Exemple #1
0
 def test_fromkeys(self):
     k = [
         'a',
         'a.b',
         'a.b.c',
         'a.b.d',
         'a.b.e',
         'x',
         'x.y',
         'x.z',
     ]
     b = KeypathDict.fromkeys(k)
     r = {
         'x': {
             'y': None,
             'z': None,
         },
         'a': {
             'b': {
                 'c': None,
                 'd': None,
                 'e': None,
             },
         },
     }
     self.assertEqual(b, r)
Exemple #2
0
 def test_fromkeys_with_value(self):
     k = [
         'a',
         'a.b',
         'a.b.c',
         'a.b.d',
         'a.b.e',
         'x',
         'x.y',
         'x.z',
     ]
     b = KeypathDict.fromkeys(k, True)
     r = {
         'x': {
             'y': True,
             'z': True,
         },
         'a': {
             'b': {
                 'c': True,
                 'd': True,
                 'e': True,
             },
         },
     }
     self.assertEqual(b, r)