def test_getsetattr(self): life = _RecursiveAttrDict(self.INITIAL) life['universe.galaxy'] = 'milky way' self.assertEqual(life.universe.galaxy, 'milky way') life['universe.a.b.c.d.e'] = 4 self.assertEqual(life.universe.a.b.c.d.e, 4) self.assertEqual(life.universe.a.b.c.d, {'e': 4}) self.assertEqual(life['universe.a.b.c.d.e'], 4)
def test_builtin_getsetattr(self): life = _RecursiveAttrDict(self.INITIAL) self.assertEqual(getattr(life.bigbang.stars, 'planet'), 'earth') setattr(life, 'planet.stars', 'sol') self.assertEqual(getattr(life, 'planet.stars'), 'sol')
def test_init(self): life = _RecursiveAttrDict(self.INITIAL) self.assertEqual(life.bigbang.stars.planet, 'earth') self.assertEqual(life.bigbang.center, 'sol') self.assertEqual(life.bigbang, life['bigbang'])
def test_contains(self): life = _RecursiveAttrDict(self.INITIAL) self.assertTrue('bigbang.stars.planet' in life) self.assertFalse('bigbang.stars.planet.earth' in life) self.assertFalse('bigbang.d.x' in life)