diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-02-20 07:07:19 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-02-20 07:07:19 -0500 |
commit | 3fc63f33449ded06431f3b4954c9f0aa1cedf1b8 (patch) | |
tree | 42c4e00b670330c920b70fc86bbfd65bf8027c6d /test/test_process.py | |
parent | f70090edc42512d8c50d9629867645fff552b775 (diff) | |
download | python-coveragepy-3fc63f33449ded06431f3b4954c9f0aa1cedf1b8.tar.gz |
A better way to test for correct handling of tracebacks during product code execution.
Diffstat (limited to 'test/test_process.py')
-rw-r--r-- | test/test_process.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/test/test_process.py b/test/test_process.py index b8ccb94..fcc5020 100644 --- a/test/test_process.py +++ b/test/test_process.py @@ -160,18 +160,13 @@ class ProcessTest(CoverageTest): f2() """) + # The important thing is for "coverage run" and "python" to report the + # same traceback. out = self.run_command("coverage run throw.py") - # Different versions of Python report the module-level code differently - # in tracebacks, so canononicalize it. - out = out.replace(", in ?", ", in <module>") - expected = textwrap.dedent("""\ - Traceback (most recent call last): - File "throw.py", line 7, in <module> - f2() - File "throw.py", line 5, in f2 - f1() - File "throw.py", line 2, in f1 - raise Exception("hey!") - Exception: hey! - """) - self.assertMultiLineEqual(out, expected) + out2 = self.run_command("python throw.py") + self.assertMultiLineEqual(out, out2) + + # But also make sure that the output is what we expect. + self.assertTrue('File "throw.py", line 5, in f2' in out) + self.assertTrue('raise Exception("hey!")' in out) + self.assertFalse('coverage' in out) |