Package rats :: Package test :: Module test_statesaving
[hide private]
[frames] | no frames]

Source Code for Module rats.test.test_statesaving

 1  #!/usr/bin/env python 
 2  """ 
 3  State saving tools 
 4   
 5  Two json modules exist. We must use the simplejson that became  
 6  the standard json module in Python 2.6 
 7  """ 
 8  from rats import statesaving 
 9  import unittest 
10  import tempfile 
11   
12  file_name = tempfile.mktemp() 
13   
14 -class Test_State_Saving(unittest.TestCase):
15 - def test_01_save(self):
16 global file_name 17 data = {} 18 data['x'] = 2 19 data['y'] = 3.14159 20 data['z'] = [1, 2, 3, 4, 5, 6] 21 data['a'] = {'egg':'white', 'ham':'pink'} 22 statesaving.save(file_name, data)
23
24 - def test_02_load(self):
25 global file_name 26 data = statesaving.load(file_name) 27 assert(data['x'] == 2) 28 assert(data['y'] == 3.14159) 29 assert(data['z'] == [1, 2, 3, 4, 5, 6]) 30 assert(data['a'] == {'egg':'white', 'ham':'pink'})
31