diff options
-rw-r--r-- | tests/coveragetest.py | 9 | ||||
-rw-r--r-- | tests/test_arcs.py | 23 | ||||
-rw-r--r-- | tests/test_parser.py | 9 | ||||
-rw-r--r-- | tests/test_process.py | 8 |
4 files changed, 24 insertions, 25 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py index f9091a8d..58cfb3dc 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -101,10 +101,6 @@ class CoverageTest( self.last_command_output = None self.last_module_name = None - def xfail(self, msg): - """Mark this test as an expected failure.""" - pytest.xfail(msg) - def clean_local_file_imports(self): """Clean up the results of calls to `import_local_file`. @@ -501,3 +497,8 @@ def command_line(args): script = CoverageScript() ret = script.command_line(shlex.split(args)) return ret + + +def xfail(condition, reason): + """A decorator to mark as test as expected to fail.""" + return pytest.mark.xfail(condition, reason=reason, strict=True) diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 545145a5..e3278303 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -3,7 +3,7 @@ """Tests for coverage.py's arc measurement.""" -from tests.coveragetest import CoverageTest +from tests.coveragetest import CoverageTest, xfail import coverage from coverage import env @@ -629,9 +629,8 @@ class ExceptionArcTest(CoverageTest): ) + @xfail(env.PYBEHAVIOR.bpo39114, reason="https://bugs.python.org/issue39114") def test_break_through_finally(self): - if env.PYBEHAVIOR.bpo39114: - self.xfail("https://bugs.python.org/issue39114") if env.PYBEHAVIOR.finally_jumps_back: arcz = ".1 12 23 34 3D 45 56 67 68 7A 7D 8A A3 A7 BC CD D." else: @@ -655,9 +654,8 @@ class ExceptionArcTest(CoverageTest): arcz_missing="3D BC CD", ) + @xfail(env.PYBEHAVIOR.bpo39114, "https://bugs.python.org/issue39114") def test_continue_through_finally(self): - if env.PYBEHAVIOR.bpo39114: - self.xfail("https://bugs.python.org/issue39114") if env.PYBEHAVIOR.finally_jumps_back: arcz = ".1 12 23 34 3D 45 56 67 68 73 7A 8A A3 A7 BC CD D." else: @@ -694,9 +692,8 @@ class ExceptionArcTest(CoverageTest): arcz=".1 12 23 35 56 61 17 7.", ) + @xfail(env.PYBEHAVIOR.bpo39114, "https://bugs.python.org/issue39114") def test_bug_212(self): - if env.PYBEHAVIOR.bpo39114: - self.xfail("https://bugs.python.org/issue39114") # "except Exception as e" is crucial here. # Bug 212 said that the "if exc" line was incorrectly marked as only # partially covered. @@ -818,9 +815,8 @@ class ExceptionArcTest(CoverageTest): arcz_unpredicted="45 7A AB", ) + @xfail(env.PYBEHAVIOR.bpo39114, "https://bugs.python.org/issue39114") def test_return_finally(self): - if env.PYBEHAVIOR.bpo39114: - self.xfail("https://bugs.python.org/issue39114") if env.PYBEHAVIOR.finally_jumps_back: arcz = ".1 12 29 9A AB BC C-1 -23 34 45 5-2 57 75 38 8-2" else: @@ -842,9 +838,8 @@ class ExceptionArcTest(CoverageTest): arcz=arcz, ) + @xfail(env.PYBEHAVIOR.bpo39114, "https://bugs.python.org/issue39114") def test_except_jump_finally(self): - if env.PYBEHAVIOR.bpo39114: - self.xfail("https://bugs.python.org/issue39114") if env.PYBEHAVIOR.finally_jumps_back: arcz = ( ".1 1Q QR RS ST TU U. " @@ -898,9 +893,8 @@ class ExceptionArcTest(CoverageTest): arcz_unpredicted="67", ) + @xfail(env.PYBEHAVIOR.bpo39114, "https://bugs.python.org/issue39114") def test_else_jump_finally(self): - if env.PYBEHAVIOR.bpo39114: - self.xfail("https://bugs.python.org/issue39114") if env.PYBEHAVIOR.finally_jumps_back: arcz = ( ".1 1S ST TU UV VW W. " @@ -1522,9 +1516,8 @@ class AsyncTest(CoverageTest): ) self.assertEqual(self.stdout(), "Compute 1 + 2 ...\n1 + 2 = 3\n") + @xfail(env.PYVERSION == (3, 9, 0, 'alpha', 2, 0), "https://bugs.python.org/issue39166") def test_async_for(self): - if env.PYVERSION == (3, 9, 0, 'alpha', 2, 0): - self.xfail("https://bugs.python.org/issue39166") self.check_coverage("""\ import asyncio diff --git a/tests/test_parser.py b/tests/test_parser.py index 8e7295a1..19264043 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -9,7 +9,7 @@ from coverage import env from coverage.misc import NotPython from coverage.parser import PythonParser -from tests.coveragetest import CoverageTest +from tests.coveragetest import CoverageTest, xfail from tests.helpers import arcz_to_arcs @@ -137,9 +137,12 @@ class PythonParserTest(CoverageTest): ''' """) + + @xfail( + env.PYPY3 and env.PYPYVERSION >= (7, 3, 0), + "https://bitbucket.org/pypy/pypy/issues/3139", + ) def test_decorator_pragmas(self): - if env.PYPY3 and env.PYPYVERSION >= (7, 3, 0): # pragma: obscure - self.xfail("https://bitbucket.org/pypy/pypy/issues/3139") parser = self.parse_source("""\ # 1 diff --git a/tests/test_process.py b/tests/test_process.py index 6ca4571c..e4c0ae8f 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -23,7 +23,7 @@ from coverage.data import line_counts from coverage.files import python_reported_file from coverage.misc import output_encoding -from tests.coveragetest import CoverageTest, TESTS_DIR +from tests.coveragetest import CoverageTest, TESTS_DIR, xfail from tests.helpers import re_lines @@ -742,12 +742,14 @@ class ProcessTest(CoverageTest): # about 5. self.assertGreater(line_counts(data)['os.py'], 50) + @xfail( + env.PYPY3 and env.PYPYVERSION >= (7, 1, 1), + "https://bitbucket.org/pypy/pypy/issues/3074" + ) def test_lang_c(self): if env.JYTHON: # Jython as of 2.7.1rc3 won't compile a filename that isn't utf8. self.skipTest("Jython can't handle this test") - if env.PYPY3 and env.PYPYVERSION >= (7, 1, 1): # pragma: obscure - self.xfail("https://bitbucket.org/pypy/pypy/issues/3074") # LANG=C forces getfilesystemencoding on Linux to 'ascii', which causes # failures with non-ascii file names. We don't want to make a real file # with strange characters, though, because that gets the test runners |