Example #1
0
 def testFreeze(self):
     "Test freeze"
     self.assertEqual(freeze([1, 2, 3]), (1, 2, 3))
     self.assertEqual(freeze({"list": [1, 2, 3]}), frozenset([("list", (1, 2, 3))]))
     self.assertEqual(
         freeze({"dict": {"inner dict": {"list": [1, 2, 3], "string": "test"}}}),
         frozenset([("dict", frozenset([("inner dict", frozenset([("list", (1, 2, 3)), ("string", "test")]))]))]),
     )
Example #2
0
 def testFreeze(self):
     "Test freeze"
     self.assertEqual(freeze([1, 2, 3]), (1, 2, 3))
     self.assertEqual(freeze({
         'list': [1, 2, 3],
     }), frozenset([('list', (1, 2, 3))]))
     self.assertEqual(
         freeze({
             'dict': {
                 'inner dict': {
                     'list': [1, 2, 3],
                     'string': 'test',
                 },
             }
         }),
         frozenset([('dict',
                     frozenset([('inner dict',
                                 frozenset([
                                     ('list', (1, 2, 3)),
                                     ('string', 'test'),
                                 ]))]))]))
Example #3
0
 def testUnfreeze(self):
     "Test unfreeze"
     for value, result in [
             (freeze([1, 2, 3]), (1, 2, 3)),
             (freeze({'dict': {
                             'inner dict': {
                                 'list': [1, 2, 3],
                                 'string': 'test',
                                 },
                             },
                         }),
                 {'dict': {
                         'inner dict': {
                             'list': (1, 2, 3),
                             'string': 'test',
                             },
                         },
                     }),
             ]:
         with self.subTest(value=value):
             self.assertEqual(unfreeze(value), result)
Example #4
0
 def testFreeze(self):
     "Test freeze"
     self.assertEqual(freeze([1, 2, 3]), (1, 2, 3))
     self.assertEqual(freeze({
                 'list': [1, 2, 3],
                 }),
         frozenset([('list', (1, 2, 3))]))
     self.assertEqual(freeze({
                 'dict': {
                     'inner dict': {
                         'list': [1, 2, 3],
                         'string': 'test',
                         },
                     }
                 }),
         frozenset([('dict',
                     frozenset([('inner dict',
                                 frozenset([
                                         ('list', (1, 2, 3)),
                                         ('string', 'test'),
                                         ]))]))]))