Title: Debugging unittest tests silently reports "skipped" when `-s` points at a subdirectory · Issue #26155 · microsoft/vscode-python · GitHub
Open Graph Title: Debugging unittest tests silently reports "skipped" when `-s` points at a subdirectory · Issue #26155 · microsoft/vscode-python
X Title: Debugging unittest tests silently reports "skipped" when `-s` points at a subdirectory · Issue #26155 · microsoft/vscode-python
Description: Type: Bug (apologies if this should be in the debugger extenions issues, raising here as it appeared to originate in the python extensions code) Behaviour With python tests configured to use unittest and settings a custom --start-directo...
Open Graph Description: Type: Bug (apologies if this should be in the debugger extenions issues, raising here as it appeared to originate in the python extensions code) Behaviour With python tests configured to use unitte...
X Description: Type: Bug (apologies if this should be in the debugger extenions issues, raising here as it appeared to originate in the python extensions code) Behaviour With python tests configured to use unitte...
Opengraph URL: https://github.com/microsoft/vscode-python/issues/26155
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Debugging unittest tests silently reports \"skipped\" when `-s` points at a subdirectory","articleBody":"\nType: \u003cb>Bug\u003c/b>\n\n(apologies if this should be in the debugger extenions issues, raising here as it appeared to originate in the python extensions code)\n\n# Behaviour\n\nWith python tests configured to use unittest and settings a custom `--start-directory` set to a sub dir (rather than just `'.'`) I found that RUNNING tests from the GUI works fine, but DEBUGGING them does not. For the latter tests just report as skipped, and the results pannel reads \"The test case did not report any output.\". \n\nTest discovery itself is unaffected - the test tree is populated correctly & running tests works. It is only debug *execution* that fails.\n\nThe `Python` output channel shows the run path completing normally and the debug path\ntearing down its results pipe without ever receiving data:\n\n```\nRUN 12:04:20.034 Running unittest with arguments: ...execution.py --udiscovery -v -s ./test -p test_*.py\n 12:04:24.099 Test Result named pipe ... received data \u003c- works\n\nDEBUG 12:04:30.381 Running DEBUG unittest ... execution.py,--udiscovery,-v,-s,./test,-p,test_*.py\n 12:04:40.428 [test-debug] Debug session started: Debug Tests: python (599b91eb...)\n 12:04:43.532 [test-debug] Debug session terminated: (599b91eb...)\n 12:04:43.532 Test Result named pipe ... cancelled \u003c- no data\n```\n\n## Steps to reproduce:\n\n1. A project whose tests live in an importable package below the workspace root, eg\n `test/__init__.py`, `test/core/__init__.py`, `test/core/test_thing.py`.\n2. `.vscode/settings.json`:\n ```json\n {\n \"python.testing.unittestEnabled\": true,\n \"python.testing.pytestEnabled\": false,\n \"python.testing.unittestArgs\": [\"-v\", \"-s\", \"./test\", \"-p\", \"test_*.py\"]\n }\n ```\n3. Discover tests, then pick any test and **Debug Test**.\n4. The test reports as \"skipped\"; no output anywhere. **Run Test** on the same test works.\n\nNot reproducible when `-s` is omitted or is `.`. My AI reckons this means #26033 may be related.\n\n## Workaround\n\nAdd `-t .` (aka `--top-level-directory .`) to `python.testing.unittestArgs` and refresh test discovery.\n\n```json\n\"python.testing.unittestArgs\": [\"-v\", \"-s\", \"./test\", \"-t\", \".\", \"-p\", \"test_*.py\"]\n```\n\n## AI identified potential cause & solution:\n\nI got my AI to poke around in order to find the workaround above, during which it believes it's identified the issue and a potential fix, i've included them in case they're useful. Apologies if they're just noise - it looks sensible to me but I'm not familiar enough with the details to know.\n\n\u003cdetails>\n\u003csummary>AI output\u003c/summary>\n\u003cp>\n\n### 1. The debug launch config never receives `PROJECT_ROOT_PATH`\n\nThe unittest **execution** adapter sets `PYTHONPATH`, `TEST_RUN_PIPE` and\n`PROJECT_ROOT_PATH` for the run path. The **debug** path, in `convertConfigToArgs`\n(inferred to be `src/client/testing/common/debugLauncher.ts`; quoted from the shipped\n`out/client/extension.js`, beautified), injects only two of them:\n\n```js\np.env = {\n ...p.env,\n TEST_RUN_PIPE: n.pytestPort,\n RUN_TEST_IDS_PIPE: n.runTestIdsPort\n};\nconst d = u.join(h.EXTENSION_ROOT_DIR, \"python_files\");\nif (p.env) {\n const e = [d];\n p.cwd ? e.push(p.cwd) : n.cwd && e.push(n.cwd), (0, T.addPathToPythonpath)(e, p.env.PYTHONPATH)\n}\n```\n\nTwo defects here:\n\n* `PROJECT_ROOT_PATH` is never added.\n* `addPathToPythonpath(...)` is a pure function that *returns* the joined path, but its\n return value is discarded, so `PYTHONPATH` is never set either.\n\nOnly the first causes the symptom reported here. `execution.py` inserts the resolved cwd\nonto `sys.path` itself (L213-217), so imports still resolve without `PYTHONPATH`.\n\nVerified by reading the resolved `LaunchRequest` from a debugpy log\n(`DEBUGPY_LOG_DIR`): the debuggee's `env` contains `RUN_TEST_IDS_PIPE` and\n`TEST_RUN_PIPE` but neither `PROJECT_ROOT_PATH` nor `PYTHONPATH`. Confirmed across\nthree separate debug sessions.\n\n### 2. Discovery and execution then disagree on `top_level_dir`\n\n`python_files/unittestadapter/discovery.py` (L144-150) overrides `top_level_dir` with\n`PROJECT_ROOT_PATH`:\n\n```python\nproject_root_path = os.environ.get(\"PROJECT_ROOT_PATH\")\nif project_root_path:\n top_level_dir = project_root_path\n```\n\n`python_files/unittestadapter/execution.py` does not - it uses `-t` (default `None`, per\n`pvsc_utils.parse_unittest_args`) and additionally replaces `start_dir` with the resolved\ncwd:\n\n```python\ncwd = os.path.abspath(project_root_path or start_dir)\n...\nstart_dir = cwd\nsuite = loader.discover(start_dir, pattern, top_level_dir)\n```\n\nSo for `-s ./test` with no `-t`:\n\n| phase | `PROJECT_ROOT_PATH` | discovery root | resulting test id |\n|---|---|---|---|\n| discovery | set | workspace | `test.core.test_thing.TestThing.test_x` |\n| execution (run) | set | workspace | `test.core.test_thing.TestThing.test_x` |\n| execution (debug) | **absent** | `\u003cworkspace>/test` | `core.test_thing.TestThing.test_x` |\n\n### 3. A mismatch produces silence rather than an error\n\n`execution.py`'s `filter_tests` matches on exact `test.id()` strings, and results are\nstreamed per test via `UnittestTestResult` -> `send_run_data` -> `send_post_request`. An\nempty filtered suite therefore sends *nothing at all*, which is why the results pipe is\ncancelled with no data and the test renders as \"skipped\" rather than as an error.\n\n### 4. Why it is undiagnosable from the UI\n\nThe auto-generated test debug configuration resolves to `console: internalConsole` with\n`debugOptions: [\"Multiprocess\", \"FixFilePathCase\", \"ShowReturnValue\"]` and **no**\n`RedirectOutput`, so the adapter's stdout and stderr are discarded. Nothing appears in\nthe Debug Console, Terminal or Test Results. Adding `\"redirectOutput\": true` to a\n`launch.json` config with `\"purpose\": [\"debug-test\"]` restores output.\n\n\n## Suggested fix\n\n1. Propagate `PROJECT_ROOT_PATH` into the debug configuration's `env` alongside\n `TEST_RUN_PIPE`/`RUN_TEST_IDS_PIPE`.\n2. Assign the result of `addPathToPythonpath(...)` back to `p.env.PYTHONPATH`.\n3. Consider having `execution.py` honour `PROJECT_ROOT_PATH` as `top_level_dir` the way\n `discovery.py` does, so the two phases cannot disagree regardless of how the process\n is launched.\n4. Consider defaulting `redirectOutput` to `true` for test debug sessions - the silence\n is what made this expensive to diagnose.\n\nNote that (3) interacts with #26033, which is the opposite manifestation of the same\n`PROJECT_ROOT_PATH`/`-t` coupling introduced by #25780: there, `PROJECT_ROOT_PATH`\noverriding `-t` breaks discovery when the start directory is not importable from the\nworkspace root. A fix should probably reconcile both - honour an explicit `-t` when\ngiven, and otherwise apply `PROJECT_ROOT_PATH` consistently in *both* phases and *both*\nlaunch paths.\n\n\u003c/p>\n\u003c/details>\n\n## Application info:\n\nExtension version: 2026.4.0\nVS Code version: Code 1.113.0 (cfbea10c5ffb233ea9177d34726e6056e89913dc, 2026-03-24T15:07:18+01:00)\nOS version: Windows_NT x64 10.0.26100\n\n- Python version: 3.13.11\n- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): venv\n- Value of the `python.languageServer` setting: Default\n\n\u003cdetails>\n\u003csummary>User Settings\u003c/summary>\n\u003cp>\n\n```\n\nlanguageServer: \"Pylance\"\n\ntesting\n• unittestArgs: [\"-v\", \"-s\", \"./test\", \"-p\", \"test_*.py\"]\n• unittestEnabled: true\n\n```\n\u003c/p>\n\u003c/details>\n\n\u003cdetails>\n\u003csummary>Installed Extensions\u003c/summary>\n\n|Extension Name|Extension Id|Version|\n|---|---|---|\n|cmake-tools|ms-|1.23.52|\n|code-spell-checker|str|4.5.6|\n|code-spell-checker-cspell-bundled-dictionaries|str|2.0.14|\n|cpp-devtools|ms-|0.5.13|\n|cpptools|ms-|1.32.2|\n|cpptools-extension-pack|ms-|1.5.1|\n|cpptools-themes|ms-|2.0.0|\n|debugpy|ms-|2026.6.0|\n|even-better-toml|tam|0.21.2|\n|js-debug|ms-|1.112.0|\n|js-debug-companion|ms-|1.1.3|\n|jupyter|ms-|2025.9.1|\n|jupyter-keymap|ms-|1.1.2|\n|jupyter-renderers|ms-|1.3.0|\n|markdown-mermaid|bie|1.32.1|\n|python|ms-|2026.4.0|\n|remote-explorer|ms-|0.5.0|\n|remote-ssh|ms-|0.124.0|\n|remote-ssh-edit|ms-|0.87.0|\n|ruff|cha|2026.60.0|\n|vscode-clangd|llv|0.6.0|\n|vscode-js-profile-table|ms-|1.0.10|\n|vscode-jupyter-cell-tags|ms-|0.1.9|\n|vscode-jupyter-slideshow|ms-|0.1.6|\n|vscode-pylance|ms-|2026.2.1|\n|vscode-python-envs|ms-|1.36.0|\n|vscode-xml|red|0.29.3|\n\u003c/details>\n\n\u003c!-- generated by issue reporter -->","author":{"url":"https://github.com/j-hil-nwm","@type":"Person","name":"j-hil-nwm"},"datePublished":"2026-09-17T13:56:38Z","url":"https://github.com/microsoft/vscode-python/issues/26155"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6c14e6cf-c324-e243-b51c-cd20d58fe218 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED1E:24F1E7:12598B:1ACAF2:6AFD70BB |
| html-safe-nonce | c33502790ad0cfb26754a92c4ff66007f225b3b93ca907214e37119091ea0609 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDFFOjI0RjFFNzoxMjU5OEI6MUFDQUYyOjZBRkQ3MEJCIiwidmlzaXRvcl9pZCI6IjY4NDcwMTA3NTU5NzIwMDE5NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c5563f0adea12b3c8d4db1c45dba30c98f67199519147866690a3d7428de3cc2 |
| hovercard-subject-tag | issue:5488339005 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/vscode-python/26155/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2c599829afc640d2b7b9b86f0e71a134747159c43b208e040c933f5243cf89ac/microsoft/vscode-python/issues/26155 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2c599829afc640d2b7b9b86f0e71a134747159c43b208e040c933f5243cf89ac/microsoft/vscode-python/issues/26155 |
| og:image:alt | Type: Bug (apologies if this should be in the debugger extenions issues, raising here as it appeared to originate in the python extensions code) Behaviour With python tests configured to use unitte... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | j-hil-nwm |
| hostname | github.com |
| expected-hostname | github.com |
| None | e54006cf2b96d1ac260960edd10003132911469ccd1ec99c9803119fe2a4e032 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/vscode-python git https://github.com/microsoft/vscode-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 106462765 |
| octolytics-dimension-repository_nwo | microsoft/vscode-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 49946255 |
| octolytics-dimension-repository_parent_nwo | DonJayamanne/pythonVSCode |
| octolytics-dimension-repository_network_root_id | 49946255 |
| octolytics-dimension-repository_network_root_nwo | DonJayamanne/pythonVSCode |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5be0bf2b8cf26f8897d31e6bc3c232d328b12a54 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width