Test that a debuggee filename with a space gets properly quoted in runInTerminal.
(tmpdir, run, expansion)
| 118 | @pytest.mark.parametrize("run", runners.all_launch_terminal) |
| 119 | @pytest.mark.parametrize("expansion", ["preserve", "expand"]) |
| 120 | def 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 |
| 131 | import debuggee |
| 132 | from debuggee import backchannel |
| 133 | |
| 134 | debuggee.setup() |
| 135 | backchannel.send(sys.argv) |
| 136 | |
| 137 | import time |
| 138 | time.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"] |
nothing calls this directly
no test coverage detected
searching dependent graphs…