Exemple #1
0
 def testlistify_dict(self):
     d = {'a': [1, 2], 'b': 'x', 'c': {'d': 7, 'e': [Exception]},
          'f': (0, 1)}
     e = {'a': [1, 2], 'b': ['x'], 'c': [{'d': [7],
                                          'e': [Exception]}], 'f': [(0, 1)]}
     d2 = listify_dict(d)
     if e != d2:
         pprint(d)
         pprint(d2)
         raise AssertionError("not listified correctly")
Exemple #2
0
    def testexpand_dictFull(self):
        d1 = {0: 0}
        d2 = {1: [1, 1.1]}
        d = {'a': (0, 1), 'b': [d1, d2]}

        l = []
        l.append({'a': (0, 1), 'b': d1})
        l.append({'a': (0, 1), 'b': {1: 1}})
        l.append({'a': (0, 1), 'b': {1: 1.1}})

        l2 = list(expand_dict(listify_dict(d)))

        if not contentEqual(l, l2):
            pprint(l)
            pprint(l2)
            raise AssertionError("expand_dict produced unexpected dicts")