(self)
| 369 | |
| 370 | @recursionlimit(150) |
| 371 | def test_find_recursion(self): |
| 372 | captured = [] |
| 373 | def capture_exc(*args, **kwargs): |
| 374 | captured.append(sys.exc_info()) |
| 375 | with mock.patch.object(ip, 'showtraceback', capture_exc): |
| 376 | ip.run_cell("r3o2()") |
| 377 | |
| 378 | self.assertEqual(len(captured), 1) |
| 379 | etype, evalue, tb = captured[0] |
| 380 | self.assertIn("recursion", str(evalue)) |
| 381 | |
| 382 | records = ip.InteractiveTB.get_records(tb, 3, ip.InteractiveTB.tb_offset) |
| 383 | for r in records[:10]: |
| 384 | print(r[1:4]) |
| 385 | |
| 386 | # The outermost frames should be: |
| 387 | # 0: the 'cell' that was running when the exception came up |
| 388 | # 1: r3o2() |
| 389 | # 2: r3o1() |
| 390 | # 3: r3a() |
| 391 | # Then repeating r3b, r3c, r3a |
| 392 | last_unique, repeat_length = find_recursion(etype, evalue, records) |
| 393 | self.assertEqual(last_unique, 2) |
| 394 | self.assertEqual(repeat_length, 3) |
| 395 | |
| 396 | |
| 397 | #---------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected