Lines Matching refs:traceback

1 """Test cases for traceback module"""
20 import traceback
39 return traceback.format_exception_only(exc, value)
103 err = traceback.format_exception_only(SyntaxError, exc)
109 # in the traceback.
128 import traceback
132 traceback.print_exc()
192 lst = traceback.format_exception_only(e.__class__, e)
199 err = traceback.format_exception_only(X, X())
230 import traceback;
254 "Invalid traceback line: {0!r} instead of {1!r}".format(
279 # Issue #22599: Ensure that it is possible to use the traceback module
283 import traceback
291 # self.exc_info[1] (traceback) contains frames:
297 traceback.print_exception(*self.exc_info)
311 traceback.print_exception(
318 traceback.print_exception(Exception("projector"), file=output)
323 output = traceback.format_exception(e)
326 traceback.format_exception(e.__class__, e)
328 traceback.format_exception(e.__class__, tb=e.__traceback__)
330 traceback.format_exception(exc=e)
333 output = traceback.format_exception_only(Exception("projector"))
339 traceback.print_exception(None, file=excfile)
343 traceback.print_exception(None, None, None, file=excfile)
347 traceback.print_exc(None, file=excfile)
350 self.assertEqual(traceback.format_exc(None), NONE_EXC_STRING)
351 self.assertEqual(traceback.format_exception(None), [NONE_EXC_STRING])
353 traceback.format_exception(None, None, None), [NONE_EXC_STRING])
355 traceback.format_exception_only(None), [NONE_EXC_STRING])
357 traceback.format_exception_only(None, None), [NONE_EXC_STRING])
361 str(inspect.signature(traceback.print_exception)),
366 str(inspect.signature(traceback.format_exception)),
371 str(inspect.signature(traceback.format_exception_only)),
385 return traceback.format_exc().splitlines()[:-1]
869 Same set of tests as above but with Python's internal traceback printing.
900 ''.join(traceback.format_tb(tb))
906 traceback.print_tb(tb)
908 traceback.print_tb(tb, file=tbfile)
910 traceback.print_exc()
911 excfmt = traceback.format_exc()
913 traceback.print_exc(file=excfile)
915 raise Error("unable to create test traceback string")
917 # Make sure that Python and the traceback module format the same thing
925 # Make sure that the traceback is properly indented.
938 # Check that traceback formatting also works with a clear()ed frame
947 traceback.print_stack(sys._getframe(1))
949 traceback.print_stack(sys._getframe(1), file=stfile)
952 stfmt = traceback.format_stack(sys._getframe(1))
958 traceback.print_stack()
966 ' traceback.print_stack()',
1099 g(traceback._RECURSIVE_CUTOFF)
1121 ' g(traceback._RECURSIVE_CUTOFF)\n'
1130 g(traceback._RECURSIVE_CUTOFF + 1)
1153 ' g(traceback._RECURSIVE_CUTOFF + 1)\n'
1161 self._check_recursive_traceback_display(traceback.print_exc)
1174 return traceback.format_stack()
1181 ' return traceback.format_stack()\n' % (__file__, lineno+1),
1234 traceback.print_exception(type(eg), eg, eg.__traceback__)
1253 traceback.print_exception(42)
1995 # This checks reporting through the 'traceback' module, with both
2002 traceback.format_exception(type(e), e, e.__traceback__))
2004 traceback.print_exception(type(e), e, e.__traceback__)
2061 return traceback.extract_stack(frame, **kwargs)
2092 return traceback.extract_tb(tb, **kwargs)
2121 return traceback.format_exception(exc_type, exc_value, tb, **kwargs)[1:-1]
2145 # Check non-printing functions in traceback module
2166 # Clear traceback frames
2167 traceback.clear_frames(tb)
2174 return traceback.extract_stack()
2179 (__file__, lineno+1, 'extract', 'return traceback.extract_stack()'),
2189 f = traceback.FrameSummary("f", 1, "dummy")
2191 ("f", 1, "dummy", '"""Test cases for traceback module"""'))
2193 ("f", 1, "dummy", '"""Test cases for traceback module"""'))
2194 self.assertEqual(f, traceback.FrameSummary("f", 1, "dummy"))
2205 f = traceback.FrameSummary("f", 1, "dummy", lookup_line=False)
2209 '"""Test cases for traceback module"""',
2213 f = traceback.FrameSummary("f", None, "dummy")
2217 f = traceback.FrameSummary("f", 1, "dummy", line="line")
2221 f = traceback.FrameSummary("f", 1, "dummy", line="line")
2229 return list(traceback.walk_stack(None))
2230 s1 = list(traceback.walk_stack(None))
2240 s = list(traceback.walk_tb(tb))
2244 s = traceback.StackSummary.extract(traceback.walk_stack(None))
2245 self.assertIsInstance(s, traceback.StackSummary)
2248 s = traceback.StackSummary.extract(traceback.walk_stack(None), limit=5)
2256 s = traceback.StackSummary.extract(iter([(f, 6)]), lookup_lines=True)
2264 s = traceback.StackSummary.extract(iter([(f, 6)]), lookup_lines=False)
2270 s = traceback.StackSummary.from_list([('foo.py', 1, 'fred', 'line')])
2276 s = traceback.StackSummary.from_list([('foo.py', 1, 'fred', 'line')])
2278 s2 = traceback.StackSummary.from_list(s)
2286 s = traceback.StackSummary.from_list([('foo.py', 1, 'fred', 'line')])
2295 s = traceback.StackSummary.extract(iter([(f, 6)]), capture_locals=True)
2302 s = traceback.StackSummary.extract(iter([(f, 6)]))
2309 return traceback.StackSummary.extract(
2310 traceback.walk_stack(None), capture_locals=True, limit=1)
2314 ' return traceback.StackSummary.extract(\n'
2322 class CustomStackSummary(traceback.StackSummary):
2328 traceback.walk_stack(None), limit=1)
2347 class Skip_G(traceback.StackSummary):
2354 traceback.walk_tb(exc_info[2])).format()
2371 exc = traceback.TracebackException(*exc_info)
2372 expected_stack = traceback.StackSummary.extract(
2373 traceback.walk_tb(exc_info[2]))
2389 self.expected_stack = traceback.StackSummary.extract(
2390 traceback.walk_tb(exc_info[2]), limit=1, lookup_lines=False,
2392 self.exc = traceback.TracebackException.from_exception(
2409 exc_context = traceback.TracebackException(*exc_info_context)
2414 exc = traceback.TracebackException(*exc_info)
2415 expected_stack = traceback.StackSummary.extract(
2416 traceback.walk_tb(exc_info[2]))
2417 exc_cause = traceback.TracebackException(Exception, cause, None)
2431 exc_context = traceback.TracebackException(*exc_info_context)
2435 exc = traceback.TracebackException(*exc_info)
2436 expected_stack = traceback.StackSummary.extract(
2437 traceback.walk_tb(exc_info[2]))
2459 te = traceback.TracebackException(*exc_info)
2479 exc = traceback.TracebackException(*exc_info, compact=True)
2480 expected_stack = traceback.StackSummary.extract(
2481 traceback.walk_tb(exc_info[2]))
2482 exc_cause = traceback.TracebackException(Exception, cause, None)
2496 exc_context = traceback.TracebackException(*exc_info_context)
2500 exc = traceback.TracebackException(*exc_info, compact=True)
2501 expected_stack = traceback.StackSummary.extract(
2502 traceback.walk_tb(exc_info[2]))
2518 exc = traceback.TracebackException(*exc_info)
2527 exc = traceback.TracebackException(*exc_info)
2528 exc2 = traceback.TracebackException(*exc_info)
2550 exc = traceback.TracebackException(*exc_info)
2551 exc1 = traceback.TracebackException(*exc_info, limit=10)
2552 exc2 = traceback.TracebackException(*exc_info, limit=2)
2558 exc3 = traceback.TracebackException(*exc_info, capture_locals=True)
2562 exc4 = traceback.TracebackException(*exc_info, limit=-1)
2563 exc5 = traceback.TracebackException(*exc_info, limit=-1, capture_locals=True)
2567 exc6 = traceback.TracebackException(*exc_info, limit=-2)
2568 exc7 = traceback.TracebackException(*exc_info, limit=-2, capture_locals=True)
2577 excs.append(traceback.TracebackException(*sys.exc_info()))
2595 exc = traceback.TracebackException(*exc_info)
2610 exc = traceback.TracebackException(*exc_info, limit=5)
2611 expected_stack = traceback.StackSummary.extract(
2612 traceback.walk_tb(exc_info[2]), limit=5)
2621 exc = traceback.TracebackException(Exception, e, tb, lookup_lines=False)
2632 exc = traceback.TracebackException(
2643 exc = traceback.TracebackException(Exception, e, tb)
2647 # do not print a traceback header if exc_traceback is None
2649 exc = traceback.TracebackException(Exception, Exception("haven"), None)
2660 exc = traceback.TracebackException(*f(), capture_locals=True)
2711 teg1 = traceback.TracebackException(*eg_info)
2712 teg2 = traceback.TracebackException.from_exception(eg_info[1])
2717 teg = traceback.TracebackException(*self.eg_info)
2724 teg = traceback.TracebackException(*self.eg_info)
2779 teg = traceback.TracebackException.from_exception(eg, max_group_width=2)
2811 teg = traceback.TracebackException.from_exception(exc, max_group_depth=2)
2844 exc = traceback.TracebackException(*exc_info)
2845 exc2 = traceback.TracebackException(*exc_info)
2846 exc3 = traceback.TracebackException(*exc_info, limit=300)
2847 ne = traceback.TracebackException(*exc_info, limit=3)
2861 for name in dir(traceback):
2864 module_object = getattr(traceback, name)
2865 if getattr(module_object, '__module__', None) == 'traceback':
2867 self.assertCountEqual(traceback.__all__, expected)