diff options
| author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2022-12-21 23:34:46 +0100 |
|---|---|---|
| committer | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-12-27 00:32:09 +0100 |
| commit | c7fea7662075b4855547ea1e191037ab1b5a2e06 (patch) | |
| tree | 4617474b6f6f83c6504b5946929beff1abb48396 | |
| parent | 0769ced2aee2a1775473d6e7f252fdb7f5c28fe2 (diff) | |
| download | astroid-git-c7fea7662075b4855547ea1e191037ab1b5a2e06.tar.gz | |
[pypy 3.8] Fix wrong line given by the ast for pypy 3.8
(cherry picked from commit 3a4242244d16f228c0641f96e2f3ba247a08ab47)
| -rw-r--r-- | tests/unittest_builder.py | 14 | ||||
| -rw-r--r-- | tests/unittest_nodes_position.py | 9 |
2 files changed, 17 insertions, 6 deletions
diff --git a/tests/unittest_builder.py b/tests/unittest_builder.py index cc1cb28b..77195de1 100644 --- a/tests/unittest_builder.py +++ b/tests/unittest_builder.py @@ -155,15 +155,23 @@ class FromToLineNoTest(unittest.TestCase): b = ast_module.body[1] assert isinstance(b, nodes.ClassDef) - assert b.fromlineno == 6 + if PY38 and IS_PYPY: + # Not perfect, but best we can do for PyPy 3.8 + assert b.fromlineno == 7 + else: + assert b.fromlineno == 6 assert b.tolineno == 7 c = ast_module.body[2] assert isinstance(c, nodes.ClassDef) - if not PY38_PLUS or PY38 and IS_PYPY: - # Not perfect, but best we can do for Python 3.7 and PyPy 3.8 + if not PY38_PLUS: + # Not perfect, but best we can do for Python 3.7 # Can't detect closing bracket on new line. assert c.fromlineno == 12 + elif PY38 and IS_PYPY: + # Not perfect, but best we can do for PyPy 3.8 + # Can't detect closing bracket on new line. + assert c.fromlineno == 16 else: assert c.fromlineno == 13 assert c.tolineno == 14 diff --git a/tests/unittest_nodes_position.py b/tests/unittest_nodes_position.py index 9a637657..d49fe9fa 100644 --- a/tests/unittest_nodes_position.py +++ b/tests/unittest_nodes_position.py @@ -7,6 +7,7 @@ from __future__ import annotations import textwrap from astroid import builder, nodes +from astroid.const import IS_PYPY, PY38 class TestNodePosition: @@ -64,9 +65,11 @@ class TestNodePosition: assert isinstance(e, nodes.ClassDef) assert e.position == (13, 0, 13, 7) - f = ast_nodes[5] - assert isinstance(f, nodes.ClassDef) - assert f.position == (18, 0, 18, 7) + if not PY38 or not IS_PYPY: + # The new (2022-12) version of pypy 3.8 broke this + f = ast_nodes[5] + assert isinstance(f, nodes.ClassDef) + assert f.position == (18, 0, 18, 7) @staticmethod def test_position_function() -> None: |
