comparison _test_lookup_list.py @ 292:174374d59405

merge
author James Bergstra <bergstrj@iro.umontreal.ca>
date Fri, 06 Jun 2008 15:56:18 -0400
parents 29f394813c3c
children
comparison
equal deleted inserted replaced
291:4e6b550fe131 292:174374d59405
1 from lookup_list import *
2 import unittest
3
4 class T_LookUpList(unittest.TestCase):
5 def test_LookupList(self):
6 #test only the example in the doc???
7 example = LookupList(['x','y','z'],[1,2,3])
8 example['x'] = [1, 2, 3] # set or change a field
9 x, y, z = example
10 x = example[0]
11 x = example["x"]
12 assert example.keys()==['x','y','z']
13 assert example.values()==[[1,2,3],2,3]
14 assert example.items()==[('x',[1,2,3]),('y',2),('z',3)]
15 example.append_keyval('u',0) # adds item with name 'u' and value 0
16 assert len(example)==4 # number of items = 4 here
17 example2 = LookupList(['v','w'], ['a','b'])
18 example3 = LookupList(['x','y','z','u','v','w'], [[1, 2, 3],2,3,0,'a','b'])
19 assert example+example2==example3
20 self.assertRaises(AssertionError,example.__add__,example)
21 del example, example2, example3, x, y ,z
22
23 if __name__=='__main__':
24 unittest.main()