test/unittest_utils.py
brancholdstable
changeset 7074 e4580e5f0703
parent 6415 b0b0f097a72d
child 7277 acd7f0e9f276
child 7568 c5ee33fb6a3b
equal deleted inserted replaced
6749:48f468f33704 7074:e4580e5f0703
    31 except ImportError:
    31 except ImportError:
    32     json = None
    32     json = None
    33 
    33 
    34 class MakeUidTC(TestCase):
    34 class MakeUidTC(TestCase):
    35     def test_1(self):
    35     def test_1(self):
    36         self.assertNotEquals(make_uid('xyz'), make_uid('abcd'))
    36         self.assertNotEqual(make_uid('xyz'), make_uid('abcd'))
    37         self.assertNotEquals(make_uid('xyz'), make_uid('xyz'))
    37         self.assertNotEqual(make_uid('xyz'), make_uid('xyz'))
    38 
    38 
    39     def test_2(self):
    39     def test_2(self):
    40         d = set()
    40         d = set()
    41         while len(d)<10000:
    41         while len(d)<10000:
    42             uid = make_uid('xyz')
    42             uid = make_uid('xyz')
   138     def test_encoding_decimal(self):
   138     def test_encoding_decimal(self):
   139         self.assertEqual(self.encode(decimal.Decimal('1.2')), '1.2')
   139         self.assertEqual(self.encode(decimal.Decimal('1.2')), '1.2')
   140 
   140 
   141     def test_encoding_bare_entity(self):
   141     def test_encoding_bare_entity(self):
   142         e = Entity(None)
   142         e = Entity(None)
   143         e['pouet'] = 'hop'
   143         e.cw_attr_cache['pouet'] = 'hop'
   144         e.eid = 2
   144         e.eid = 2
   145         self.assertEqual(json.loads(self.encode(e)),
   145         self.assertEqual(json.loads(self.encode(e)),
   146                           {'pouet': 'hop', 'eid': 2})
   146                           {'pouet': 'hop', 'eid': 2})
   147 
   147 
   148     def test_encoding_entity_in_list(self):
   148     def test_encoding_entity_in_list(self):
   149         e = Entity(None)
   149         e = Entity(None)
   150         e['pouet'] = 'hop'
   150         e.cw_attr_cache['pouet'] = 'hop'
   151         e.eid = 2
   151         e.eid = 2
   152         self.assertEqual(json.loads(self.encode([e])),
   152         self.assertEqual(json.loads(self.encode([e])),
   153                           [{'pouet': 'hop', 'eid': 2}])
   153                           [{'pouet': 'hop', 'eid': 2}])
   154 
   154 
   155     def test_encoding_unknown_stuff(self):
   155     def test_encoding_unknown_stuff(self):