From 30a249aac87be4701bfafae2ed3c5a6e964aa3fc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 30 Jul 2022 10:07:06 -0400 Subject: [PATCH] test: xfail some tests that need PyPy to improve #1426 https://foss.heptapod.net/pypy/pypy/-/issues/3792 --- coverage/env.py | 2 +- tests/helpers.py | 7 ++++++- tests/test_process.py | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/coverage/env.py b/coverage/env.py index 2e21b9a7d..13411699a 100644 --- a/coverage/env.py +++ b/coverage/env.py @@ -85,7 +85,7 @@ class PYBEHAVIOR: nix_while_true = (PYVERSION >= (3, 8)) # CPython 3.9a1 made sys.argv[0] and other reported files absolute paths. - report_absolute_files = (CPYTHON and PYVERSION >= (3, 9)) + report_absolute_files = ((CPYTHON or (PYPYVERSION >= (7, 3, 10))) and PYVERSION >= (3, 9)) # Lines after break/continue/return/raise are no longer compiled into the # bytecode. They used to be marked as missing, now they aren't executable. diff --git a/tests/helpers.py b/tests/helpers.py index 32115dc1d..f593c72c6 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -320,5 +320,10 @@ def swallow_warnings(message=r".", category=CoverageWarning): xfail_pypy_3749 = pytest.mark.xfail( env.PYVERSION[:2] == (3, 8) and env.PYPY and env.PYPYVERSION >= (7, 3, 10), - reason="Avoid a PyPy bug: https://foss.heptapod.net/pypy/pypy/-/issues/3749" + reason="Avoid a PyPy bug: https://foss.heptapod.net/pypy/pypy/-/issues/3749", +) + +xfail_pypy_3792 = pytest.mark.xfail( + env.PYBEHAVIOR.report_absolute_files and env.PYPY, + reason="Avoid a PyPy bug: https://foss.heptapod.net/pypy/pypy/-/issues/3792", ) diff --git a/tests/test_process.py b/tests/test_process.py index c473cf9a7..fcbcb9ba7 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -19,7 +19,7 @@ from coverage.files import abs_file, python_reported_file from tests.coveragetest import CoverageTest, TESTS_DIR -from tests.helpers import re_lines_text +from tests.helpers import re_lines_text, xfail_pypy_3792 class ProcessTest(CoverageTest): @@ -283,6 +283,7 @@ def test_running_missing_file(self): assert "rror" not in out assert status == 1 + @xfail_pypy_3792 # Because the file names aren't yet absolute. def test_code_throws(self): self.make_file("throw.py", """\ class MyException(Exception): @@ -302,7 +303,7 @@ def f2(): status, out = self.run_command_status("coverage run throw.py") out2 = self.run_command("python throw.py") if env.PYPY: - # Pypy has an extra frame in the traceback for some reason + # PyPy has an extra frame in the traceback for some reason out2 = re_lines_text("toplevel", out2, match=False) assert out == out2 @@ -695,6 +696,7 @@ def test_coverage_run_dashm_is_like_python_dashm(self): actual = self.run_command("coverage run -m process_test.try_execfile") self.assert_tryexecfile_output(expected, actual) + @xfail_pypy_3792 # Because the sys.path[0] isn't yet absolute. def test_coverage_run_dir_is_like_python_dir(self): with open(TRY_EXECFILE) as f: self.make_file("with_main/__main__.py", f.read())