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

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

import unittest 

import lsst.utils.tests 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

class CleanUpTestCase(unittest.TestCase): 

 

def test_clean_up(self): 

""" 

Test that sims_clean_up behaves as it should by importing a test module 

with some dummy caches, adding things to them, and then deleting them. 

""" 

from testModules.dummyModule import a_dict_cache 

from testModules.dummyModule import a_list_cache 

from lsst.sims.utils.CodeUtilities import sims_clean_up 

 

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

 

a_dict_cache['a'] = 1 

a_dict_cache['b'] = 2 

a_list_cache.append('alpha') 

a_list_cache.append('beta') 

 

self.assertEqual(len(a_dict_cache), 2) 

self.assertEqual(len(a_list_cache), 2) 

 

sims_clean_up() 

 

self.assertEqual(len(a_dict_cache), 0) 

self.assertEqual(len(a_list_cache), 0) 

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

 

# make sure that re-importing caches does not add second copies 

# to sims_clean_up.targets 

from testModules.dummyModule import a_list_cache 

 

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

 

 

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

pass 

 

46 ↛ 47line 46 didn't jump to line 47, because the condition on line 46 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()