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

Function test_log_point

tests/debugpy/test_breakpoints.py:180–229  ·  view source on GitHub ↗
(pyfile, target, run, condition)

Source from the content-addressed store, hash-verified

178@pytest.mark.parametrize("condition", ["condition", ""])
179@pytest.mark.parametrize("target", targets.all_named)
180def test_log_point(pyfile, target, run, condition):
181 @pyfile
182 def code_to_debug():
183 import debuggee
184 import sys
185
186 debuggee.setup()
187 for i in range(0, 10):
188 sys.stderr.write(str(i * 10) + "\n") # @bp
189 sys.stderr.flush()
190 x = 4 # @wait_for_output
191
192 lines = code_to_debug.lines
193 with debug.Session() as session:
194 session.config["redirectOutput"] = True
195
196 with run(session, target(code_to_debug)):
197 bp = {"line": lines["bp"], "logMessage": "{i}"}
198 if condition:
199 bp["condition"] = "i == 5"
200 session.request(
201 "setBreakpoints",
202 {
203 "source": {"path": code_to_debug},
204 "breakpoints": [bp, {"line": lines["wait_for_output"]}],
205 },
206 )
207
208 session.wait_for_stop(
209 "breakpoint",
210 expected_frames=[some.dap.frame(code_to_debug, line="wait_for_output")],
211 )
212 session.request_continue()
213
214 # print() should produce both actual output, and "output" events on stderr,
215 # but logpoints should only produce "output" events on stdout.
216 if "internalConsole" not in str(run):
217 assert not session.captured_stdout()
218
219 if condition:
220 expected_stdout = "5\r?\n"
221 else:
222 expected_stdout = "".join(
223 (r"{0}\r?\n".format(re.escape(str(i))) for i in range(0, 10))
224 )
225 expected_stderr = "".join(
226 (r"{0}\r?\n".format(re.escape(str(i * 10))) for i in range(0, 10))
227 )
228 assert session.output("stdout") == some.str.matching(expected_stdout)
229 assert session.output("stderr") == some.str.matching(expected_stderr)
230
231
232@pytest.mark.parametrize("run", [runners.launch])

Callers

nothing calls this directly

Calls 9

wait_for_stopMethod · 0.80
request_continueMethod · 0.80
captured_stdoutMethod · 0.80
outputMethod · 0.80
matchingMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
requestMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…