The support for Multi‐Project Testing in VS Code alongside Multi-root Workspaces is great, but I believe there's one short coming when used in combination of devcontainers.
Currently, there's no way to prevent the Python extension from discovering all Python projects in a workspace, (or I haven't found one). Discovery is possible on the host because the extension is smart enough to use each project's own virtual environment. In a setup where each project gets its own devcontainer, resolving only the dependencies of that specific project, the extension will still try to collect tests from other projects and will fail because no environment is available for them.
I've created a demo repository demonstrating this: https://github.com/superlevure/vscode-python-tests-discovery-issue.
Happy path (non devcontainer workflow):
git clone git@github.com:superlevure/vscode-python-tests-discovery-issue.git
cd vscode-python-tests-discovery-issue/folder_a
uv sync
cd ../folder_b
uv sync
cd ..
code .
- "Open Workspace"
- Open
src/folder_a/tests/test_foo.py and src/folder_b/tests/test_foo.py
- Refresh Tests (in the Python extension testing side bar)
- It works \o/
Non happy path (devcontainer workflow):
git clone git@github.com:superlevure/vscode-python-tests-discovery-issue.git
cd vscode-python-tests-discovery-issue
code .
- "Open Workspace"
- "Dev Containers: Rebuild and Reopen in Container"
- Select
folder_a
- Open
src/folder_a/tests/test_foo.py
- Refresh Tests (in the Python extension testing side bar)
- The extension tries to collect tests from
folder_b, even though the current dev container has no environment for this project (it's specific to folder_a)
Ideally, we should be able to prevent the extension from trying to collect tests from anywhere else than folder_a using a setting set specifically in .devcontainer/folder_a/devcontainer.json.
Thank you!
The support for Multi‐Project Testing in VS Code alongside Multi-root Workspaces is great, but I believe there's one short coming when used in combination of devcontainers.
Currently, there's no way to prevent the Python extension from discovering all Python projects in a workspace, (or I haven't found one). Discovery is possible on the host because the extension is smart enough to use each project's own virtual environment. In a setup where each project gets its own devcontainer, resolving only the dependencies of that specific project, the extension will still try to collect tests from other projects and will fail because no environment is available for them.
I've created a demo repository demonstrating this: https://github.com/superlevure/vscode-python-tests-discovery-issue.
Happy path (non devcontainer workflow):
git clone git@github.com:superlevure/vscode-python-tests-discovery-issue.gitcd vscode-python-tests-discovery-issue/folder_auv synccd ../folder_buv synccd ..code .src/folder_a/tests/test_foo.pyandsrc/folder_b/tests/test_foo.pyNon happy path (devcontainer workflow):
git clone git@github.com:superlevure/vscode-python-tests-discovery-issue.gitcd vscode-python-tests-discovery-issuecode .folder_asrc/folder_a/tests/test_foo.pyfolder_b, even though the current dev container has no environment for this project (it's specific tofolder_a)Ideally, we should be able to prevent the extension from trying to collect tests from anywhere else than
folder_ausing a setting set specifically in.devcontainer/folder_a/devcontainer.json.Thank you!