Coverage for tests/test_deprecated.py: 39%

14 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-02-04 02:34 -0800

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 

13 

14import lsst.utils 

15import lsst.utils.tests 

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 

24 # Use an unusual category 

25 old = lsst.utils.deprecate_pybind11( 

26 old, reason="For testing.", version="unknown", category=PendingDeprecationWarning 

27 ) 

28 with self.assertWarnsRegex( 

29 PendingDeprecationWarning, 

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

31 "-- Deprecated since version unknown.$", 

32 ): 

33 # Check that the function still works 

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

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

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

37 

38 

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

40 unittest.main()