summaryrefslogtreecommitdiff
path: root/astroid/tests
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-20 15:14:48 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-20 15:14:48 +0300
commit48dcbe01d3da8746334b539f6274fb5fe2bb8ae2 (patch)
tree119f06459de19975861c55d44723cb716a3180b0 /astroid/tests
parenta5c81da8f022a76394e2e1e61b23d1a7a822ea41 (diff)
downloadastroid-48dcbe01d3da8746334b539f6274fb5fe2bb8ae2.tar.gz
Add `igetattr` method to scoped_nodes.Function.
Diffstat (limited to 'astroid/tests')
-rw-r--r--astroid/tests/unittest_scoped_nodes.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/astroid/tests/unittest_scoped_nodes.py b/astroid/tests/unittest_scoped_nodes.py
index b7611c5..1165534 100644
--- a/astroid/tests/unittest_scoped_nodes.py
+++ b/astroid/tests/unittest_scoped_nodes.py
@@ -537,6 +537,20 @@ class FunctionNodeTest(ModuleLoader, unittest.TestCase):
self.assertEqual(node.locals['long_classmethod'][0].type,
'classmethod')
+ def test_igetattr(self):
+ func = test_utils.extract_node('''
+ def test():
+ pass
+ ''')
+ func.instance_attrs['value'] = [nodes.Const(42)]
+ value = func.getattr('value')
+ self.assertEqual(len(value), 1)
+ self.assertIsInstance(value[0], nodes.Const)
+ self.assertEqual(value[0].value, 42)
+ inferred = next(func.igetattr('value'))
+ self.assertIsInstance(inferred, nodes.Const)
+ self.assertEqual(inferred.value, 42)
+
class ClassNodeTest(ModuleLoader, unittest.TestCase):
@@ -1136,7 +1150,9 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
self.assertIsNone(sixth_slots)
seventh_slots = astroid['Seventh'].slots()
- self.assertIsNone(seventh_slots)
+ self.assertEqual(len(seventh_slots), 1)
+ self.assertIsInstance(seventh_slots[0], nodes.Const)
+ self.assertEqual(seventh_slots[0].value, 'dedent')
eight_slots = astroid['Eight'].slots()
self.assertEqual(len(eight_slots), 1)