From e6a79ae5f832d809ff6584bde3d9bae3b869ac0a Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Wed, 2 Oct 2024 11:35:47 -0400 Subject: [PATCH] tests: split xfail_pypy38 decorator into _older_ and _all_ variants The lcov output tests that are affected by bugs in PyPy 3.8, fail with the current version of PyPy 3.8 (7.3.11), unlike the other tests annotated with @xfail_pypy38. Split this decorator into two variants, xfail_older_pypy38 (used for all the tests that were labeled xfail_py38 prior to this patchset) and xfail_all_pypy38 (used for the lcov output tests). --- tests/helpers.py | 8 +++++++- tests/test_arcs.py | 4 ++-- tests/test_lcov.py | 16 ++++++++-------- tests/test_parser.py | 6 +++--- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index 823bbfd41..6312c7dfa 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -326,7 +326,13 @@ def swallow_warnings( yield -xfail_pypy38 = pytest.mark.xfail( +xfail_all_pypy38 = pytest.mark.xfail( + env.PYPY and env.PYVERSION[:2] == (3, 8), + reason="These tests fail on all versions of PyPy 3.8", +) + + +xfail_older_pypy38 = pytest.mark.xfail( env.PYPY and env.PYVERSION[:2] == (3, 8) and env.PYPYVERSION < (7, 3, 11), reason="These tests fail on older PyPy 3.8", ) diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 516e2acda..10e1e2f01 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -8,7 +8,7 @@ import pytest from tests.coveragetest import CoverageTest -from tests.helpers import assert_count_equal, xfail_pypy38 +from tests.helpers import assert_count_equal, xfail_older_pypy38 import coverage from coverage import env @@ -1695,7 +1695,7 @@ def my_function( branchz="", branchz_missing="", ) - @xfail_pypy38 + @xfail_older_pypy38 def test_class_decorator(self) -> None: self.check_coverage("""\ def decorator(arg): diff --git a/tests/test_lcov.py b/tests/test_lcov.py index b67d22e0c..964b315a7 100644 --- a/tests/test_lcov.py +++ b/tests/test_lcov.py @@ -11,7 +11,7 @@ import coverage from tests.coveragetest import CoverageTest -from tests.helpers import xfail_pypy38 +from tests.helpers import xfail_all_pypy38 class LcovTest(CoverageTest): @@ -160,7 +160,7 @@ def test_simple_line_coverage_two_files(self) -> None: actual_result = self.get_lcov_report_content(filename="data.lcov") assert expected_result == actual_result - @xfail_pypy38 + @xfail_all_pypy38 def test_branch_coverage_one_file(self) -> None: # Test that the reporter produces valid branch coverage. self.make_file("main_file.py", """\ @@ -197,7 +197,7 @@ def is_it_x(x): actual_result = self.get_lcov_report_content() assert expected_result == actual_result - @xfail_pypy38 + @xfail_all_pypy38 def test_branch_coverage_two_files(self) -> None: # Test that valid branch coverage is generated # in the case of two files. @@ -361,7 +361,7 @@ def test_excluded_lines(self) -> None: actual_result = self.get_lcov_report_content() assert expected_result == actual_result - @xfail_pypy38 + @xfail_all_pypy38 def test_exit_branches(self) -> None: self.make_file("runme.py", """\ def foo(a): @@ -399,7 +399,7 @@ def foo(a): actual_result = self.get_lcov_report_content() assert expected_result == actual_result - @xfail_pypy38 + @xfail_all_pypy38 def test_genexpr_exit_arcs_pruned_full_coverage(self) -> None: self.make_file("runme.py", """\ def foo(a): @@ -437,7 +437,7 @@ def foo(a): actual_result = self.get_lcov_report_content() assert expected_result == actual_result - @xfail_pypy38 + @xfail_all_pypy38 def test_genexpr_exit_arcs_pruned_never_true(self) -> None: self.make_file("runme.py", """\ def foo(a): @@ -471,7 +471,7 @@ def foo(a): actual_result = self.get_lcov_report_content() assert expected_result == actual_result - @xfail_pypy38 + @xfail_all_pypy38 def test_genexpr_exit_arcs_pruned_always_true(self) -> None: self.make_file("runme.py", """\ def foo(a): @@ -505,7 +505,7 @@ def foo(a): actual_result = self.get_lcov_report_content() assert expected_result == actual_result - @xfail_pypy38 + @xfail_all_pypy38 def test_genexpr_exit_arcs_pruned_not_reached(self) -> None: self.make_file("runme.py", """\ def foo(a): diff --git a/tests/test_parser.py b/tests/test_parser.py index 8bde8ed65..154a7d2b4 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -14,7 +14,7 @@ from coverage.parser import PythonParser from tests.coveragetest import CoverageTest -from tests.helpers import arcz_to_arcs, xfail_pypy38 +from tests.helpers import arcz_to_arcs, xfail_older_pypy38 class PythonParserTestBase(CoverageTest): @@ -672,7 +672,7 @@ def test_formfeed(self) -> None: ) assert parser.statements == {1, 6} - @xfail_pypy38 + @xfail_older_pypy38 def test_decorator_pragmas(self) -> None: parser = self.parse_text("""\ # 1 @@ -706,7 +706,7 @@ def func(x=25): assert parser.raw_statements == raw_statements assert parser.statements == {8} - @xfail_pypy38 + @xfail_older_pypy38 def test_decorator_pragmas_with_colons(self) -> None: # A colon in a decorator expression would confuse the parser, # ending the exclusion of the decorated function.