Testing - Test View for Python with multi-root workspace
See original GitHub issueRefs: #15750
- macOS @sandy081
- linux @roblourens
- windows @meganrogge
Complexity: 3
Requirements
- Install python extension from here: https://pvsc.blob.core.windows.net/extension-builds/ms-python-insiders.vsix
- Make sure you have
"python.experiments.optInto": ["All"],
in your user settings. If you did not have it, add it and reload.
Testing
- Open either this project https://github.com/karthiknadig/multiroot_pytest_sample or create a project layout similar to that.
- Create a virtual environment in the repo directory and install
pytest
.- Navigate to the repo directory in the terminal.
- Then use following commands to create virtual envs
- For windows, you can use this command
py -3 -m venv .venv
- For mac/linux you can use the command
python3 -m venv .venv
Note: For linux users you may not havevenv
available out of the box. Please installpython3-venv
via apt.
- For windows, you can use this command
- Activate the virtual environment:
- For windows : run the
activate
binary.\.venv\Scripts\activate
- For linux/mac (bash): run
source ./.venv/bin/activate
. Note: If you use other terminal shells there are scripts underScripts
orbin
directory that should work for your preferred shell.
- For windows : run the
- Once activated you should see the name of the env in the prompt. Run the following command to install
pytest
:python -m pip install pytest
- Activate the python extension and select the virtual environment that you just created. Depending on where you create the virtual environment it may or may not show up in the quick pick. But you can always browse to it and select it.
- If you created your own files, then configure each project root for testing using the
python: configure test
command. Otherwise you should see the tests in the test view. - Run the tests, add more files or test and see the Test UI update accordingly.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Multi-root Workspaces in Visual Studio Code
You can work with multiple project folders in Visual Studio Code with multi-root workspaces. This can be helpful when you are working on...
Read more >python - Use unit tests for a single project when I have multiple ...
python - Use unit tests for a single project when I have multiple project folders in explorer? - Stack Overflow. Stack Overflow for...
Read more >Visual Studio Code tips for monorepo development with Multi ...
A multi-root workspace is a feature in Visual Studio Code where you can have multiple root folders in one explorer view.
Read more >Configuring Project Structure | PyCharm Documentation
contain files and folders ignored by PyCharm when indexing, searching, parsing, watching, and so on. Test sources roots the Tests root icon ...
Read more >Advanced Visual Studio Code for Python Developers
This setup is really useful when writing unit tests with your test code on the ... of its extensions live within a .vscode/...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sandy081 That is not in the scope of this testing plan item. You can skip that.
You can re-select that python by running
Python: Select interpreter
command@roblourens that is a know issue #16170, #16613