Пример #1
0
 def test_existing_without_kwarg(self):
     self.assertIsNone(gattr(NESTED_OBJ, 'get_attr', 'get_attr', 'get_attr'))
Пример #2
0
 def test_non_existing_is_none(self):
     self.assertIsNone(gattr(NESTED_OBJ, 'attr1', invoke_callables=True))
Пример #3
0
 def test_error_returns_none(self):
     self.assertIsNone(gattr(NESTED_LIST, 'notthere'))
Пример #4
0
 def test_existing(self):
     self.assertEqual(gattr(NESTED_OBJ, 'get_attr', 'get_attr', 'get_attr', invoke_callables=True), 'value')
     self.assertEqual(gattr(NESTED_OBJ, 'attr', 'get_attr', 'attr', invoke_callables=True), 'value')
     self.assertEqual(gattr(NESTED_OBJ, 'attr', 'attr', 'attr'), 'value')
Пример #5
0
 def test_non_existing_is_none(self):
     self.assertIsNone(gattr(NESTED_LIST, 42))
Пример #6
0
 def test_existing(self):
     self.assertEqual(gattr(NESTED_LIST, 0, 1), 1)
     self.assertEqual(gattr(NESTED_LIST, -1, 0), 2)
Пример #7
0
 def test_default(self):
     self.assertEqual(gattr(NESTED_DICT, 'notthere', default='default'), 'default')
     self.assertEqual(gattr(NESTED_DICT, 'k1', 'n1k1', default='hello'), 'n1v1')
Пример #8
0
 def test_non_existing_is_none(self):
     self.assertIsNone(gattr(NESTED_DICT, 'notthere'))
Пример #9
0
 def test_existing(self):
     self.assertEqual(gattr(NESTED_DICT, 'k1', 'n1k1'), 'n1v1')