kevlened / pytest-parallel

A pytest plugin for parallel and concurrent testing
https://github.com/browsertron/pytest-parallel/issues/104#issuecomment-1293941066
MIT License
313 stars 60 forks source link

--exitfirst pytest CLI option is being ignored #60

Open ethagnawl opened 4 years ago

ethagnawl commented 4 years ago

Given the following pytest.ini configuration file:

[pytest]
addopts = --exitfirst --log-cli-level=debug --workers auto

I see the following when running my test suite containing an unhandled exception.

# ...
tests/unit/test_foo.py::test_foo /home/appuser/app
PASSED                                                                                  
tests/unit/test_bar.py::test_bar /home/appuser/app
FAILED
tests/unit/test_baz.py::test_baz /home/appuser/app
PASSED
# ...
1 failed, 114 passed, 2 skipped, 9 warnings in 122.04s (0:02:02)

I've only used Python's Process API in very trivial ways, so the following may be wildly off the mark: I took a brief look at how the parallelization provided by this library works and I think you could achieve the standard pytest behavior by running a loop while the processes are in progress, checking their exitcodes and terminating all of the others (and closing the queue?) if any one returns a failure exitcode.

Is this something you'd consider doing? If so, I could try to put a PR together.

Either way, this library has been a tremendous productivity booster and reduced the run time of my test suite from ~11 minutes to ~2 minutes. So, thanks!