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

Function test_custom_python_args

tests/debugpy/test_run.py:254–285  ·  view source on GitHub ↗
(
    pyfile, tmpdir, run, target, python_key, python, python_args
)

Source from the content-addressed store, hash-verified

252@pytest.mark.parametrize("python_key", ["python", "pythonPath"])
253@pytest.mark.flaky(retries=2, delay=1)
254def test_custom_python_args(
255 pyfile, tmpdir, run, target, python_key, python, python_args
256):
257 @pyfile
258 def code_to_debug():
259 import sys
260
261 import debuggee
262 from debuggee import backchannel
263
264 debuggee.setup()
265 backchannel.send([sys.flags.optimize, sys.flags.dont_write_bytecode])
266
267 custompy = make_custompy(tmpdir)
268 python = [] if python is None else python.split(",")
269 python = [(custompy if arg == "custompy" else arg) for arg in python]
270 python_args = [] if python_args is None else python_args.split(",")
271 python_cmd = (python if len(python) else [sys.executable]) + python_args
272
273 with debug.Session() as session:
274 session.config.pop("python", None)
275 session.config.pop("pythonPath", None)
276 if len(python):
277 session.config[python_key] = python[0] if len(python) == 1 else python
278 if len(python_args):
279 session.config["pythonArgs"] = python_args
280
281 backchannel = session.open_backchannel()
282 with run(session, target(code_to_debug)):
283 pass
284
285 assert backchannel.receive() == ["-O" in python_cmd, "-B" in python_cmd]
286
287
288@pytest.mark.parametrize("run", runners.all)

Callers

nothing calls this directly

Calls 6

make_custompyFunction · 0.85
popMethod · 0.80
open_backchannelMethod · 0.80
receiveMethod · 0.80
runFunction · 0.70
targetFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…