test/unittest_utils.py
branchtls-sprint
changeset 1802 d628defebc17
parent 720 36b64f712ec9
child 1977 606923dff11b
equal deleted inserted replaced
1801:672acc730ce5 1802:d628defebc17
     7 
     7 
     8 class MakeUidTC(TestCase):
     8 class MakeUidTC(TestCase):
     9     def test_1(self):
     9     def test_1(self):
    10         self.assertNotEquals(make_uid('xyz'), make_uid('abcd'))
    10         self.assertNotEquals(make_uid('xyz'), make_uid('abcd'))
    11         self.assertNotEquals(make_uid('xyz'), make_uid('xyz'))
    11         self.assertNotEquals(make_uid('xyz'), make_uid('xyz'))
    12         
    12 
    13     def test_2(self):
    13     def test_2(self):
    14         d = {}
    14         d = {}
    15         while len(d)<10000:
    15         while len(d)<10000:
    16             uid = make_uid('xyz')
    16             uid = make_uid('xyz')
    17             if d.has_key(uid):
    17             if d.has_key(uid):
    18                 self.fail(len(d))
    18                 self.fail(len(d))
    19             d[uid] = 1
    19             d[uid] = 1
    20 
    20 
    21         
    21 
    22 class UStringIOTC(TestCase):
    22 class UStringIOTC(TestCase):
    23     def test_boolean_value(self):
    23     def test_boolean_value(self):
    24         self.assert_(UStringIO())
    24         self.assert_(UStringIO())
    25 
    25 
    26 
    26 
    29     def test_append(self):
    29     def test_append(self):
    30         l = SizeConstrainedList(10)
    30         l = SizeConstrainedList(10)
    31         for i in xrange(12):
    31         for i in xrange(12):
    32             l.append(i)
    32             l.append(i)
    33         self.assertEquals(l, range(2, 12))
    33         self.assertEquals(l, range(2, 12))
    34     
    34 
    35     def test_extend(self):
    35     def test_extend(self):
    36         testdata = [(range(5), range(5)),
    36         testdata = [(range(5), range(5)),
    37                     (range(10), range(10)),
    37                     (range(10), range(10)),
    38                     (range(12), range(2, 12)),
    38                     (range(12), range(2, 12)),
    39                     ]
    39                     ]
    40         for extension, expected in testdata:
    40         for extension, expected in testdata:
    41             l = SizeConstrainedList(10)
    41             l = SizeConstrainedList(10)
    42             l.extend(extension)
    42             l.extend(extension)
    43             yield self.assertEquals, l, expected
    43             yield self.assertEquals, l, expected
    44 
    44 
    45    
    45 
    46 if __name__ == '__main__':
    46 if __name__ == '__main__':
    47     unittest_main()
    47     unittest_main()