Coverage for tests/testCleanUp.py : 31%

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
1import unittest
2import lsst.utils.tests
5def setup_module(module):
6 lsst.utils.tests.init()
9class CleanUpTestCase(unittest.TestCase):
11 def test_clean_up(self):
12 """
13 Test that sims_clean_up behaves as it should by importing a test module
14 with some dummy caches, adding things to them, and then deleting them.
15 """
16 from testModules.dummyModule import a_dict_cache
17 from testModules.dummyModule import a_list_cache
18 from lsst.sims.utils.CodeUtilities import sims_clean_up
20 self.assertEqual(len(sims_clean_up.targets), 2)
22 a_dict_cache['a'] = 1
23 a_dict_cache['b'] = 2
24 a_list_cache.append('alpha')
25 a_list_cache.append('beta')
27 self.assertEqual(len(a_dict_cache), 2)
28 self.assertEqual(len(a_list_cache), 2)
30 sims_clean_up()
32 self.assertEqual(len(a_dict_cache), 0)
33 self.assertEqual(len(a_list_cache), 0)
34 self.assertEqual(len(sims_clean_up.targets), 2)
36 # make sure that re-importing caches does not add second copies
37 # to sims_clean_up.targets
38 from testModules.dummyModule import a_list_cache
40 self.assertEqual(len(sims_clean_up.targets), 2)
43class MemoryTestClass(lsst.utils.tests.MemoryTestCase):
44 pass
46if __name__ == "__main__": 46 ↛ 47line 46 didn't jump to line 47, because the condition on line 46 was never true
47 lsst.utils.tests.init()
48 unittest.main()