diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_builder.py | 14 | ||||
-rw-r--r-- | tests/test_inference.py | 6 | ||||
-rw-r--r-- | tests/test_nodes.py | 27 | ||||
-rw-r--r-- | tests/test_nodes_lineno.py | 6 | ||||
-rw-r--r-- | tests/test_protocols.py | 3 | ||||
-rw-r--r-- | tests/test_regrtest.py | 2 | ||||
-rw-r--r-- | tests/test_scoped_nodes.py | 11 | ||||
-rw-r--r-- | tests/test_utils.py | 6 |
8 files changed, 15 insertions, 60 deletions
diff --git a/tests/test_builder.py b/tests/test_builder.py index 15ee26c5..b4a0c464 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -19,7 +19,7 @@ import unittest.mock import pytest from astroid import Instance, builder, nodes, test_utils, util -from astroid.const import IS_PYPY, PY38, PY38_PLUS, PY39_PLUS, PYPY_7_3_11_PLUS +from astroid.const import IS_PYPY, PY38, PY39_PLUS, PYPY_7_3_11_PLUS from astroid.exceptions import ( AstroidBuildingError, AstroidSyntaxError, @@ -62,10 +62,7 @@ class FromToLineNoTest(unittest.TestCase): else: self.assertEqual(strarg.tolineno, 5) else: - if not PY38_PLUS: - self.assertEqual(strarg.fromlineno, 5) - else: - self.assertEqual(strarg.fromlineno, 4) + self.assertEqual(strarg.fromlineno, 4) self.assertEqual(strarg.tolineno, 5) namearg = callfunc.args[1] self.assertIsInstance(namearg, nodes.Name) @@ -160,8 +157,8 @@ class FromToLineNoTest(unittest.TestCase): c = ast_module.body[2] assert isinstance(c, nodes.ClassDef) - if not PY38_PLUS or IS_PYPY and PY38 and not PYPY_7_3_11_PLUS: - # Not perfect, but best we can do for Python 3.7 and PyPy 3.8 (< v7.3.11). + if IS_PYPY and PY38 and not PYPY_7_3_11_PLUS: + # Not perfect, but best we can do for PyPy 3.8 (< v7.3.11). # Can't detect closing bracket on new line. assert c.fromlineno == 12 else: @@ -923,8 +920,7 @@ def test_module_build_dunder_file() -> None: assert module.path[0] == collections.__file__ -@pytest.mark.skipif( - PY38_PLUS, +@pytest.mark.xfail( reason=( "The builtin ast module does not fail with a specific error " "for syntax error caused by invalid type comments." diff --git a/tests/test_inference.py b/tests/test_inference.py index b81a3e17..cdb61918 100644 --- a/tests/test_inference.py +++ b/tests/test_inference.py @@ -31,7 +31,7 @@ from astroid import decorators as decoratorsmod from astroid.arguments import CallSite from astroid.bases import BoundMethod, Instance, UnboundMethod, UnionType from astroid.builder import AstroidBuilder, _extract_single_node, extract_node, parse -from astroid.const import PY38_PLUS, PY39_PLUS, PY310_PLUS +from astroid.const import PY39_PLUS, PY310_PLUS from astroid.context import CallContext, InferenceContext from astroid.exceptions import ( AstroidTypeError, @@ -959,8 +959,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase): self.assertEqual("module.C", should_be_c[0].qname()) self.assertEqual("module.D", should_be_d[0].qname()) - @pytest.mark.skipif( - PY38_PLUS, + @pytest.mark.xfail( reason="pathlib.Path cannot be inferred on Python 3.8", ) def test_factory_methods_inside_binary_operation(self): @@ -6588,7 +6587,6 @@ def test_custom_decorators_for_classmethod_and_staticmethods(code, obj, obj_type assert inferred.type == obj_type -@pytest.mark.skipif(not PY38_PLUS, reason="Needs dataclasses available") @pytest.mark.skipif( PY39_PLUS, reason="Exact inference with dataclasses (replace function) in python3.9", diff --git a/tests/test_nodes.py b/tests/test_nodes.py index 9d5f3ba0..1d8d67a0 100644 --- a/tests/test_nodes.py +++ b/tests/test_nodes.py @@ -26,7 +26,7 @@ from astroid import ( transforms, util, ) -from astroid.const import PY38_PLUS, PY310_PLUS, Context +from astroid.const import PY310_PLUS, Context from astroid.context import InferenceContext from astroid.exceptions import ( AstroidBuildingError, @@ -48,13 +48,6 @@ from astroid.nodes.scoped_nodes import ClassDef, FunctionDef, GeneratorExp, Modu from . import resources abuilder = builder.AstroidBuilder() -try: - import typed_ast # pylint: disable=unused-import - - HAS_TYPED_AST = True -except ImportError: - # typed_ast merged in `ast` in Python 3.8 - HAS_TYPED_AST = PY38_PLUS class AsStringTest(resources.SysPathSetup, unittest.TestCase): @@ -641,9 +634,6 @@ class ConstNodeTest(unittest.TestCase): def test_unicode(self) -> None: self._test("a") - @pytest.mark.skipif( - not PY38_PLUS, reason="kind attribute for ast.Constant was added in 3.8" - ) def test_str_kind(self): node = builder.extract_node( """ @@ -673,7 +663,6 @@ class NameNodeTest(unittest.TestCase): builder.parse(code) -@pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") class TestNamedExprNode: """Tests for the NamedExpr node.""" @@ -1237,7 +1226,6 @@ def test_unknown() -> None: assert isinstance(nodes.Unknown().qname(), str) -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_type_comments_with() -> None: module = builder.parse( """ @@ -1254,7 +1242,6 @@ def test_type_comments_with() -> None: assert ignored_node.type_annotation is None -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_type_comments_for() -> None: module = builder.parse( """ @@ -1272,7 +1259,6 @@ def test_type_comments_for() -> None: assert ignored_node.type_annotation is None -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_type_coments_assign() -> None: module = builder.parse( """ @@ -1288,7 +1274,6 @@ def test_type_coments_assign() -> None: assert ignored_node.type_annotation is None -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_type_comments_invalid_expression() -> None: module = builder.parse( """ @@ -1301,7 +1286,6 @@ def test_type_comments_invalid_expression() -> None: assert node.type_annotation is None -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_type_comments_invalid_function_comments() -> None: module = builder.parse( """ @@ -1321,7 +1305,6 @@ def test_type_comments_invalid_function_comments() -> None: assert node.type_comment_args is None -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_type_comments_function() -> None: module = builder.parse( """ @@ -1352,7 +1335,6 @@ def test_type_comments_function() -> None: assert node.type_comment_returns.as_string() == expected_returns_string -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_type_comments_arguments() -> None: module = builder.parse( """ @@ -1392,9 +1374,6 @@ def test_type_comments_arguments() -> None: assert actual_arg.as_string() == expected_arg -@pytest.mark.skipif( - not PY38_PLUS, reason="needs to be able to parse positional only arguments" -) def test_type_comments_posonly_arguments() -> None: module = builder.parse( """ @@ -1430,7 +1409,6 @@ def test_type_comments_posonly_arguments() -> None: assert actual_arg.as_string() == expected_arg -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_correct_function_type_comment_parent() -> None: data = """ def f(a): @@ -1512,7 +1490,6 @@ def test_f_string_correct_line_numbering() -> None: assert node.last_child().last_child().lineno == 5 -@pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_assignment_expression() -> None: code = """ if __(a := 1): @@ -1535,7 +1512,6 @@ def test_assignment_expression() -> None: assert second.as_string() == "b := test" -@pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_assignment_expression_in_functiondef() -> None: code = """ def function(param = (assignment := "walrus")): @@ -1650,7 +1626,6 @@ def test_parse_fstring_debug_mode() -> None: assert node.as_string() == "f'3={3!r}'" -@pytest.mark.skipif(not HAS_TYPED_AST, reason="requires typed_ast") def test_parse_type_comments_with_proper_parent() -> None: code = """ class D: #@ diff --git a/tests/test_nodes_lineno.py b/tests/test_nodes_lineno.py index bbc1a300..126655df 100644 --- a/tests/test_nodes_lineno.py +++ b/tests/test_nodes_lineno.py @@ -8,11 +8,11 @@ import pytest import astroid from astroid import builder, nodes -from astroid.const import IS_PYPY, PY38, PY38_PLUS, PY39_PLUS, PY310_PLUS +from astroid.const import IS_PYPY, PY38, PY39_PLUS, PY310_PLUS @pytest.mark.skipif( - PY38_PLUS and not (PY38 and IS_PYPY), + not (PY38 and IS_PYPY), reason="end_lineno and end_col_offset were added in PY38", ) class TestEndLinenoNotSet: @@ -43,7 +43,7 @@ class TestEndLinenoNotSet: @pytest.mark.skipif( - not PY38_PLUS or PY38 and IS_PYPY, + PY38 and IS_PYPY, reason="end_lineno and end_col_offset were added in PY38", ) class TestLinenoColOffset: diff --git a/tests/test_protocols.py b/tests/test_protocols.py index 4841ae7b..d24659ba 100644 --- a/tests/test_protocols.py +++ b/tests/test_protocols.py @@ -13,7 +13,7 @@ import pytest import astroid from astroid import extract_node, nodes -from astroid.const import PY38_PLUS, PY310_PLUS +from astroid.const import PY310_PLUS from astroid.exceptions import InferenceError from astroid.manager import AstroidManager from astroid.util import Uninferable, UninferableBase @@ -280,7 +280,6 @@ class ProtocolTests(unittest.TestCase): assert parsed.inferred() == [Uninferable] -@pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_named_expr_inference() -> None: code = """ if (a := 2) == 2: diff --git a/tests/test_regrtest.py b/tests/test_regrtest.py index 88c4aab9..31d9e6b8 100644 --- a/tests/test_regrtest.py +++ b/tests/test_regrtest.py @@ -11,7 +11,6 @@ import pytest from astroid import MANAGER, Instance, bases, nodes, parse, test_utils from astroid.builder import AstroidBuilder, _extract_single_node, extract_node -from astroid.const import PY38_PLUS from astroid.context import InferenceContext from astroid.exceptions import InferenceError from astroid.raw_building import build_module @@ -163,7 +162,6 @@ def test(): base = next(result._proxied.bases[0].infer()) self.assertEqual(base.name, "int") - @pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_filter_stmts_nested_if(self) -> None: builder = AstroidBuilder() data = """ diff --git a/tests/test_scoped_nodes.py b/tests/test_scoped_nodes.py index 60fd68f7..9f409582 100644 --- a/tests/test_scoped_nodes.py +++ b/tests/test_scoped_nodes.py @@ -30,7 +30,7 @@ from astroid import ( util, ) from astroid.bases import BoundMethod, Generator, Instance, UnboundMethod -from astroid.const import IS_PYPY, PY38, PY38_PLUS +from astroid.const import IS_PYPY, PY38 from astroid.exceptions import ( AttributeInferenceError, DuplicateBasesError, @@ -530,7 +530,6 @@ class FunctionNodeTest(ModuleLoader, unittest.TestCase): astroid["f"].argnames(), ["a", "b", "args", "c", "d", "kwargs"] ) - @unittest.skipUnless(PY38_PLUS, "positional-only argument syntax") def test_positional_only_argnames(self) -> None: code = "def f(a, b, /, c=None, *args, d, **kwargs): pass" astroid = builder.parse(code, __name__) @@ -1333,7 +1332,7 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase): astroid = builder.parse(data) self.assertEqual(astroid["g1"].fromlineno, 4) self.assertEqual(astroid["g1"].tolineno, 5) - if not PY38_PLUS or PY38 and IS_PYPY: + if PY38 and IS_PYPY: self.assertEqual(astroid["g2"].fromlineno, 9) else: self.assertEqual(astroid["g2"].fromlineno, 10) @@ -1943,7 +1942,7 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase): cls.mro() def test_mro_typing_extensions(self): - """Regression test for mro() inference on typing_extesnions. + """Regression test for mro() inference on typing_extensions. Regression reported in: https://github.com/pylint-dev/astroid/issues/1124 @@ -1973,9 +1972,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase): "Protocol", "object", ] - if not PY38_PLUS: - class_names.pop(-2) - final_def = module.body[-1] self.assertEqual(class_names, sorted(i.name for i in final_def.mro())) @@ -2799,7 +2795,6 @@ def test_slots_duplicate_bases_issue_1089() -> None: class TestFrameNodes: @staticmethod - @pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_frame_node(): """Test if the frame of FunctionDef, ClassDef and Module is correctly set.""" module = builder.parse( diff --git a/tests/test_utils.py b/tests/test_utils.py index a0f2137a..c06ee58e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -4,10 +4,7 @@ import unittest -import pytest - from astroid import Uninferable, builder, extract_node, nodes -from astroid.const import PY38_PLUS from astroid.exceptions import InferenceError @@ -33,7 +30,6 @@ class InferenceUtil(unittest.TestCase): self.assertEqual(nodes.are_exclusive(xass1, xnames[1]), False) self.assertEqual(nodes.are_exclusive(xass1, xnames[2]), False) - @pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_not_exclusive_walrus_operator(self) -> None: node_if, node_body, node_or_else = extract_node( """ @@ -54,7 +50,6 @@ class InferenceUtil(unittest.TestCase): assert nodes.are_exclusive(node_if, node_or_else) is False assert nodes.are_exclusive(node_body, node_or_else) is True - @pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_not_exclusive_walrus_multiple(self) -> None: node_if, body_1, body_2, or_else_1, or_else_2 = extract_node( """ @@ -84,7 +79,6 @@ class InferenceUtil(unittest.TestCase): assert nodes.are_exclusive(walruses[1], or_else_1) is False assert nodes.are_exclusive(walruses[1], or_else_2) is False - @pytest.mark.skipif(not PY38_PLUS, reason="needs assignment expressions") def test_not_exclusive_walrus_operator_nested(self) -> None: node_if, node_body, node_or_else = extract_node( """ |