diff options
| author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-19 13:26:15 +0200 |
|---|---|---|
| committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-19 21:40:08 +0200 |
| commit | 11722b99525122ca7323fddc8b5791085b179399 (patch) | |
| tree | b83179b5ca836a19fe7b6be3461e7ac614dc54ba /tests | |
| parent | 24f9672270908b76c62448c7f02306deb5b366a4 (diff) | |
| download | astroid-git-11722b99525122ca7323fddc8b5791085b179399.tar.gz | |
Simplification because AstroidManager is a singleton/borg
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/resources.py | 7 | ||||
| -rw-r--r-- | tests/unittest_inference.py | 2 | ||||
| -rw-r--r-- | tests/unittest_scoped_nodes.py | 4 | ||||
| -rw-r--r-- | tests/unittest_transforms.py | 8 |
4 files changed, 11 insertions, 10 deletions
diff --git a/tests/resources.py b/tests/resources.py index 20adc2f8..fe24a347 100644 --- a/tests/resources.py +++ b/tests/resources.py @@ -13,8 +13,9 @@ import os import sys -from astroid import MANAGER, builder +from astroid import builder from astroid.bases import BUILTINS +from astroid.manager import AstroidManager DATA_DIR = os.path.join("testdata", "python3") RESOURCE_PATH = os.path.join(os.path.dirname(__file__), DATA_DIR, "data") @@ -56,9 +57,9 @@ class AstroidCacheSetupMixin: @classmethod def setup_class(cls): - cls._builtins = MANAGER.astroid_cache.get(BUILTINS) + cls._builtins = AstroidManager().astroid_cache.get(BUILTINS) @classmethod def teardown_class(cls): if cls._builtins: - MANAGER.astroid_cache[BUILTINS] = cls._builtins + AstroidManager().astroid_cache[BUILTINS] = cls._builtins diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py index 0795dcb7..e124177d 100644 --- a/tests/unittest_inference.py +++ b/tests/unittest_inference.py @@ -5218,7 +5218,7 @@ def test_limit_inference_result_amount(): """ result = extract_node(code).inferred() assert len(result) == 16 - with patch("astroid.node_classes.MANAGER.max_inferable_values", 4): + with patch("astroid.manager.AstroidManager.max_inferable_values", 4): result_limited = extract_node(code).inferred() # Can't guarantee exact size assert len(result_limited) < 16 diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py index 287eaafd..1b376a31 100644 --- a/tests/unittest_scoped_nodes.py +++ b/tests/unittest_scoped_nodes.py @@ -39,7 +39,7 @@ from functools import partial import pytest -from astroid import builder, nodes, objects, scoped_nodes, test_utils, util +from astroid import MANAGER, builder, nodes, objects, scoped_nodes, test_utils, util from astroid.bases import BUILTINS, BoundMethod, Generator, Instance, UnboundMethod from astroid.exceptions import ( AttributeInferenceError, @@ -1389,7 +1389,7 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase): A1 = astroid.getattr("A1")[0] B1 = astroid.getattr("B1")[0] C1 = astroid.getattr("C1")[0] - object_ = builder.MANAGER.astroid_cache[BUILTINS].getattr("object")[0] + object_ = MANAGER.astroid_cache[BUILTINS].getattr("object")[0] self.assertEqual( cm.exception.mros, [[B1, C1, A1, object_], [C1, B1, A1, object_]] ) diff --git a/tests/unittest_transforms.py b/tests/unittest_transforms.py index 9db783ef..e07abc2e 100644 --- a/tests/unittest_transforms.py +++ b/tests/unittest_transforms.py @@ -14,7 +14,7 @@ import contextlib import time import unittest -from astroid import builder, nodes, parse, transforms +from astroid import MANAGER, builder, nodes, parse, transforms @contextlib.contextmanager @@ -152,7 +152,7 @@ class TestTransforms(unittest.TestCase): return next(node.infer_call_result()) return None - manager = builder.MANAGER + manager = MANAGER with add_transform(manager, nodes.FunctionDef, transform_function): module = builder.parse( """ @@ -186,7 +186,7 @@ class TestTransforms(unittest.TestCase): node.args.args = [name] return node - manager = builder.MANAGER + manager = MANAGER def predicate(node): return node.root().name == "time" @@ -204,7 +204,7 @@ class TestTransforms(unittest.TestCase): def transform_function(node): return nodes.const_factory(42) - manager = builder.MANAGER + manager = MANAGER with add_transform(manager, nodes.FunctionDef, transform_function): astroid_builder = builder.AstroidBuilder(apply_transforms=False) module = astroid_builder.string_build("""def test(): pass""") |
