summaryrefslogtreecommitdiff
path: root/tests/brain
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-02-09 22:48:16 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2023-02-09 23:53:46 +0100
commit1ff5fbdb773598d59d0a33729b4bbcb2e6d38f14 (patch)
tree73af9e464f91a9a4b87e17bd436e5c3959be847a /tests/brain
parentcd4ee62622eb40c86cf1c3b79bdd251de6f1dca7 (diff)
downloadastroid-git-1ff5fbdb773598d59d0a33729b4bbcb2e6d38f14.tar.gz
[brain tests] Burst typing extensions from the main file
Diffstat (limited to 'tests/brain')
-rw-r--r--tests/brain/test_brain.py32
-rw-r--r--tests/brain/test_typing_extensions.py41
2 files changed, 41 insertions, 32 deletions
diff --git a/tests/brain/test_brain.py b/tests/brain/test_brain.py
index 948dad26..a0bbd8ec 100644
--- a/tests/brain/test_brain.py
+++ b/tests/brain/test_brain.py
@@ -23,15 +23,6 @@ from astroid.exceptions import (
from astroid.nodes.node_classes import Const
from astroid.nodes.scoped_nodes import ClassDef
-try:
- import typing_extensions # pylint: disable=unused-import
-
- HAS_TYPING_EXTENSIONS = True
- HAS_TYPING_EXTENSIONS_TYPEVAR = hasattr(typing_extensions, "TypeVar")
-except ImportError:
- HAS_TYPING_EXTENSIONS = False
- HAS_TYPING_EXTENSIONS_TYPEVAR = False
-
def assertEqualMro(klass: ClassDef, expected_mro: list[str]) -> None:
"""Check mro names."""
@@ -1519,29 +1510,6 @@ class TypingBrain(unittest.TestCase):
assert i1.value == 2 # should be "Hello"!
-@pytest.mark.skipif(
- not HAS_TYPING_EXTENSIONS,
- reason="These tests require the typing_extensions library",
-)
-class TestTypingExtensions:
- @staticmethod
- @pytest.mark.skipif(
- not HAS_TYPING_EXTENSIONS_TYPEVAR,
- reason="Need typing_extensions>=4.4.0 to test TypeVar",
- )
- def test_typing_extensions_types() -> None:
- ast_nodes = builder.extract_node(
- """
- from typing_extensions import TypeVar
- TypeVar('MyTypeVar', int, float, complex) #@
- TypeVar('AnyStr', str, bytes) #@
- """
- )
- for node in ast_nodes:
- inferred = next(node.infer())
- assert isinstance(inferred, nodes.ClassDef)
-
-
class ReBrainTest(unittest.TestCase):
def test_regex_flags(self) -> None:
names = [name for name in dir(re) if name.isupper()]
diff --git a/tests/brain/test_typing_extensions.py b/tests/brain/test_typing_extensions.py
new file mode 100644
index 00000000..27ee6ee5
--- /dev/null
+++ b/tests/brain/test_typing_extensions.py
@@ -0,0 +1,41 @@
+# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
+# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
+# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
+
+from __future__ import annotations
+
+import pytest
+
+from astroid import builder, nodes
+
+try:
+ import typing_extensions # pylint: disable=unused-import
+
+ HAS_TYPING_EXTENSIONS = True
+ HAS_TYPING_EXTENSIONS_TYPEVAR = hasattr(typing_extensions, "TypeVar")
+except ImportError:
+ HAS_TYPING_EXTENSIONS = False
+ HAS_TYPING_EXTENSIONS_TYPEVAR = False
+
+
+@pytest.mark.skipif(
+ not HAS_TYPING_EXTENSIONS,
+ reason="These tests require the typing_extensions library",
+)
+class TestTypingExtensions:
+ @staticmethod
+ @pytest.mark.skipif(
+ not HAS_TYPING_EXTENSIONS_TYPEVAR,
+ reason="Need typing_extensions>=4.4.0 to test TypeVar",
+ )
+ def test_typing_extensions_types() -> None:
+ ast_nodes = builder.extract_node(
+ """
+ from typing_extensions import TypeVar
+ TypeVar('MyTypeVar', int, float, complex) #@
+ TypeVar('AnyStr', str, bytes) #@
+ """
+ )
+ for node in ast_nodes:
+ inferred = next(node.infer())
+ assert isinstance(inferred, nodes.ClassDef)