def test_001_simple(self): data = { 'a': 1, 'b': [1,2,3], 'c': lambda: 4, 'd': { 'a': 'test', }, } self.assertEqual(digattr(data, 'a'), 1) self.assertEqual(digattr(data, 'b.2'), 3) self.assertEqual(digattr(data, 'c'), 4) self.assertEqual(digattr(data, 'd.a'), 'test') self.assertEqual(digattr(data, 'd.a.1'), 'e')
def test_001_simple(self): data = { 'a': 1, 'b': [1, 2, 3], 'c': lambda: 4, 'd': { 'a': 'test', }, } self.assertEqual(digattr(data, 'a'), 1) self.assertEqual(digattr(data, 'b.2'), 3) self.assertEqual(digattr(data, 'c'), 4) self.assertEqual(digattr(data, 'd.a'), 'test') self.assertEqual(digattr(data, 'd.a.1'), 'e')
def __get__(self, instance, cls=None): if instance is None: return self return digattr(instance._obj, self.name, self.default)