Coverage for tests/test_deprecated.py: 36%

12 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-25 09:27 +0000

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 """Test depreaction.""" 

20 

21 def test_deprecate_pybind11(self): 

22 def old(x): 

23 """Docstring""" 

24 return x + 1 

25 

26 # Use an unusual category 

27 old = lsst.utils.deprecate_pybind11( 

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

29 ) 

30 with self.assertWarnsRegex( 

31 PendingDeprecationWarning, 

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

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

34 ): 

35 # Check that the function still works 

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

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

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

39 

40 

41if __name__ == "__main__": 

42 unittest.main()