diff options
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r-- | Lib/test/test_traceback.py | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 5cd08eeff3..0708f8163e 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -8,6 +8,16 @@ from test.test_support import run_unittest, is_jython, Error import traceback +try: + raise KeyError +except KeyError: + type_, value, tb = sys.exc_info() + file_ = StringIO() + traceback_print(tb, file_) + example_traceback = file_.getvalue() +else: + raise Error("unable to create test traceback string") + class TracebackCases(unittest.TestCase): # For now, a very minimal set of tests. I want to be sure that @@ -152,24 +162,9 @@ def test(): class TracebackFormatTests(unittest.TestCase): - def test_traceback_format(self): - try: - raise KeyError('blah') - except KeyError: - type_, value, tb = sys.exc_info() - traceback_fmt = 'Traceback (most recent call last):\n' + \ - ''.join(traceback.format_tb(tb)) - file_ = StringIO() - traceback_print(tb, file_) - python_fmt = file_.getvalue() - else: - raise Error("unable to create test traceback string") - - # Make sure that Python and the traceback module format the same thing - self.assertEquals(traceback_fmt, python_fmt) - + def test_traceback_indentation(self): # Make sure that the traceback is properly indented. - tb_lines = python_fmt.splitlines() + tb_lines = example_traceback.splitlines() self.assertEquals(len(tb_lines), 3) banner, location, source_line = tb_lines self.assert_(banner.startswith('Traceback')) |