Skip to content

Commit

Permalink
Update tests and testoptions for PyPy
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed May 2, 2022
1 parent 324ae1d commit d44346a
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions pylint/testutils/checker_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from astroid import nodes

from pylint.constants import PY38_PLUS
from pylint.constants import IS_PYPY, PY38_PLUS, PY39_PLUS
from pylint.testutils.global_test_linter import linter
from pylint.testutils.output_line import MessageTest
from pylint.testutils.unittest_linter import UnittestLinter
Expand Down Expand Up @@ -77,7 +77,7 @@ def assertAddsMessages(

assert expected_msg.line == gotten_msg.line, msg
assert expected_msg.col_offset == gotten_msg.col_offset, msg
if PY38_PLUS:
if PY38_PLUS and not IS_PYPY or PY39_PLUS:
# TODO: 3.0: Remove deprecated missing arguments and remove the warning
if not expected_msg.end_line == gotten_msg.end_line:
warnings.warn( # pragma: no cover
Expand Down
4 changes: 4 additions & 0 deletions pylint/testutils/lint_module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from pylint import checkers
from pylint.config.config_initialization import _config_initialization
from pylint.constants import IS_PYPY
from pylint.lint import PyLinter
from pylint.message.message import Message
from pylint.testutils.constants import _EXPECTED_RE, _OPERATORS, UPDATE_OPTION
Expand Down Expand Up @@ -60,6 +61,9 @@ def __init__(
self._check_end_position = (
sys.version_info >= self._test_file.options["min_pyver_end_position"]
)
# TODO: PY3.9: PyPy supports end_lineno from 3.9 and above
if self._check_end_position and IS_PYPY:
self._check_end_position = sys.version_info >= (3, 9) # pragma: no cover
try:
args = [test_file.source]
except NoFileError:
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/b/bad_open_mode.rc

This file was deleted.

6 changes: 2 additions & 4 deletions tests/functional/c/consider/consider_using_with_open.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# pylint: disable=missing-function-docstring, missing-module-docstring, invalid-name, import-outside-toplevel, no-self-use
# pylint: disable=missing-class-docstring, too-few-public-methods, unused-variable, multiple-statements, line-too-long
"""
The functional test for the standard ``open()`` function has to be moved in a separate file,
because PyPy has to be excluded for the tests as the ``open()`` function is uninferable in PyPy.
However, all remaining checks for consider-using-with work in PyPy, so we do not want to exclude
PyPy from ALL functional tests.
Previously, open was uninferable on PyPy so we moved all functional tests
to a separate file. This is no longer the case but the files remain split.
"""
from contextlib import contextmanager
from pathlib import Path
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/c/consider/consider_using_with_open.rc

This file was deleted.

14 changes: 7 additions & 7 deletions tests/functional/c/consider/consider_using_with_open.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
consider-using-with:12:9:12:43::Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:16:9:16:43:test_open:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:46:4:46:33:test_open_outside_assignment:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:47:14:47:43:test_open_outside_assignment:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:52:8:52:37:test_open_inside_with_block:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:120:26:122:13:TestControlFlow.test_triggers_if_reassigned_after_if_else:Consider using 'with' for resource-allocating operations:UNDEFINED
used-before-assignment:141:12:141:23:TestControlFlow.test_defined_in_try_and_finally:Using variable 'file_handle' before assignment:CONTROL_FLOW
consider-using-with:10:9:10:43::Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:14:9:14:43:test_open:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:44:4:44:33:test_open_outside_assignment:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:45:14:45:43:test_open_outside_assignment:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:50:8:50:37:test_open_inside_with_block:Consider using 'with' for resource-allocating operations:UNDEFINED
consider-using-with:118:26:120:13:TestControlFlow.test_triggers_if_reassigned_after_if_else:Consider using 'with' for resource-allocating operations:UNDEFINED
used-before-assignment:139:12:139:23:TestControlFlow.test_defined_in_try_and_finally:Using variable 'file_handle' before assignment:CONTROL_FLOW
1 change: 1 addition & 0 deletions tests/functional/i/import_error.rc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ enable=multiple-imports
ignored-modules=external_module,fake_module.submodule,foo,bar

[testoptions]
# TODO: PY3.9: This does pass on PyPy 3.9
except_implementations=PyPy
3 changes: 0 additions & 3 deletions tests/functional/r/regression_02/regression_5479.rc

This file was deleted.

2 changes: 0 additions & 2 deletions tests/functional/s/sys_stream_regression_1004.rc

This file was deleted.

4 changes: 3 additions & 1 deletion tests/functional/u/undefined/undefined_variable_typing.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[testoptions]
except_implementations=PyPy
# This was added as PyPy is only able to run this on 3.8 and above
min_pyver=3.8

[VARIABLES]
additional-builtins=__additional_builtin__
3 changes: 2 additions & 1 deletion tests/functional/u/unused/unused_typing_imports.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[testoptions]
except_implementations=PyPy
# This was added as PyPy is only able to run this on 3.8 and above
min_pyver=3.8

0 comments on commit d44346a

Please sign in to comment.