12

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?

Dhanush Prabhakar
  • 121
  • 1
  • 1
  • 5

2 Answers2

8

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

enter image description here

As hoefling mentioned, the solution is to install the pytest-xdist:

pip install pytest-xdist

Caridorc
  • 6,222
  • 2
  • 31
  • 46
Bowman Zhu-MSFT
  • 4,776
  • 1
  • 9
  • 10
1

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 :)

VivienG
  • 2,143
  • 3
  • 24
  • 43