summaryrefslogtreecommitdiff
path: root/tests/test_process.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-04 07:54:32 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-11-04 08:08:48 -0400
commita89f40e4c01fcb6c5a50eb42dc372454446693eb (patch)
treee685c92d7c57822e41c245b57f43a29a3fa36940 /tests/test_process.py
parentc7c32846ea2af9863fa921c5f5735ff3958b775f (diff)
downloadpython-coveragepy-git-a89f40e4c01fcb6c5a50eb42dc372454446693eb.tar.gz
refactor(test): make traceback checks a bit flexible
Python 3.11 made a traceback look like this: Traceback (most recent call last): File "{path}", line 8, in <module> print(sys.argv[1]) ~~~~~~~~^^^ IndexError: list index out of range We needed to not care if that tilde-caret line was present or not.
Diffstat (limited to 'tests/test_process.py')
-rw-r--r--tests/test_process.py9
1 files changed, 6 insertions, 3 deletions
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():