Skip to content

Commit

Permalink
tests: split xfail_pypy38 decorator into _older_ and _all_ variants
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
zackw committed Oct 2, 2024
1 parent f90ef28 commit e6a79ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
8 changes: 7 additions & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_arcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
16 changes: 8 additions & 8 deletions tests/test_lcov.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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", """\
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e6a79ae

Please sign in to comment.