summaryrefslogtreecommitdiff
path: root/tests/test_cmdline.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_cmdline.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_cmdline.py')
-rw-r--r--tests/test_cmdline.py9
1 files changed, 5 insertions, 4 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"):