summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-01-19 19:00:26 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-01-19 19:00:26 -0500
commit644ac5a7deb3933224a5ff6863e5b3d98362c2a8 (patch)
tree8460a97e584ed57c1926ce73dcc390984e1c6429
parentdb7825a33067e5c0873250488ba0543968765abb (diff)
downloadpython-coveragepy-git-644ac5a7deb3933224a5ff6863e5b3d98362c2a8.tar.gz
refactor(test): use xfail for tests that fail on specific versions of Python
-rw-r--r--tests/test_arcs.py32
-rw-r--r--tests/test_coverage.py2
-rw-r--r--tests/test_execfile.py4
-rw-r--r--tests/test_phystokens.py2
-rw-r--r--tests/test_process.py2
-rw-r--r--tests/test_venv.py2
6 files changed, 19 insertions, 25 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 39187598..483c0bc3 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -273,7 +273,7 @@ class WithTest(CoverageTest):
arcz=arcz,
)
- @pytest.mark.skipif(
+ @pytest.mark.xfail(
(3, 11) <= env.PYVERSION <= (3, 11, 0, 'alpha', 2, 0),
reason="avoid a 3.11 bug: 45709"
)
@@ -572,7 +572,7 @@ class LoopArcTest(CoverageTest):
)
# https://bugs.python.org/issue44672
- @pytest.mark.skipif(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
+ @pytest.mark.xfail(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
def test_incorrect_loop_exit_bug_1175(self):
self.check_coverage("""\
def wrong_loop(x):
@@ -589,7 +589,7 @@ class LoopArcTest(CoverageTest):
)
# https://bugs.python.org/issue44672
- @pytest.mark.skipif(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
+ @pytest.mark.xfail(env.PYVERSION < (3, 10), reason="<3.10 traced final pass incorrectly")
def test_incorrect_if_bug_1175(self):
self.check_coverage("""\
def wrong_loop(x):
@@ -1196,7 +1196,7 @@ class YieldTest(CoverageTest):
)
# https://bugs.python.org/issue46225
- @pytest.mark.skipif(
+ @pytest.mark.xfail(
env.PYVERSION[:5] == (3, 11, 0, 'alpha', 3),
reason="avoid 3.11 bug: bpo46225",
)
@@ -1234,8 +1234,8 @@ class YieldTest(CoverageTest):
arcz=".1 14 45 54 4. .2 2. -22 2-2",
)
- @pytest.mark.skipif(
- (3, 11, 0, "alpha", 4) <= env.PYVERSION,
+ @pytest.mark.xfail(
+ ((3, 11, 0, "alpha", 4) <= env.PYVERSION) and not env.C_TRACER,
reason="avoid a 3.11 bug: https://bugs.python.org/issue46389",
)
def test_bug_324(self):
@@ -1307,7 +1307,7 @@ class YieldTest(CoverageTest):
)
-@pytest.mark.skipif(env.PYVERSION <= (3, 10, 0, 'beta', 4, 0), reason="3.10.0b4 had bugs")
+@pytest.mark.xfail(env.PYVERSION <= (3, 10, 0, 'beta', 4, 0), reason="3.10.0b4 had bugs")
@pytest.mark.skipif(not env.PYBEHAVIOR.match_case, reason="Match-case is new in 3.10")
class MatchCaseTest(CoverageTest):
"""Tests of match-case."""
@@ -1623,8 +1623,8 @@ class MiscArcTest(CoverageTest):
self.check_coverage(code, arcs=[(-1, 1), (1, 2*n+4), (2*n+4, -1)])
assert self.stdout() == f"{n}\n"
- @pytest.mark.skipif(
- (3, 11, 0, "alpha", 4) <= env.PYVERSION,
+ @pytest.mark.xfail(
+ ((3, 11, 0, "alpha", 4) <= env.PYVERSION) and not env.C_TRACER,
reason="avoid a 3.11 bug: https://bugs.python.org/issue46389",
)
def test_partial_generators(self):
@@ -1831,7 +1831,7 @@ class LambdaArcTest(CoverageTest):
)
-skip_eventlet_670 = pytest.mark.skipif(
+xfail_eventlet_670 = pytest.mark.xfail(
env.PYVERSION[:2] == (3, 9) and env.OSX,
reason="Avoid an eventlet bug on Mac 3.9: eventlet#670",
# https://github.com/eventlet/eventlet/issues/670
@@ -1841,7 +1841,7 @@ skip_eventlet_670 = pytest.mark.skipif(
class AsyncTest(CoverageTest):
"""Tests of the new async and await keywords in Python 3.5"""
- @skip_eventlet_670
+ @xfail_eventlet_670
def test_async(self):
self.check_coverage("""\
import asyncio
@@ -1868,7 +1868,7 @@ class AsyncTest(CoverageTest):
)
assert self.stdout() == "Compute 1 + 2 ...\n1 + 2 = 3\n"
- @skip_eventlet_670
+ @xfail_eventlet_670
def test_async_for(self):
self.check_coverage("""\
import asyncio
@@ -1942,7 +1942,7 @@ class AsyncTest(CoverageTest):
# https://github.com/nedbat/coveragepy/issues/1158
# https://bugs.python.org/issue44621
- @pytest.mark.skipif(env.PYVERSION[:2] == (3, 9), reason="avoid a 3.9 bug: 44621")
+ @pytest.mark.xfail(env.PYVERSION[:2] == (3, 9), reason="avoid a 3.9 bug: 44621")
@pytest.mark.skipif(env.PYVERSION < (3, 7), reason="need asyncio.run")
def test_bug_1158(self):
self.check_coverage("""\
@@ -1968,11 +1968,11 @@ class AsyncTest(CoverageTest):
# https://github.com/nedbat/coveragepy/issues/1176
# https://bugs.python.org/issue44622
- @pytest.mark.skipif(
+ @pytest.mark.xfail(
(3, 10, 0, "alpha", 0, 0) <= env.PYVERSION <= (3, 10, 0, "beta", 4, 0),
reason="avoid a 3.10 bug fixed after beta 4: 44622"
)
- @skip_eventlet_670
+ @xfail_eventlet_670
@pytest.mark.skipif(env.PYVERSION < (3, 7), reason="need asyncio.run")
def test_bug_1176(self):
self.check_coverage("""\
@@ -1993,7 +1993,7 @@ class AsyncTest(CoverageTest):
# https://github.com/nedbat/coveragepy/issues/1205
# https://bugs.python.org/issue44840
- @pytest.mark.skipif(
+ @pytest.mark.xfail(
(3, 10, 0, "alpha", 0, 0) <= env.PYVERSION <= (3, 10, 0, "candidate", 1, 0),
reason="avoid a 3.10 bug fixed after rc1: 44840"
)
diff --git a/tests/test_coverage.py b/tests/test_coverage.py
index 3f111367..fc4263de 100644
--- a/tests/test_coverage.py
+++ b/tests/test_coverage.py
@@ -1213,7 +1213,7 @@ class CompoundStatementTest(CoverageTest):
""",
[1,10,12,13], "")
- @pytest.mark.skipif(
+ @pytest.mark.xfail(
(3, 11, 0, "alpha", 3, 0) <= env.PYVERSION < (3, 11, 0, "alpha", 4, 0),
reason="avoid class docstring bug: bpo 46331",
# https://bugs.python.org/issue46331
diff --git a/tests/test_execfile.py b/tests/test_execfile.py
index 6d316700..83db5273 100644
--- a/tests/test_execfile.py
+++ b/tests/test_execfile.py
@@ -149,9 +149,6 @@ class RunFileTest(CoverageTest):
assert self.stdout() == "about to exit..\n"
assert self.stderr() == ""
- @pytest.mark.skipif(not env.CPYTHON,
- reason="non-CPython handles excepthook exits differently, punt for now."
- )
def test_excepthook_exit(self):
self.make_file("excepthook_exit.py", """\
import sys
@@ -169,7 +166,6 @@ class RunFileTest(CoverageTest):
cov_out = self.stdout()
assert cov_out == "in excepthook\n"
- @pytest.mark.skipif(env.PYPY, reason="PyPy handles excepthook throws differently.")
def test_excepthook_throw(self):
self.make_file("excepthook_throw.py", """\
import sys
diff --git a/tests/test_phystokens.py b/tests/test_phystokens.py
index 91a9d3d9..8a8b8506 100644
--- a/tests/test_phystokens.py
+++ b/tests/test_phystokens.py
@@ -173,8 +173,6 @@ class SourceEncodingTest(CoverageTest):
for _, source, expected in ENCODING_DECLARATION_SOURCES:
assert source_encoding(source) == expected, f"Wrong encoding in {source!r}"
- # PyPy3 gets this case wrong. Not sure what I can do about it, so skip the test.
- @pytest.mark.skipif(env.PYPY, reason="PyPy3 is wrong about non-comment encoding. Skip it.")
def test_detect_source_encoding_not_in_comment(self):
# Should not detect anything here
source = b'def parse(src, encoding=None):\n pass'
diff --git a/tests/test_process.py b/tests/test_process.py
index f13fe014..7558671b 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -552,7 +552,7 @@ class ProcessTest(CoverageTest):
@pytest.mark.expensive
@pytest.mark.skipif(not env.C_TRACER, reason="fullcoverage only works with the C tracer.")
@pytest.mark.skipif(env.METACOV, reason="Can't test fullcoverage when measuring ourselves")
- @pytest.mark.skipif(
+ @pytest.mark.xfail(
(3, 11, 0, "alpha", 4) <= env.PYVERSION,
reason="avoid 3.11 bug lineno==None: https://bugs.python.org/issue46389",
)
diff --git a/tests/test_venv.py b/tests/test_venv.py
index e4457315..050d467c 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -160,7 +160,7 @@ def coverage_command_fixture(request):
# https://bugs.python.org/issue46028
-@pytest.mark.skipif((3, 11, 0, 'alpha', 3) <= env.PYVERSION[:5], reason="avoid 3.11 bug: bpo46028")
+@pytest.mark.xfail((3, 11, 0, 'alpha', 3) <= env.PYVERSION[:5], reason="avoid 3.11 bug: bpo46028")
class VirtualenvTest(CoverageTest):
"""Tests of virtualenv considerations."""