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

Make "-n 0" not error with "--dist" set

Open adamchainz opened this issue 4 years ago • 5 comments

I have this in my pytest.ini:

[pytest]
addopts = --numprocesses auto
          --dist loadscope

When I need to run with just one process, such as when I am just running a limited number of tests, using just -n 0 crashes:

$ pytest -n 0
...
platform darwin -- Python 3.9.1, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
...
ERROR: MISSING test execution (tx) nodes: please specify --tx

It would be great if -n 0 didn't need to worry about the dist mode.

This is similar to #549 which made --pdb imply --dist no alongside -n 0.

adamchainz avatar Mar 18 '21 13:03 adamchainz

I've had a look at this and it's not so easy - "--dist" is checked in many places as the authoritative flag whether to use multiple processes (or external environments), even though -n and --tx are more likely to represent what the user wants.

adamchainz avatar Mar 19 '21 15:03 adamchainz

Before this can be done easily, the configuration of the plugin will need a refactoring

RonnyPfannschmidt avatar Mar 19 '21 15:03 RonnyPfannschmidt

Seems to be fixed? Reproducible with pytest 7.0.1 + xdist 2.5.0, not reproducible with 7.2.1 + 3.1.0

prokudin79 avatar Jun 16 '23 10:06 prokudin79

Can confirm it seems to work with latest pytest and xdist.

kdeldycke avatar Jun 16 '23 10:06 kdeldycke

Let's verify that there's a test for this so we can close it,

RonnyPfannschmidt avatar Jun 16 '23 10:06 RonnyPfannschmidt