diff --git a/IPython/core/tests/test_ultratb.py b/IPython/core/tests/test_ultratb.py index 3ab0ce3..71af252 100644 --- a/IPython/core/tests/test_ultratb.py +++ b/IPython/core/tests/test_ultratb.py @@ -8,10 +8,8 @@ import os.path from textwrap import dedent import traceback import unittest -from unittest import mock -import IPython.core.ultratb as ultratb -from IPython.core.ultratb import ColorTB, VerboseTB, find_recursion +from IPython.core.ultratb import ColorTB, VerboseTB from IPython.testing import tools as tt @@ -38,16 +36,12 @@ def recursionlimit(frames): def inner(test_function): def wrapper(*args, **kwargs): - _orig_rec_limit = ultratb._FRAME_RECURSION_LIMIT - ultratb._FRAME_RECURSION_LIMIT = 50 - rl = sys.getrecursionlimit() sys.setrecursionlimit(frames) try: return test_function(*args, **kwargs) finally: sys.setrecursionlimit(rl) - ultratb._FRAME_RECURSION_LIMIT = _orig_rec_limit return wrapper @@ -350,45 +344,24 @@ def r3o2(): ip.run_cell(self.DEFINITIONS) def test_no_recursion(self): - with tt.AssertNotPrints("frames repeated"): + with tt.AssertNotPrints("skipping similar frames"): ip.run_cell("non_recurs()") @recursionlimit(150) def test_recursion_one_frame(self): - with tt.AssertPrints("1 frames repeated"): + with tt.AssertPrints("[... skipping similar frames: r1 at line 5 (95 times)]"): ip.run_cell("r1()") @recursionlimit(150) def test_recursion_three_frames(self): - with tt.AssertPrints("3 frames repeated"): + with tt.AssertPrints( + "[... skipping similar frames: " + "r3a at line 8 (29 times), " + "r3b at line 11 (29 times), " + "r3c at line 14 (29 times)]" + ): ip.run_cell("r3o2()") - @recursionlimit(150) - def test_find_recursion(self): - captured = [] - def capture_exc(*args, **kwargs): - captured.append(sys.exc_info()) - with mock.patch.object(ip, 'showtraceback', capture_exc): - ip.run_cell("r3o2()") - - self.assertEqual(len(captured), 1) - etype, evalue, tb = captured[0] - self.assertIn("recursion", str(evalue)) - - records = ip.InteractiveTB.get_records(tb, 3, ip.InteractiveTB.tb_offset) - for r in records[:10]: - print(r[1:4]) - - # The outermost frames should be: - # 0: the 'cell' that was running when the exception came up - # 1: r3o2() - # 2: r3o1() - # 3: r3a() - # Then repeating r3b, r3c, r3a - last_unique, repeat_length = find_recursion(etype, evalue, records) - self.assertEqual(last_unique, 2) - self.assertEqual(repeat_length, 3) - #----------------------------------------------------------------------------