Beispiel #1
0
 def test_levels3(self):
     ddict = common.nested_defaultdict(int, levels=3)
     ddict['a1']['a2']['a3'] = 1
     ddict['a1']['b2'] = 2
     benchmark = {'a1': {'a2': {'a3': 1}}}
     benchmark['a1']['b2'] = 2
     self.assertEqual(ddict, benchmark)
Beispiel #2
0
 def test_levels2(self):
     ddict = common.nested_defaultdict(int, levels=2)
     self.assertTrue(isinstance(ddict, defaultdict))
     self.assertTrue(isinstance(ddict['k1'], defaultdict))
     self.assertEqual(ddict['k1']['k2'], 0)
     benchmark = {'k1': {'k2': 0}}
     self.assertEqual(ddict, benchmark)
Beispiel #3
0
 def test_levels3(self):
     ddict = common.nested_defaultdict(int, levels=3)
     ddict['a1']['a2']['a3'] = 1
     ddict['a1']['b2'] = 2
     benchmark = {'a1': {'a2': {'a3': 1}}}
     benchmark['a1']['b2'] = 2
     self.assertEqual(ddict, benchmark)
Beispiel #4
0
 def test_levels2(self):
     ddict = common.nested_defaultdict(int, levels=2)
     self.assertTrue(isinstance(ddict, defaultdict))
     self.assertTrue(isinstance(ddict['k1'], defaultdict))
     self.assertEqual(ddict['k1']['k2'], 0)
     benchmark = {'k1': {'k2': 0}}
     self.assertEqual(ddict, benchmark)
Beispiel #5
0
 def test_levels1(self):
     ddict = common.nested_defaultdict(int, levels=1)
     self.assertTrue(isinstance(ddict, defaultdict))
     self.assertEqual(ddict['key1'], 0)
Beispiel #6
0
 def test_levels1(self):
     ddict = common.nested_defaultdict(int, levels=1)
     self.assertTrue(isinstance(ddict, defaultdict))
     self.assertEqual(ddict['key1'], 0)