From 3fc63f33449ded06431f3b4954c9f0aa1cedf1b8 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 20 Feb 2010 07:07:19 -0500 Subject: A better way to test for correct handling of tracebacks during product code execution. --- test/test_process.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'test/test_process.py') 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 ") - expected = textwrap.dedent("""\ - Traceback (most recent call last): - File "throw.py", line 7, in - 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) -- cgit v1.2.1