diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2016-06-29 10:04:26 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-06-29 10:04:26 +0100 |
| commit | 76cfc8e8a02a6ef7e6bc61624d3b24503ee3a235 (patch) | |
| tree | 741df3f0b807b758b7ea156351bece7cd9f49f0b /astroid/tests/unittest_objects.py | |
| parent | 02f1250178c22f4f4b249e4e5377651de407c522 (diff) | |
| download | astroid-git-76cfc8e8a02a6ef7e6bc61624d3b24503ee3a235.tar.gz | |
New function, astroid.extract_node, exported out from astroid.test_utils.
Diffstat (limited to 'astroid/tests/unittest_objects.py')
| -rw-r--r-- | astroid/tests/unittest_objects.py | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/astroid/tests/unittest_objects.py b/astroid/tests/unittest_objects.py index f5c70c0f..d78301f9 100644 --- a/astroid/tests/unittest_objects.py +++ b/astroid/tests/unittest_objects.py @@ -6,6 +6,7 @@ import unittest import six +import astroid from astroid import exceptions from astroid import nodes from astroid.interpreter import objects @@ -18,7 +19,7 @@ BUILTINS = six.moves.builtins.__name__ class ObjectsTest(unittest.TestCase): def test_frozenset(self): - node = test_utils.extract_node(""" + node = astroid.extract_node(""" frozenset({1: 2, 2: 3}) #@ """) inferred = next(node.infer()) @@ -39,7 +40,7 @@ class ObjectsTest(unittest.TestCase): class SuperTests(unittest.TestCase): def test_inferring_super_outside_methods(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class Module(object): pass class StaticMethod(object): @@ -65,7 +66,7 @@ class SuperTests(unittest.TestCase): self.assertEqual(no_arguments.qname(), "%s.super" % BUILTINS) def test_inferring_unbound_super_doesnt_work(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class Test(object): def __init__(self): super(Test) #@ @@ -75,7 +76,7 @@ class SuperTests(unittest.TestCase): self.assertEqual(unbounded.qname(), "%s.super" % BUILTINS) def test_use_default_inference_on_not_inferring_args(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class Test(object): def __init__(self): super(Lala, self) #@ @@ -94,7 +95,7 @@ class SuperTests(unittest.TestCase): # super doesn't work on old style class, but leave # that as an error for pylint. We'll infer Super objects, # but every call will result in a failure at some point. - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class OldStyle: def __init__(self): super(OldStyle, self) #@ @@ -110,7 +111,7 @@ class SuperTests(unittest.TestCase): @test_utils.require_version(minver='3.0') def test_no_arguments_super(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class First(object): pass class Second(First): def test(self): @@ -134,7 +135,7 @@ class SuperTests(unittest.TestCase): self.assertEqual(second.mro_pointer.name, 'Second') def test_super_simple_cases(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class First(object): pass class Second(First): pass class Third(First): @@ -196,7 +197,7 @@ class SuperTests(unittest.TestCase): self.assertEqual(fifth.mro_pointer.name, 'Fourth') def test_super_infer(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class Super(object): def __init__(self): super(Super, self) #@ @@ -208,7 +209,7 @@ class SuperTests(unittest.TestCase): self.assertIs(inferred, reinferred) def test_inferring_invalid_supers(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class Super(object): def __init__(self): # MRO pointer is not a type @@ -235,7 +236,7 @@ class SuperTests(unittest.TestCase): self.assertIsInstance(cm.exception.super_.type, invalid_type) def test_proxied(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class Super(object): def __init__(self): super(Super, self) #@ @@ -246,7 +247,7 @@ class SuperTests(unittest.TestCase): self.assertIsInstance(proxied, nodes.ClassDef) def test_super_bound_model(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class First(object): def method(self): pass @@ -299,7 +300,7 @@ class SuperTests(unittest.TestCase): self.assertEqual(sixth.type, 'classmethod') def test_super_getattr_single_inheritance(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class First(object): def test(self): pass class Second(First): @@ -345,7 +346,7 @@ class SuperTests(unittest.TestCase): self.assertEqual(second_unbound.parent.name, 'First') def test_super_invalid_mro(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class A(object): test = 42 class Super(A, A): @@ -357,7 +358,7 @@ class SuperTests(unittest.TestCase): next(inferred.getattr('test')) def test_super_complex_mro(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class A(object): def spam(self): return "A" def foo(self): return "A" @@ -392,7 +393,7 @@ class SuperTests(unittest.TestCase): self.assertEqual(static.parent.scope().name, 'A') def test_super_data_model(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class X(object): pass class A(X): def __init__(self): @@ -432,7 +433,7 @@ class SuperTests(unittest.TestCase): expected_mro) def test_super_mro(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' class A(object): pass class B(A): pass class C(A): pass @@ -460,7 +461,7 @@ class SuperTests(unittest.TestCase): fifth.super_mro() def test_super_yes_objects(self): - ast_nodes = test_utils.extract_node(''' + ast_nodes = astroid.extract_node(''' from collections import Missing class A(object): def __init__(self): @@ -473,7 +474,7 @@ class SuperTests(unittest.TestCase): self.assertIsInstance(second, objects.Instance) def test_super_invalid_types(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' import collections class A(object): def __init__(self): @@ -486,7 +487,7 @@ class SuperTests(unittest.TestCase): inferred.super_mro() def test_super_properties(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class Foo(object): @property def dict(self): @@ -507,7 +508,7 @@ class SuperTests(unittest.TestCase): class MethodTest(unittest.TestCase): def test_unbound_function_method_difference(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class A: def test(self): pass A.test @@ -519,7 +520,7 @@ class MethodTest(unittest.TestCase): self.assertIsInstance(inferred, nodes.FunctionDef) def test_unbound_function_from_classmethods(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class A: @classmethod def test(cls): return cls.b @@ -533,7 +534,7 @@ class MethodTest(unittest.TestCase): self.assertIsInstance(inferred, nodes.FunctionDef) def test_static_method(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class A: @staticmethod def test(self): pass @@ -544,7 +545,7 @@ class MethodTest(unittest.TestCase): @unittest.skipUnless(six.PY2, "Unbound methods are available only on Python 2") def test_underlying_proxied_unbound_method(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class A: def test(self): pass A.test @@ -553,7 +554,7 @@ class MethodTest(unittest.TestCase): self.assertIsInstance(inferred._proxied, nodes.FunctionDef) def test_underlying_proxied_bound_method(self): - node = test_utils.extract_node(''' + node = astroid.extract_node(''' class A: def test(self): pass A().test |
