pytest-xdist icon indicating copy to clipboard operation
pytest-xdist copied to clipboard

Bug: -n Auto fails when run in WSL/VSCode Dev Container as part of pyproject.toml

Open ADataGMan opened this issue 1 year ago • 2 comments

I am working in WSL 2 in a VSCode Devcontainer, and when I run pytest-xdist with -n AUTO as part of pyproject.toml it fails with:

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument -n/--numprocesses: invalid parse_numprocesses value: ' AUTO'

If I pass in an explicit number it runs fine. If I run from the command line pytest -n auto or poetry run pytest -n auto it runs just fine.

pyproject.toml

[tool.poetry.dependencies]
python = "^3.12"

[tool.poetry.group.dev.dependencies]
coverage = "^7.3.2"
ipykernel = "^6.26.0"
pyright = "^1.1.338"
Sphinx = "^7.2.6"
pytest-cov = "^4.1.0"
pytest-html = "^4.1.1"
pytest-xdist = "^3.5.0"

[tool.pytest.ini_options]
addopts = [
    "-n AUTO", # IF I comment out this line and add it to my own arguments it runs fine. IF I say -n 4 it runs fine.
    "--cov=/workspaces/coh/src/coh",
    "--cov-report=html",
    "--self-contained-html",
    "--html=/workspaces/coh/documentation/generated_reports/tests/test_result.html",
    "--cache-clear",
]

My kernel details I believe are:

Debian GNU/Linux 11 (bullseye) 
WSL 5.10.102.1-microsoft-standard-WSL2

ADataGMan avatar Dec 31 '23 07:12 ADataGMan

Taking a look at both the documentation and the code, I think "-n AUTO" needs to be lowercase "-n auto", the code won't enter into the 'auto' branch of logic otherwise.

I would assume if you run pytest -n AUTO on the commandline, it would also bork.

james-certn avatar Jan 25 '24 21:01 james-certn

closing as user error - it needs to be "-n", "auto" or "--numprocesses=auto"

RonnyPfannschmidt avatar Jan 26 '24 10:01 RonnyPfannschmidt