MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_extract_tb

Method test_extract_tb

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

Source from the content-addressed store, hash-verified

3286 self.assertEqual(extract(), [])
3287
3288 def test_extract_tb(self):
3289 try:
3290 self.last_raises5()
3291 except Exception as e:
3292 tb = e.__traceback__
3293 def extract(**kwargs):
3294 return traceback.extract_tb(tb, **kwargs)
3295
3296 with support.swap_attr(sys, 'tracebacklimit', 1000):
3297 nolim = extract()
3298 self.assertEqual(len(nolim), 5+1)
3299 self.assertEqual(extract(limit=2), nolim[:2])
3300 self.assertEqual(extract(limit=10), nolim)
3301 self.assertEqual(extract(limit=-2), nolim[-2:])
3302 self.assertEqual(extract(limit=-10), nolim)
3303 self.assertEqual(extract(limit=0), [])
3304 del sys.tracebacklimit
3305 self.assertEqual(extract(), nolim)
3306 sys.tracebacklimit = 2
3307 self.assertEqual(extract(), nolim[:2])
3308 self.assertEqual(extract(limit=3), nolim[:3])
3309 self.assertEqual(extract(limit=-3), nolim[-3:])
3310 sys.tracebacklimit = 0
3311 self.assertEqual(extract(), [])
3312 sys.tracebacklimit = -1
3313 self.assertEqual(extract(), [])
3314
3315 def test_format_exception(self):
3316 try:

Callers

nothing calls this directly

Calls 4

last_raises5Method · 0.95
extractFunction · 0.85
lenFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected