MCPcopy Index your code
hub / github.com/python/cpython / test_extract_tb

Method test_extract_tb

Lib/test/test_traceback.py:3210–3235  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3208 self.assertEqual(extract(), [])
3209
3210 def test_extract_tb(self):
3211 try:
3212 self.last_raises5()
3213 except Exception as e:
3214 tb = e.__traceback__
3215 def extract(**kwargs):
3216 return traceback.extract_tb(tb, **kwargs)
3217
3218 with support.swap_attr(sys, 'tracebacklimit', 1000):
3219 nolim = extract()
3220 self.assertEqual(len(nolim), 5+1)
3221 self.assertEqual(extract(limit=2), nolim[:2])
3222 self.assertEqual(extract(limit=10), nolim)
3223 self.assertEqual(extract(limit=-2), nolim[-2:])
3224 self.assertEqual(extract(limit=-10), nolim)
3225 self.assertEqual(extract(limit=0), [])
3226 del sys.tracebacklimit
3227 self.assertEqual(extract(), nolim)
3228 sys.tracebacklimit = 2
3229 self.assertEqual(extract(), nolim[:2])
3230 self.assertEqual(extract(limit=3), nolim[:3])
3231 self.assertEqual(extract(limit=-3), nolim[-3:])
3232 sys.tracebacklimit = 0
3233 self.assertEqual(extract(), [])
3234 sys.tracebacklimit = -1
3235 self.assertEqual(extract(), [])
3236
3237 def test_format_exception(self):
3238 try:

Callers

nothing calls this directly

Calls 3

last_raises5Method · 0.95
extractFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected