Title: pytest.HIDDEN_PARAM Causes Discovery Failure · Issue #25795 · microsoft/vscode-python · GitHub
Open Graph Title: pytest.HIDDEN_PARAM Causes Discovery Failure · Issue #25795 · microsoft/vscode-python
X Title: pytest.HIDDEN_PARAM Causes Discovery Failure · Issue #25795 · microsoft/vscode-python
Description: Type: Bug Using pytest.HIDDEN_PARAM in parametrized tests causes pytest discovery to fail with a ValueError in the VS Code Python extension's test discovery mechanism. Steps to reproduce: Create a test file with a parametrized test using...
Open Graph Description: Type: Bug Using pytest.HIDDEN_PARAM in parametrized tests causes pytest discovery to fail with a ValueError in the VS Code Python extension's test discovery mechanism. Steps to reproduce: Create a ...
X Description: Type: Bug Using pytest.HIDDEN_PARAM in parametrized tests causes pytest discovery to fail with a ValueError in the VS Code Python extension's test discovery mechanism. Steps to reproduce: Creat...
Opengraph URL: https://github.com/microsoft/vscode-python/issues/25795
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pytest.HIDDEN_PARAM Causes Discovery Failure","articleBody":"\nType: \u003cb>Bug\u003c/b>\n\n\u003c!-- Please fill in all XXX markers -->\nUsing `pytest.HIDDEN_PARAM` in parametrized tests causes pytest discovery to fail with a `ValueError` in the VS Code Python extension's test discovery mechanism.\n\n## Steps to reproduce:\n\n1. Create a test file with a parametrized test using `pytest.HIDDEN_PARAM`:\n\n```python\nimport pytest\n\n@pytest.mark.parametrize(\"setup\", [pytest.param(\"setup\", id=pytest.HIDDEN_PARAM)])\ndef test_main(setup) -> None:\n assert True\n```\n\n2. Open the file in VS Code with the Python extension enabled\n3. Observe that pytest discovery fails\n\n\u003c!--\n**After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation.\n-->\n\n\u003c!-- **NOTE**: Please do provide logs from Python Output panel. -->\n# Diagnostic data\n\n\u003cdetails>\n\n\u003csummary>Output for \u003ccode>Python\u003c/code> in the \u003ccode>Output\u003c/code> panel (\u003ccode>View\u003c/code>→\u003ccode>Output\u003c/code>, change the drop-down the upper-right of the \u003ccode>Output\u003c/code> panel to \u003ccode>Python\u003c/code>)\n\u003c/summary>\n\n\u003cp>\n\n```\npytest test discovery error for workspace: /tmp/test_pytest \n Error Occurred, traceback: Traceback (most recent call last):\n File \"/home/tobi/.vscode-server/extensions/ms-python.python-2026.0.0/python_files/vscode_pytest/__init__.py\", line 428, in pytest_sessionfinish\n session_node: TestNode | None = build_test_tree(session)\n ~~~~~~~~~~~~~~~^^^^^^^^^\n File \"/home/tobi/.vscode-server/extensions/ms-python.python-2026.0.0/python_files/vscode_pytest/__init__.py\", line 691, in build_test_tree\n test_node = process_parameterized_test(\n test_case, test_node, function_nodes_dict, file_nodes_dict\n )\n File \"/home/tobi/.vscode-server/extensions/ms-python.python-2026.0.0/python_files/vscode_pytest/__init__.py\", line 617, in process_parameterized_test\n parent_part, parameterized_section = test_node[\"name\"].split(\"[\", 1)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nValueError: not enough values to unpack (expected 2, got 1)\n```\n\n\u003c/p>\n\u003c/details>\n\n\nExtension version: 2026.0.0\nVS Code version: Code 1.109.3 (b6a47e94e326b5c209d118cf0f994d6065585705, 2026-02-12T17:54:48.470Z)\nOS version: Windows_NT x64 10.0.26200\nModes:\nRemote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2\nRemote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2\nRemote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2\n\n- Python version (& distribution if applicable, e.g. Anaconda): 3.11.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• pytestArgs: \"\u003cplaceholder>\"\n• pytestEnabled: true\n• unittestArgs: \"\u003cplaceholder>\"\n\nexperiments\n• optInto: [\"pythonTestAdapter\"]\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|ansible|red|26.1.3|\n|auto-commit-msg|Mic|0.27.2|\n|autodocstring|njp|0.6.1|\n|change-case|wma|1.0.0|\n|code-spell-checker|str|4.5.6|\n|color-highlight|nau|2.8.0|\n|copilot-chat|Git|0.37.6|\n|debugpy|ms-|2025.18.0|\n|direnv|mkh|0.17.0|\n|djlint|mon|2025.11.0|\n|EditorConfig|Edi|0.18.1|\n|even-better-toml|tam|0.21.2|\n|gitignore|cod|0.10.0|\n|gitlab-workflow|Git|6.69.3|\n|gitlens|eam|17.10.0|\n|gitlink|qez|1.2.6|\n|go|gol|0.52.2|\n|isort|ms-|2025.0.0|\n|jinjahtml|sam|0.20.0|\n|js-debug|ms-|1.105.0|\n|jupyter|ms-|2025.9.1|\n|jupyter-renderers|ms-|1.3.0|\n|live-server|ms-|0.4.17|\n|markdown-all-in-one|yzh|3.6.3|\n|markdown-pdf|yza|1.5.0|\n|markdowntable|Tak|0.13.0|\n|marp-vscode|mar|3.3.0|\n|mypy-type-checker|ms-|2025.2.0|\n|oxc-vscode|oxc|1.45.0|\n|pdminterpreter|Kal|0.0.5|\n|plantuml|jeb|2.18.1|\n|prettier-vscode|esb|12.3.0|\n|python|ms-|2026.0.0|\n|ruff|cha|2026.36.0|\n|shellcheck|tim|0.38.6|\n|tfsec|tfs|1.11.0|\n|unique-window-colors|stu|1.0.51|\n|vscode-containers|ms-|2.4.1|\n|vscode-conventional-commits|viv|1.27.0|\n|vscode-coverage-gutters|rya|2.14.0|\n|vscode-django|bat|1.15.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-opentofu|ope|0.6.0|\n|vscode-pylance|ms-|2025.10.4|\n|vscode-python-envs|ms-|1.16.0|\n|vscode-stylelint|sty|2.0.2|\n|vscode-wakatime|Wak|25.5.1|\n|vscode-yaml|red|1.19.1|\n|vsliveshare|ms-|1.0.5959|\n\u003c/details>\n\u003cdetails>\n\u003csummary>System Info\u003c/summary>\n\n|Item|Value|\n|---|---|\n|CPUs|Intel(R) Core(TM) Ultra 7 165U (14 x 2688)|\n|GPU Status|2d_canvas: enabled\u003cbr>GPU0: VENDOR= 0x8086, DEVICE=0x7d45 [Intel(R) Graphics], DRIVER_VENDOR=Intel, DRIVER_VERSION=32.0.101.7026 *ACTIVE*\u003cbr>GPU1: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.7309\u003cbr>Machine model name: \u003cbr>Machine model version: \u003cbr>direct_rendering_display_compositor: disabled_off_ok\u003cbr>gpu_compositing: enabled\u003cbr>multiple_raster_threads: enabled_on\u003cbr>opengl: enabled_on\u003cbr>rasterization: enabled\u003cbr>raw_draw: disabled_off_ok\u003cbr>skia_graphite: disabled_off\u003cbr>trees_in_viz: disabled_off\u003cbr>video_decode: enabled\u003cbr>video_encode: enabled\u003cbr>webgl: enabled\u003cbr>webgl2: enabled\u003cbr>webgpu: enabled\u003cbr>webnn: disabled_off|\n|Load (avg)|undefined|\n|Memory (System)|63.46GB (35.34GB free)|\n|Process Argv|--folder-uri=vscode-remote://wsl+Ubuntu-24.04/home/tobi/projects/gitlab.energiekoppler.com/ek/software/ee-redispatch --remote=wsl+Ubuntu-24.04|\n|Screen Reader|yes|\n|VM|0%|\n\n|Item|Value|\n|---|---|\n|Remote|WSL: Ubuntu-24.04|\n|OS|Linux x64 5.15.153.1-microsoft-standard-WSL2|\n|CPUs|Intel(R) Core(TM) Ultra 7 165U (14 x 0)|\n|Memory (System)|31.08GB (18.75GB free)|\n|VM|0%|\n\n|Item|Value|\n|---|---|\n|Remote|WSL: Ubuntu-24.04|\n|OS|Linux x64 5.15.153.1-microsoft-standard-WSL2|\n|CPUs|Intel(R) Core(TM) Ultra 7 165U (14 x 0)|\n|Memory (System)|31.08GB (18.75GB free)|\n|VM|0%|\n\n|Item|Value|\n|---|---|\n|Remote|WSL: Ubuntu-24.04|\n|OS|Linux x64 5.15.153.1-microsoft-standard-WSL2|\n|CPUs|Intel(R) Core(TM) Ultra 7 165U (14 x 0)|\n|Memory (System)|31.08GB (18.83GB free)|\n|VM|0%|\n\u003c/details>\n\u003c!-- generated by issue reporter -->\n\n# Extended Info\n\n## Root Cause\n\nThe issue is in the `process_parameterized_test` function at line 617 of `vscode_pytest/__init__.py`:\n\n```python\nparent_part, parameterized_section = test_node[\"name\"].split(\"[\", 1)\n```\n\nThis code assumes that all parametrized tests have a `[` character in their name (e.g., `test_main[setup]`). However, when using `pytest.HIDDEN_PARAM`, pytest intentionally omits the parameter brackets from the test ID, resulting in just `test_main`.\n\nThe `.split(\"[\", 1)` call then returns a list with only one element (the test name without brackets), but the code tries to unpack it into two variables, causing the `ValueError`.\n\n## Suggested Fix\n\nThe `process_parameterized_test` function should check if the test name contains parameters before attempting to split:\n\n```python\nif \"[\" in test_node[\"name\"]:\n parent_part, parameterized_section = test_node[\"name\"].split(\"[\", 1)\n # Process parameterized test\nelse:\n # Handle test without visible parameters (e.g., HIDDEN_PARAM)\n parent_part = test_node[\"name\"]\n # Treat as non-parameterized or handle appropriately\n```\n\n## Additional Context\n\n- `pytest.HIDDEN_PARAM` is a documented pytest feature for hiding parameter values from test IDs\n- This is particularly useful for fixture setup that shouldn't be visible in test names\n- Command-line pytest handles this correctly; only VS Code discovery fails\n- Extension logs show `collected 1 item` before the error, suggesting pytest itself collected the test successfully\n\n## Workaround\n\nRemove the use of `pytest.HIDDEN_PARAM` and use a regular string ID instead:\n\n```python\n@pytest.mark.parametrize(\"setup\", [pytest.param(\"setup\", id=\"setup\")])\ndef test_main(setup) -> None:\n assert True\n```\n\nHowever, this defeats the purpose of `HIDDEN_PARAM` and creates visible parameter IDs.\n\n## References\n\n- pytest documentation on `HIDDEN_PARAM`: https://docs.pytest.org/en/stable/reference/reference.html#pytest.HIDDEN_PARAM\n","author":{"url":"https://github.com/tobias-westerheide","@type":"Person","name":"tobias-westerheide"},"datePublished":"2026-02-13T22:25:34Z","url":"https://github.com/microsoft/vscode-python/issues/25795"}
| 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:1e9253fc-9ff6-74bd-ad94-51afe240d9dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6EE:EA06E:E44B0A:12597C2:6B00F50C |
| html-safe-nonce | ab769b6e0e9972485a361eb6d3c65525bb4264c75b8876126b49629ef2aaeb2d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkVFOkVBMDZFOkU0NEIwQToxMjU5N0MyOjZCMDBGNTBDIiwidmlzaXRvcl9pZCI6IjUyMDI4MzIxOTM0MjM5OTYxNzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3e2159bdc67812d4f570aac5515d8ef4ba05e1bae91f64d5cc2e66378db95e5e |
| hovercard-subject-tag | issue:3939565789 |
| 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/25795/issue_layout |
| twitter:image | https://opengraph.githubassets.com/94dffe019b1cf4e9514752b3c6e204ea45111f5587a06316c9134a192b4e6c7c/microsoft/vscode-python/issues/25795 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/94dffe019b1cf4e9514752b3c6e204ea45111f5587a06316c9134a192b4e6c7c/microsoft/vscode-python/issues/25795 |
| og:image:alt | Type: Bug Using pytest.HIDDEN_PARAM in parametrized tests causes pytest discovery to fail with a ValueError in the VS Code Python extension's test discovery mechanism. Steps to reproduce: Create a ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tobias-westerheide |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width