Hide keyboard shortcuts

Hot-keys 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

1# 

2# LSST Data Management System 

3# See COPYRIGHT file at the top of the source tree. 

4# 

5# This product includes software developed by the 

6# LSST Project (http://www.lsst.org/). 

7# 

8# This program is free software: you can redistribute it and/or modify 

9# it under the terms of the GNU General Public License as published by 

10# the Free Software Foundation, either version 3 of the License, or 

11# (at your option) any later version. 

12# 

13# This program is distributed in the hope that it will be useful, 

14# but WITHOUT ANY WARRANTY without even the implied warranty of 

15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

16# GNU General Public License for more details. 

17# 

18# You should have received a copy of the LSST License Statement and 

19# the GNU General Public License along with this program. If not, 

20# see <http://www.lsstcorp.org/LegalNotices/>. 

21# 

22 

23# -*- python -*- 

24""" 

25Regression tests for https://jira.lsstcorp.org/browse/DM-8654 

26 

27See testDm8654.cc for tests of the C++ interface. 

28 

29Run with: 

30 python test_Dm8654.py 

31or 

32 pytest test_Dm8654.py 

33""" 

34 

35 

36import unittest 

37 

38import lsst.utils.tests 

39import lsst.pex.policy as pexPolicy 

40 

41 

42class Dm8654TestSuite(lsst.utils.tests.TestCase): 

43 

44 def setUp(self): 

45 self._diversePolicy = pexPolicy.Policy() 

46 

47 self._diversePolicy.set("answer", 42) 

48 

49 self._topNames = {"answer"} 

50 

51 self._diversePolicy.add("array", 2) 

52 self._diversePolicy.add("array", 3) 

53 self._diversePolicy.add("array", 5) 

54 self._diversePolicy.add("array", 8) 

55 

56 self._topNames.add("array") 

57 

58 self._diversePolicy.set("sub.logical", "false") 

59 self._diversePolicy.set("sub.answer", "42") 

60 self._diversePolicy.set("sub.stringlyTyped", "true") 

61 

62 self._topNames.add("sub") 

63 self._fullNames = self._topNames | {"sub.logical", "sub.answer", "sub.stringlyTyped"} 

64 

65 def tearDown(self): 

66 # For some reason Policies don't get garbage collected(at least in Swig) 

67 del self._diversePolicy 

68 

69 def testNamesExpected(self): 

70 """Test if `Policy::names(bool)` returns heirarchical names if and 

71 only if they are requested. 

72 """ 

73 self.assertEqual(set(self._diversePolicy.names()), self._fullNames) 

74 self.assertEqual(set(self._diversePolicy.names(True)), self._topNames) 

75 self.assertEqual(set(self._diversePolicy.names(False)), self._fullNames) 

76 

77 

78class MemoryTester(lsst.utils.tests.MemoryTestCase): 

79 pass 

80 

81 

82def setup_module(module): 

83 lsst.utils.tests.init() 

84 

85 

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

87 lsst.utils.tests.init() 

88 unittest.main()