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

Function test_debuggee_filename_with_space

tests/debugpy/test_args.py:120–203  ·  view source on GitHub ↗

Test that a debuggee filename with a space gets properly quoted in runInTerminal.

(tmpdir, run, expansion)

Source from the content-addressed store, hash-verified

118@pytest.mark.parametrize("run", runners.all_launch_terminal)
119@pytest.mark.parametrize("expansion", ["preserve", "expand"])
120def test_debuggee_filename_with_space(tmpdir, run, expansion):
121 """Test that a debuggee filename with a space gets properly quoted in runInTerminal."""
122
123 # Create a script file with a space in both directory and filename
124
125 # Create a Python script with a space in the filename
126 script_dir = tmpdir / "test dir"
127 script_dir.mkdir()
128 script_file = script_dir / "script with space.py"
129
130 script_content = """import sys
131import debuggee
132from debuggee import backchannel
133
134debuggee.setup()
135backchannel.send(sys.argv)
136
137import time
138time.sleep(2)
139"""
140 script_file.write(script_content)
141
142 captured_run_in_terminal_request = []
143 captured_run_in_terminal_args = []
144
145 class Session(debug.Session):
146 def _process_request(self, request):
147 if request.command == "runInTerminal":
148 # Capture the raw runInTerminal request before any processing
149 args_from_request = list(request.arguments.get("args", []))
150 captured_run_in_terminal_request.append({
151 "args": args_from_request,
152 "argsCanBeInterpretedByShell": request.arguments.get("argsCanBeInterpretedByShell", False)
153 })
154 return super()._process_request(request)
155
156 def run_in_terminal(self, args, cwd, env):
157 # Capture the processed args after the framework has handled them
158 captured_run_in_terminal_args.append(args[:])
159 return super().run_in_terminal(args, cwd, env)
160
161 argslist = ["arg1", "arg2"]
162 args = argslist if expansion == "preserve" else " ".join(argslist)
163
164 with Session() as session:
165 backchannel = session.open_backchannel()
166 target = targets.Program(script_file, args=args)
167 with run(session, target):
168 pass
169
170 argv = backchannel.receive()
171
172 assert argv == [some.str] + argslist
173
174 # Verify that runInTerminal was called
175 assert captured_run_in_terminal_request, "Expected runInTerminal request to be sent"
176 request_data = captured_run_in_terminal_request[0]
177 terminal_request_args = request_data["args"]

Callers

nothing calls this directly

Calls 7

open_backchannelMethod · 0.80
receiveMethod · 0.80
infoMethod · 0.80
SessionClass · 0.70
runFunction · 0.70
writeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…