コード例 #1
0
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 def test_existing_without_kwarg(self):
     self.assertIsNone(gattr(NESTED_OBJ, 'get_attr', 'get_attr', 'get_attr'))
コード例 #2
0
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 def test_non_existing_is_none(self):
     self.assertIsNone(gattr(NESTED_OBJ, 'attr1', invoke_callables=True))
コード例 #3
0
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 def test_error_returns_none(self):
     self.assertIsNone(gattr(NESTED_LIST, 'notthere'))
コード例 #4
0
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 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
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 def test_non_existing_is_none(self):
     self.assertIsNone(gattr(NESTED_LIST, 42))
コード例 #6
0
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 def test_existing(self):
     self.assertEqual(gattr(NESTED_LIST, 0, 1), 1)
     self.assertEqual(gattr(NESTED_LIST, -1, 0), 2)
コード例 #7
0
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 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
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 def test_non_existing_is_none(self):
     self.assertIsNone(gattr(NESTED_DICT, 'notthere'))
コード例 #9
0
ファイル: nested.py プロジェクト: pcauthorn/python-gattr
 def test_existing(self):
     self.assertEqual(gattr(NESTED_DICT, 'k1', 'n1k1'), 'n1v1')