diff options
| author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2022-03-09 15:24:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-09 15:24:35 +0100 |
| commit | b0c0c450dc21bc9d901f811ce1b4e39e13a387b5 (patch) | |
| tree | 7c5ae48f35f432cadd9eeb64b67b4f66becd0735 /tests | |
| parent | 128e50f357e73c166a7b4eee40d0d8cf6eb5780f (diff) | |
| download | astroid-git-b0c0c450dc21bc9d901f811ce1b4e39e13a387b5.tar.gz | |
Replace platform import (#1459)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unittest_builder.py | 6 | ||||
| -rw-r--r-- | tests/unittest_inference.py | 5 | ||||
| -rw-r--r-- | tests/unittest_manager.py | 4 | ||||
| -rw-r--r-- | tests/unittest_nodes.py | 7 | ||||
| -rw-r--r-- | tests/unittest_nodes_lineno.py | 6 | ||||
| -rw-r--r-- | tests/unittest_raw_building.py | 4 | ||||
| -rw-r--r-- | tests/unittest_scoped_nodes.py | 4 |
7 files changed, 14 insertions, 22 deletions
diff --git a/tests/unittest_builder.py b/tests/unittest_builder.py index c47c944f..1b872eac 100644 --- a/tests/unittest_builder.py +++ b/tests/unittest_builder.py @@ -43,7 +43,7 @@ import unittest.mock import pytest from astroid import Instance, builder, nodes, test_utils, util -from astroid.const import IMPLEMENTATION_PYPY, PY38, PY38_PLUS, PY39_PLUS +from astroid.const import IS_PYPY, PY38, PY38_PLUS, PY39_PLUS from astroid.exceptions import ( AstroidBuildingError, AstroidSyntaxError, @@ -79,7 +79,7 @@ class FromToLineNoTest(unittest.TestCase): self.assertEqual(name.tolineno, 4) strarg = callfunc.args[0] self.assertIsInstance(strarg, nodes.Const) - if IMPLEMENTATION_PYPY: + if IS_PYPY: self.assertEqual(strarg.fromlineno, 4) if not PY39_PLUS: self.assertEqual(strarg.tolineno, 4) @@ -187,7 +187,7 @@ class FromToLineNoTest(unittest.TestCase): c = ast_module.body[2] assert isinstance(c, nodes.ClassDef) - if not PY38_PLUS or PY38 and IMPLEMENTATION_PYPY: + if not PY38_PLUS or PY38 and IS_PYPY: # Not perfect, but best we can do for Python 3.7 and PyPy 3.8 # Can't detect closing bracket on new line. assert c.fromlineno == 12 diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py index 477debef..9505c034 100644 --- a/tests/unittest_inference.py +++ b/tests/unittest_inference.py @@ -44,7 +44,6 @@ """Tests for the astroid inference capabilities""" -import platform import textwrap import unittest from abc import ABCMeta @@ -61,7 +60,7 @@ from astroid import helpers, nodes, objects, test_utils, util from astroid.arguments import CallSite from astroid.bases import BoundMethod, Instance, UnboundMethod from astroid.builder import AstroidBuilder, extract_node, parse -from astroid.const import PY38_PLUS, PY39_PLUS +from astroid.const import IS_PYPY, PY38_PLUS, PY39_PLUS from astroid.context import InferenceContext from astroid.exceptions import ( AstroidTypeError, @@ -858,7 +857,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase): self.assertIsInstance(inferred[0], nodes.FunctionDef) self.assertEqual(inferred[0].name, "open") - if platform.python_implementation() == "PyPy": + if IS_PYPY: test_builtin_open = unittest.expectedFailure(test_builtin_open) def test_callfunc_context_func(self) -> None: diff --git a/tests/unittest_manager.py b/tests/unittest_manager.py index 78680730..e0233b2f 100644 --- a/tests/unittest_manager.py +++ b/tests/unittest_manager.py @@ -24,7 +24,6 @@ # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE import os -import platform import site import sys import time @@ -36,13 +35,14 @@ import pkg_resources import astroid from astroid import manager, test_utils +from astroid.const import IS_JYTHON from astroid.exceptions import AstroidBuildingError, AstroidImportError from . import resources def _get_file_from_object(obj) -> str: - if platform.python_implementation() == "Jython": + if IS_JYTHON: return obj.__file__.split("$py.class")[0] + ".py" return obj.__file__ diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index 36fe963f..489a4b41 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -33,7 +33,6 @@ """ import copy import os -import platform import sys import textwrap import unittest @@ -290,12 +289,6 @@ def func(param: Tuple): ast = abuilder.string_build(code) self.assertEqual(ast.as_string().strip(), code.strip()) - # This test is disabled on PyPy because we cannot get a release that has proper - # support for f-strings (we need 7.2 at least) - @pytest.mark.skipif( - platform.python_implementation() == "PyPy", - reason="Needs f-string support.", - ) def test_f_strings(self): code = r''' a = f"{'a'}" diff --git a/tests/unittest_nodes_lineno.py b/tests/unittest_nodes_lineno.py index f38208af..55b4f513 100644 --- a/tests/unittest_nodes_lineno.py +++ b/tests/unittest_nodes_lineno.py @@ -4,11 +4,11 @@ import pytest import astroid from astroid import builder, nodes -from astroid.const import IMPLEMENTATION_PYPY, PY38, PY38_PLUS, PY39_PLUS, PY310_PLUS +from astroid.const import IS_PYPY, PY38, PY38_PLUS, PY39_PLUS, PY310_PLUS @pytest.mark.skipif( - PY38_PLUS and not (PY38 and IMPLEMENTATION_PYPY), + PY38_PLUS and not (PY38 and IS_PYPY), reason="end_lineno and end_col_offset were added in PY38", ) class TestEndLinenoNotSet: @@ -37,7 +37,7 @@ class TestEndLinenoNotSet: @pytest.mark.skipif( - not PY38_PLUS or PY38 and IMPLEMENTATION_PYPY, + not PY38_PLUS or PY38 and IS_PYPY, reason="end_lineno and end_col_offset were added in PY38", ) class TestLinenoColOffset: diff --git a/tests/unittest_raw_building.py b/tests/unittest_raw_building.py index 3a5fbf85..e549e917 100644 --- a/tests/unittest_raw_building.py +++ b/tests/unittest_raw_building.py @@ -13,13 +13,13 @@ # 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 -import platform import unittest import _io import pytest from astroid.builder import AstroidBuilder +from astroid.const import IS_PYPY from astroid.raw_building import ( attach_dummy_node, build_class, @@ -85,7 +85,7 @@ class RawBuildingTC(unittest.TestCase): node = build_from_import("astroid", names) self.assertEqual(len(names), len(node.names)) - @unittest.skipIf(platform.python_implementation() == "PyPy", "Only affects CPython") + @unittest.skipIf(IS_PYPY, "Only affects CPython") def test_io_is__io(self): # _io module calls itself io. This leads # to cyclic dependencies when astroid tries to resolve diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py index a20996eb..26fd8be8 100644 --- a/tests/unittest_scoped_nodes.py +++ b/tests/unittest_scoped_nodes.py @@ -58,7 +58,7 @@ from astroid import ( util, ) from astroid.bases import BoundMethod, Generator, Instance, UnboundMethod -from astroid.const import IMPLEMENTATION_PYPY, PY38, PY38_PLUS, PY310_PLUS, WIN32 +from astroid.const import IS_PYPY, PY38, PY38_PLUS, PY310_PLUS, WIN32 from astroid.exceptions import ( AttributeInferenceError, DuplicateBasesError, @@ -1291,7 +1291,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 IMPLEMENTATION_PYPY: + if not PY38_PLUS or PY38 and IS_PYPY: self.assertEqual(astroid["g2"].fromlineno, 9) else: self.assertEqual(astroid["g2"].fromlineno, 10) |
