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

Method test_cause_recursive

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

Source from the content-addressed store, hash-verified

2417 self.assertIn('inner_raise() # Marker', blocks[2])
2418
2419 def test_cause_recursive(self):
2420 def inner_raise():
2421 try:
2422 try:
2423 self.zero_div()
2424 except ZeroDivisionError as e:
2425 z = e
2426 raise KeyError from e
2427 except KeyError as e:
2428 raise z from e
2429 def outer_raise():
2430 inner_raise() # Marker
2431 blocks = boundaries.split(self.get_report(outer_raise))
2432 self.assertEqual(len(blocks), 3)
2433 self.assertEqual(blocks[1], cause_message)
2434 # The first block is the KeyError raised from the ZeroDivisionError
2435 self.assertIn('raise KeyError from e', blocks[0])
2436 self.assertNotIn('1/0', blocks[0])
2437 # The second block (apart from the boundary) is the ZeroDivisionError
2438 # re-raised from the KeyError
2439 self.assertIn('inner_raise() # Marker', blocks[2])
2440 self.check_zero_div(blocks[2])
2441
2442 def test_syntax_error_offset_at_eol(self):
2443 # See #10186.

Callers

nothing calls this directly

Calls 6

check_zero_divMethod · 0.95
assertInMethod · 0.80
assertNotInMethod · 0.80
splitMethod · 0.45
get_reportMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected