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)
def test_multi_hop_link(self): od = {'a': '$(b)', 'b': '$(c)', 'c': 'd'} d = _DotDict(od) self.assertEqual(d['a'], d['c'])
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'])
def test_link(self): od = {'a': '$(b)'} link = {'b': 'c'} d = _DotDict(od, link) self.assertEqual(d['a'], link['b'])
def test_dot_path_construct(self): od = {'a.b': 1} d = _DotDict(od) self.assertDictEqual(d._mapping, {'a': {'b': 1}})
def test_incorrect_type_construct(self): with self.assertRaises(TypeError): _DotDict(1)
def test_simple_construct(self): od = {'a': 1} d = _DotDict(od) self.assertDictEqual(d._mapping, od)
def setUp(self): self.od = {'a': 1, 'b': {'c': 2}} self.d = _DotDict(self.od)
def test_arith_tag(self): od = {'a': ArithTag('2')} d = _DotDict(od) self.assertEqual(d['a'], 2)