예제 #1
0
 def test_nested_dot_path_construct(self):
     od = {'a.b': {'c.d': 1}}
     d = _DotDict(od)
     td = {'a': {'b': {'c': {'d': 1}}}}
     self.assertDictEqual(d._mapping, td)
     od = {'a': {'b': {'c.d': 1}}}
     d = _DotDict(od)
     self.assertDictEqual(d._mapping, td)
예제 #2
0
 def test_multi_hop_link(self):
     od = {'a': '$(b)', 'b': '$(c)', 'c': 'd'}
     d = _DotDict(od)
     self.assertEqual(d['a'], d['c'])
예제 #3
0
 def test_dot_path_link(self):
     od = {'a': '$(b.c)'}
     link = _DotDict({'b': {'c': 'd'}})
     d = _DotDict(od, link)
     self.assertEqual(d['a'], link['b']['c'])
예제 #4
0
 def test_link(self):
     od = {'a': '$(b)'}
     link = {'b': 'c'}
     d = _DotDict(od, link)
     self.assertEqual(d['a'], link['b'])
예제 #5
0
 def test_dot_path_construct(self):
     od = {'a.b': 1}
     d = _DotDict(od)
     self.assertDictEqual(d._mapping, {'a': {'b': 1}})
예제 #6
0
 def test_incorrect_type_construct(self):
     with self.assertRaises(TypeError):
         _DotDict(1)
예제 #7
0
 def test_simple_construct(self):
     od = {'a': 1}
     d = _DotDict(od)
     self.assertDictEqual(d._mapping, od)
예제 #8
0
 def setUp(self):
     self.od = {'a': 1, 'b': {'c': 2}}
     self.d = _DotDict(self.od)
예제 #9
0
 def test_arith_tag(self):
     od = {'a': ArithTag('2')}
     d = _DotDict(od)
     self.assertEqual(d['a'], 2)