pytestArgs: ["-n", "4"] not working for running tests in parallel with pytest-xdist
See original GitHub issueEasy fix is to change docs to have “-n 4” instead of two args, but I don’t understand why “-n”, “4” is not working.
Environment data
- VS Code version: 1.35.1
- Extension version (available under the Extensions sidebar): 2019.7.21668-dev
- OS and version: Windows 10
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.1
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
- Relevant/affected Python packages and their versions:
Expected behaviour
"python.testing.pytestArgs": ["-n 4"]
and "python.testing.pytestArgs": ["-n", "4"]
should have the same behaviour, shouldn’t it?
Actual behaviour
Having "python.testing.pytestArgs": ["-n", "4"]
in settings.json throws an error:
pytest.py: error: argument -n/--numprocesses: invalid parse_numprocesses value: '.\\testing\\python\\approx.py'
and approx.py is the file from which I tried to execute the tests.
Steps to reproduce:
- Clone pytest repo
- Install dependencies if needed. Make sure pytest-xdist is installed
- Configure tests in the extension to use pytest framework and add
"python.testing.pytestArgs": ["-n", "4"]
to settings.json file - Open the test explorer
- Discover tests works
- Run all tests works
- Run an individual test file and watch the “There was an error in running the tests” prompt appear
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
=========================== short test summary info ===========================
FAILED testing/logging/test_formatter.py::test_colored_short_level - Assertio...
===================== 1 failed, 2 passed in 0.98 seconds ======================
Error: Error: cannot open file:///c%3A/Users/luabud/pytest/c. Detail: Unable to read file (Error: File not found (c:\Users\luabud\pytest\c))
Test Discovery failed:
TypeError: i.startsWith is not a function
Test Discovery failed:
TypeError: i.startsWith is not a function
python C:\Users\luabud\.vscode\extensions\ms-python.python-2019.7.21668-dev\pythonFiles\testing_tools\run_adapter.py discover pytest -- -s --cache-clear -n 4
ERROR: usage: pytest.py [options] [file_or_dir] [file_or_dir] [...]
pytest.py: error: argument -n/--numprocesses: invalid parse_numprocesses value: '.\\testing\\python\\approx.py'
Error: TypeError: Cannot read property 'testsuite' of null
Test Discovery failed:
TypeError: i.startsWith is not a function
Test Discovery failed:
TypeError: i.startsWith is not a function
Test Discovery failed:
TypeError: i.startsWith is not a function
python C:\Users\luabud\.vscode\extensions\ms-python.python-2019.7.21668-dev\pythonFiles\testing_tools\run_adapter.py discover pytest -- -s --cache-clear -n 4
ERROR: usage: pytest.py [options] [file_or_dir] [file_or_dir] [...]
pytest.py: error: argument -n/--numprocesses: invalid parse_numprocesses value: '.\\testing\\python\\integration.py'
Error: TypeError: Cannot read property 'testsuite' of null
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
pytest run tests parallel - python - Stack Overflow
I want to run all my pytest tests in parallel instead of sequentially. my current setup looks like: class Test1(OtherClass): @pytest. mark.
Read more >Testing Python in Visual Studio Code
Support for running tests in parallel with pytest is available through the pytest-xdist package. To enable parallel testing: Open the integrated terminal and...
Read more >test - Pants build
Benefit of Pants: runs each file in parallel. Each file gets run as a separate process, which gives you fine-grained caching and better...
Read more >Pytest - Run Tests in Parallel - Tutorialspoint
Pytest - Run Tests in Parallel, By default, pytest runs tests in sequential order. In a real scenario, a test suite will have...
Read more >Changelog — pytest documentation
This solves some issues with tests that involve pytest environment variables. ... properly when multiple instances of pytest are running in parallel.
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
Validated
I’m not sure we understand the problem yet. Passing the file last should work fine. If there’s a pytest bug then we a workaround is fine as long as we file an upstream bug and document the workaround.