summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-02-20 07:07:19 -0500
committerNed Batchelder <ned@nedbatchelder.com>2010-02-20 07:07:19 -0500
commit18b0df82b8055a270b007d47bade0db64d5d822d (patch)
treeb660d5348df3c1a830baf41d2b1518d0724adcec
parent86f65fd21d59fdd4febdab308e907976ca1dce6d (diff)
downloadpython-coveragepy-git-18b0df82b8055a270b007d47bade0db64d5d822d.tar.gz
A better way to test for correct handling of tracebacks during product code execution.
-rw-r--r--CHANGES.txt4
-rw-r--r--test/test_process.py23
2 files changed, 13 insertions, 14 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 34c75c80..fc6c7cd3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -22,6 +22,10 @@ Version 3.3
- Parallel data files combined with "coverage combine" are deleted after
they're combined, to clean up unneeded files. Fixes `issue 40`_.
+- Exceptions thrown from product code run with "coverage run" are now displayed
+ without internal coverage.py frames, so the output is the same as if the code
+ is run without coverage.py.
+
- The `data_suffix` argument to the coverage constructor is now appended with
an added dot rather than simply appended, so that .coveragerc files will not
be confused for data files.
diff --git a/test/test_process.py b/test/test_process.py
index b8ccb942..fcc50200 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)