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

Method test_extract_stack

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

Source from the content-addressed store, hash-verified

3180 return self.last_returns_frame4()
3181
3182 def test_extract_stack(self):
3183 frame = self.last_returns_frame5()
3184 def extract(**kwargs):
3185 return traceback.extract_stack(frame, **kwargs)
3186 def assertEqualExcept(actual, expected, ignore):
3187 self.assertEqual(actual[:ignore], expected[:ignore])
3188 self.assertEqual(actual[ignore+1:], expected[ignore+1:])
3189 self.assertEqual(len(actual), len(expected))
3190
3191 with support.swap_attr(sys, 'tracebacklimit', 1000):
3192 nolim = extract()
3193 self.assertGreater(len(nolim), 5)
3194 self.assertEqual(extract(limit=2), nolim[-2:])
3195 assertEqualExcept(extract(limit=100), nolim[-100:], -5-1)
3196 self.assertEqual(extract(limit=-2), nolim[:2])
3197 assertEqualExcept(extract(limit=-100), nolim[:100], len(nolim)-5-1)
3198 self.assertEqual(extract(limit=0), [])
3199 del sys.tracebacklimit
3200 assertEqualExcept(extract(), nolim, -5-1)
3201 sys.tracebacklimit = 2
3202 self.assertEqual(extract(), nolim[-2:])
3203 self.assertEqual(extract(limit=3), nolim[-3:])
3204 self.assertEqual(extract(limit=-3), nolim[:3])
3205 sys.tracebacklimit = 0
3206 self.assertEqual(extract(), [])
3207 sys.tracebacklimit = -1
3208 self.assertEqual(extract(), [])
3209
3210 def test_extract_tb(self):
3211 try:

Callers

nothing calls this directly

Calls 4

last_returns_frame5Method · 0.95
extractFunction · 0.85
assertGreaterMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected