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

Unexpected error message when `--dist worksteal`, `-n0` and `--pdb` flags are all set.

Open superosku opened this issue 1 year ago • 1 comments

Pytest shows an unexpected error message with the following flags:

 $ py.test -n0 --pdb --dist worksteal
ERROR: --pdb is incompatible with distributing tests; try using -n0 or -nauto.

This is an issue for me since I have a pytest.ini set up like so:

[pytest]
addopts =
  -n auto --dist worksteal

This allows me to have it so that the default pytest run without parameters runs all of the test in parallel mode in the most efficient way.

But quite often I run just one test file and when doing so I would like for pytest to not use the parallel mode so I add the -n0 flag. This works as expected. I can also run pytest with just the --pdb flag, this automatically disables the parallelism as well.

But when I have both the --pdb and -n0 flags I get the error.

Everything works as expected when --dist worksteal is not there in the pytest.ini file but that can make the full parallel test suite run slower than it needs to be.

This is a big issue for me since I often run tests on single test file many times over and I alternate between running it with pdb and without. It would be much more convininent and faster if I could just add and remove the --pdb flag instead of alternating between the --pdb and -n0 flags.

Also I think the error message describes the issue poorly since I already have the -n0 flag on that is suggested by it.

Thanks

Pytest version:

py.test --version
pytest 7.4.3

Operating system version:

macOS 13.6.1 (22G313)
  • [x] a detailed description of the bug or problem you are having
  • [ ] output of pip list from the virtual environment you are using
  • [x] pytest and operating system versions
  • [x] minimal example if possible

superosku avatar Jan 04 '24 12:01 superosku

this is rooted in https://github.com/pytest-dev/pytest-xdist/blob/f5573149fd99702064f973833d3e8cd48ff169f1/src/xdist/plugin.py#L256-L278

it seeems like this edge-case is missed, moving the issue to xdist

RonnyPfannschmidt avatar Jan 04 '24 13:01 RonnyPfannschmidt