Back to index

python3.2  3.2.2
Public Member Functions
test.test_traceback.TracebackFormatTests Class Reference

List of all members.

Public Member Functions

def test_traceback_format

Detailed Description

Definition at line 151 of file test_traceback.py.


Member Function Documentation

Definition at line 153 of file test_traceback.py.

00153 
00154     def test_traceback_format(self):
00155         try:
00156             raise KeyError('blah')
00157         except KeyError:
00158             type_, value, tb = sys.exc_info()
00159             traceback_fmt = 'Traceback (most recent call last):\n' + \
00160                             ''.join(traceback.format_tb(tb))
00161             file_ = StringIO()
00162             traceback_print(tb, file_)
00163             python_fmt  = file_.getvalue()
00164         else:
00165             raise Error("unable to create test traceback string")
00166 
00167         # Make sure that Python and the traceback module format the same thing
00168         self.assertEqual(traceback_fmt, python_fmt)
00169 
00170         # Make sure that the traceback is properly indented.
00171         tb_lines = python_fmt.splitlines()
00172         self.assertEqual(len(tb_lines), 3)
00173         banner, location, source_line = tb_lines
00174         self.assertTrue(banner.startswith('Traceback'))
00175         self.assertTrue(location.startswith('  File'))
00176         self.assertTrue(source_line.startswith('    raise'))
00177 

Here is the call graph for this function:


The documentation for this class was generated from the following file: