Reputation: 191
Hi I am trying to run my tests parallely(pytest-xdist) on the azure pipelines. Till now the tests were running perfectly fine. Suddenly the pytest is throwing a weird error saying "unrecognized argument".
The file name : integration_test.py Command used : pytest -n 5 --tb=short integration_test.py -v -s --> to run 5 tests parallely Total number of tests : 57 Versions : pytest==6.2.5 pytest-xdist==2.3.0 Even tried with the latest versions of these 2 modules.
Error : ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: -n integration_test.py
How can I overcome this error?
Upvotes: 19
Views: 34617
Reputation: 11
I encountered the same error while adding my own argument to pytest. The problem was that my conftest.py was not on /tests level in project, but in /tests/suites. Maybe it will help someone with similar problem.
Upvotes: 0
Reputation: 7176
This error is what you encountered:
Error : ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: -n integration_test.py
initfile: None
rootdir: C:\test
As hoefling mentioned, the solution is to install the pytest-xdist:
pip install pytest-xdist
Upvotes: 16
Reputation: 2180
On MacOS just running pytest
might be ran by a different Python's version than you thought.
$ pytest
============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.9.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: [REDACTED]
plugins: anyio-3.5.0, cov-3.0.0
While
$ python3 -m pytest
============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0
rootdir: [REDACTED]
plugins: xdist-2.5.0, forked-1.4.0, pylama-8.4.1
Be careful, and launch it as a module :)
Upvotes: 0