MCPcopy Index your code
hub / github.com/ipython/ipython / test_debug_magic_passes_through_generators

Function test_debug_magic_passes_through_generators

tests/test_debug_magic.py:25–87  ·  view source on GitHub ↗

This test that we can correctly pass through frames of a generator post-mortem.

()

Source from the content-addressed store, hash-verified

23
24@skip_win32
25def test_debug_magic_passes_through_generators():
26 """
27 This test that we can correctly pass through frames of a generator post-mortem.
28 """
29 import pexpect
30 import re
31
32 in_prompt = re.compile(rb"In ?\[\d+\]:")
33 ipdb_prompt = "ipdb>"
34 env = os.environ.copy()
35 child = pexpect.spawn(
36 sys.executable,
37 ["-m", "IPython", "--colors=nocolor", "--simple-prompt"],
38 env=env,
39 )
40 child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE
41
42 child.expect(in_prompt)
43
44 child.timeout = 2 * IPYTHON_TESTING_TIMEOUT_SCALE
45
46 child.sendline("def f(x):")
47 child.sendline(" raise Exception")
48 child.sendline("")
49
50 child.expect(in_prompt)
51 child.sendline("gen = (f(x) for x in [0])")
52 child.sendline("")
53
54 child.expect(in_prompt)
55 child.sendline("for x in gen:")
56 child.sendline(" pass")
57 child.sendline("")
58
59 child.timeout = 10 * IPYTHON_TESTING_TIMEOUT_SCALE
60
61 child.expect("Exception:")
62
63 child.expect(in_prompt)
64 child.sendline(r"%debug")
65 child.expect("----> 2 raise Exception")
66
67 child.expect(ipdb_prompt)
68 child.sendline("u")
69 child.expect_exact(r"----> 1 gen = (f(x) for x in [0])")
70
71 child.expect(ipdb_prompt)
72 child.sendline("u")
73 child.expect_exact("----> 1 for x in gen:")
74
75 child.expect(ipdb_prompt)
76 child.sendline("u")
77 child.expect_exact(
78 "*** all frames above skipped (hidden frames and ignored modules). Use `skip_hidden False` for hidden frames or unignore_module for ignored modules."
79 )
80
81 child.expect(ipdb_prompt)
82 child.sendline("exit")

Callers

nothing calls this directly

Calls 2

copyMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…