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

Function test_error_in_condition

tests/debugpy/test_breakpoints.py:139–175  ·  view source on GitHub ↗
(pyfile, target, run, error_name)

Source from the content-addressed store, hash-verified

137# all other errors, we should be printing traceback.
138@pytest.mark.parametrize("error_name", ["NameError", ""])
139def test_error_in_condition(pyfile, target, run, error_name):
140 error_name = error_name or "ZeroDivisionError"
141
142 condition, expect_traceback = {
143 "NameError": ("no_such_name", False),
144 "ZeroDivisionError": ("1 / 0", True),
145 }[error_name]
146
147 @pyfile
148 def code_to_debug():
149 import debuggee
150
151 debuggee.setup()
152 for i in range(1, 10): # @bp
153 pass
154
155 with debug.Session() as session:
156 with run(session, target(code_to_debug)):
157 session.request(
158 "setBreakpoints",
159 {
160 "source": {"path": code_to_debug},
161 "breakpoints": [
162 {"line": code_to_debug.lines["bp"], "condition": condition}
163 ],
164 },
165 )
166 occurrences = session.timeline.all_occurrences_of(
167 timeline.Event("output", some.dict.containing({"category": "important"})),
168 )
169
170 if expect_traceback:
171 assert len(occurrences) == 10
172 for occurrence in occurrences:
173 assert error_name in occurrence.body['output']
174 else:
175 assert len(occurrences) == 0
176
177
178@pytest.mark.parametrize("condition", ["condition", ""])

Callers

nothing calls this directly

Calls 4

runFunction · 0.70
targetFunction · 0.70
requestMethod · 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…