Identify correct test crashed during teardown and support multiple test logs from plugins #218
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While trying to fix #124, I realized the root of the problem was that xdist was trying to identify when a test was "done" on a worker by looking at the report from the
pytest_runtest_logreport
, but this is a problem because it is not entirely obvious when a test is actually "done".pytest_runtest_logreport
is called for all testing stages,setup
,call
andteardown
, and those stages are called or not depending on specific outcomes:setup
prevent'scall
andteardown
stages;call
will follow with ateardown
stage;And plugins might even affect that by implementing
pytest_runtest_protocol
themselves.So I figured the problem was trying to implicitly figure out if a test was done based on that information.
To solve this I created an explicit event "runtest_protocol_complete" which is sent by workers after
runtestprotocol
, this way we ensure that a worker is indeed "done" with an item.I also realized that this fixes #206 because we no longer use
pytest_runtest_logreport
to determine if a test is done, allowing plugins to issue multiplepytest_runtest_logreport
hooks if needed.I modified
pytest-rerunfailures
locally to skip its check ifxdist
is running, allowing it to log multiple times and it works well:I also executed
pytest
's test suite using this branch and it worked with no problems.cc @davehunt