예제 #1
0
    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')
예제 #2
0
    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')
예제 #3
0
 def __get__(self, instance, cls=None):
     if instance is None:
         return self
     return digattr(instance._obj, self.name, self.default)
예제 #4
0
파일: fields.py 프로젝트: tmacjx/django-nap
 def __get__(self, instance, cls=None):
     if instance is None:
         return self
     return digattr(instance._obj, self.name, self.default)