Coverage for tests/test_deprecated.py: 50%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

1# This file is part of utils. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# Use of this source code is governed by a 3-clause BSD-style 

10# license that can be found in the LICENSE file. 

11 

12import unittest 

13import lsst.utils.tests 

14 

15import lsst.utils 

16 

17 

18class DeprecatedTestCase(lsst.utils.tests.TestCase): 

19 def test_deprecate_pybind11(self): 

20 def old(x): 

21 """Docstring""" 

22 return x + 1 

23 # Use an unusual category 

24 old = lsst.utils.deprecate_pybind11( 

25 old, reason="For testing.", version="unknown", 

26 category=PendingDeprecationWarning) 

27 with self.assertWarnsRegex( 

28 PendingDeprecationWarning, 

29 r"Call to deprecated function \(or staticmethod\) old\. \(For testing\.\) " 

30 "-- Deprecated since version unknown.$"): 

31 # Check that the function still works 

32 self.assertEqual(old(3), 4) 

33 self.assertIn("Docstring", old.__doc__) 

34 self.assertIn("For testing.", old.__doc__) 

35 

36 

37if __name__ == "__main__": 37 ↛ 38line 37 didn't jump to line 38, because the condition on line 37 was never true

38 unittest.main()