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

1import unittest 

2import lsst.utils.tests 

3 

4 

5def setup_module(module): 

6 lsst.utils.tests.init() 

7 

8 

9class CleanUpTestCase(unittest.TestCase): 

10 

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 

19 

20 self.assertEqual(len(sims_clean_up.targets), 2) 

21 

22 a_dict_cache['a'] = 1 

23 a_dict_cache['b'] = 2 

24 a_list_cache.append('alpha') 

25 a_list_cache.append('beta') 

26 

27 self.assertEqual(len(a_dict_cache), 2) 

28 self.assertEqual(len(a_list_cache), 2) 

29 

30 sims_clean_up() 

31 

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) 

35 

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 

39 

40 self.assertEqual(len(sims_clean_up.targets), 2) 

41 

42 

43class MemoryTestClass(lsst.utils.tests.MemoryTestCase): 

44 pass 

45 

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()