diff options
-rw-r--r-- | tests/test_cmdline.py | 9 | ||||
-rw-r--r-- | tests/test_process.py | 9 |
2 files changed, 11 insertions, 7 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 9e987760..acd5fa29 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -956,10 +956,11 @@ class CmdMainTest(CoverageTest): assert ret == 1 out, err = self.stdouterr() assert out == "" - err = err.split('\n') - assert err[0] == 'Traceback (most recent call last):' - assert err[-3] == ' raise Exception("oh noes!")' - assert err[-2] == 'Exception: oh noes!' + print(err) + err = err.splitlines(keepends=True) + assert err[0] == 'Traceback (most recent call last):\n' + assert ' raise Exception("oh noes!")\n' in err + assert err[-1] == 'Exception: oh noes!\n' def test_internalraise(self): with pytest.raises(ValueError, match="coverage is broken"): diff --git a/tests/test_process.py b/tests/test_process.py index e048bdc2..b8f268f7 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1412,12 +1412,15 @@ class YankedDirectoryTest(CoverageTest): self.make_file("bug806.py", self.BUG_806) out = self.run_command("coverage run bug806.py") path = python_reported_file('bug806.py') - assert out == textwrap.dedent("""\ + # Python 3.11 adds an extra line to the traceback. + # Check that the lines we expect are there. + lines = textwrap.dedent(f"""\ Traceback (most recent call last): - File "{}", line 8, in <module> + File "{path}", line 8, in <module> print(sys.argv[1]) IndexError: list index out of range - """.format(path)) + """).splitlines(keepends=True) + assert all(line in out for line in lines) def possible_pth_dirs(): |