예제 #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')