MCPcopy Create free account
hub / github.com/microsoft/debugpy / test_module_events

Function test_module_events

tests/debugpy/test_vs_specific.py:51–100  ·  view source on GitHub ↗
(pyfile, target, run)

Source from the content-addressed store, hash-verified

49
50
51def test_module_events(pyfile, target, run):
52 @pyfile
53 def module2():
54 def do_more_things():
55 print("done") # @bp
56
57 @pyfile
58 def module1():
59 import module2
60
61 def do_something():
62 module2.do_more_things()
63
64 @pyfile
65 def test_code():
66 import debuggee
67
68 debuggee.setup()
69
70 from module1 import do_something
71
72 do_something()
73
74 with debug.Session() as session:
75 with run(session, target(test_code)):
76 session.set_breakpoints(module2, all)
77
78 session.wait_for_stop(
79 "breakpoint", expected_frames=[some.dap.frame(module2, line="bp")]
80 )
81
82 # Stack trace after the stop will trigger module events, but they are only
83 # sent after the trace response, so we need to wait for them separately.
84 # The order isn't guaranteed, either, so just wait for any 3 modules.
85 session.timeline.wait_until_realized(
86 Event("module") >> Event("module") >> Event("module")
87 )
88 modules = {
89 event.body["module"]["name"]: event.body["module"]["path"]
90 for event in session.all_occurrences_of(Event("module"))
91 }
92 assert modules == some.dict.containing(
93 {
94 "__main__": some.path(test_code),
95 "module1": some.path(module1),
96 "module2": some.path(module2),
97 }
98 )
99
100 session.request_continue()

Callers

nothing calls this directly

Calls 9

EventFunction · 0.90
set_breakpointsMethod · 0.80
wait_for_stopMethod · 0.80
pathMethod · 0.80
request_continueMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
wait_until_realizedMethod · 0.45
all_occurrences_ofMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…