(pyfile, target, run, subProcess, method)
| 166 | @pytest.mark.parametrize("subProcess", [True, False, None]) |
| 167 | @pytest.mark.parametrize("method", ["startDebugging", "debugpyAttach", ""]) |
| 168 | def test_subprocess(pyfile, target, run, subProcess, method): |
| 169 | @pyfile |
| 170 | def child(): |
| 171 | import os |
| 172 | import sys |
| 173 | |
| 174 | assert "debugpy" in sys.modules |
| 175 | |
| 176 | import debugpy |
| 177 | from debuggee import backchannel |
| 178 | |
| 179 | backchannel.send(os.getpid()) |
| 180 | backchannel.send(debugpy.__file__) |
| 181 | backchannel.send(sys.argv) |
| 182 | |
| 183 | @pyfile |
| 184 | def parent(): |
| 185 | import debuggee |
| 186 | import os |
| 187 | import subprocess |
| 188 | import sys |
| 189 | |
| 190 | debuggee.setup() |
| 191 | argv = [sys.executable, sys.argv[1], "--arg1", "--arg2", "--arg3"] |
| 192 | env = os.environ.copy() |
| 193 | process = subprocess.Popen( |
| 194 | argv, |
| 195 | env=env, |
| 196 | stdin=subprocess.PIPE, |
| 197 | stdout=subprocess.PIPE, |
| 198 | stderr=subprocess.PIPE, |
| 199 | ) |
| 200 | process.wait() |
| 201 | |
| 202 | with debug.Session() as parent_session: |
| 203 | backchannel = parent_session.open_backchannel() |
| 204 | |
| 205 | if method: |
| 206 | parent_session.capabilities["supportsStartDebuggingRequest"] = (method == "startDebugging") |
| 207 | parent_session.config["preLaunchTask"] = "doSomething" |
| 208 | parent_session.config["postDebugTask"] = "doSomethingElse" |
| 209 | if subProcess is not None: |
| 210 | parent_session.config["subProcess"] = subProcess |
| 211 | |
| 212 | with run(parent_session, target(parent, args=[child])): |
| 213 | pass |
| 214 | |
| 215 | if subProcess is False: |
| 216 | return |
| 217 | |
| 218 | expected_child_config = expected_subprocess_config(parent_session) |
| 219 | |
| 220 | if method == "startDebugging": |
| 221 | subprocess_request = parent_session.timeline.wait_for_next(timeline.Request("startDebugging")) |
| 222 | child_config = subprocess_request.arguments("configuration", dict) |
| 223 | del expected_child_config["request"] |
| 224 | else: |
| 225 | child_config = parent_session.wait_for_next_event("debugpyAttach") |
nothing calls this directly
no test coverage detected
searching dependent graphs…