Repository navigation
Pytest 9 no longer supports pytest-xdist run groups - #12715
Merged
Merged
Conversation
Contributor
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 25 files ± 0 25 suites ±0 6h 11m 40s ⏱️ - 40m 58s Results for commit 44005e2. ± Comparison against base commit b4cc5c5. This pull request removes 52 and adds 57 tests. Note that renamed tests count towards both.This pull request removes 9 skipped tests and adds 9 skipped tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
pytest 9 no longer applies the xdist_group marker: xdist's worker-side
pytest_collection_modifyitems gates on config.getvalue("loadgroup"),
which is not a registered option, so the @group nodeid suffix is never
appended and --dist loadgroup silently degrades to plain load balancing.
test_s3.py then runs concurrently across workers, all sharing one moto
server on port 5555 and one bucket named "test", which produces
NoSuchBucket / FileNotFoundError / "bucket not empty" errors and
cross-contaminated bucket contents.
Derive the moto port from PYTEST_XDIST_WORKER so that every worker owns
its own S3 state, and build endpoint_uri from it. The bucket name and
the tests are unchanged. Keep the xdist_group mark, which is still
correct (and still effective on pytest 8).
pytest 9 turned `Node.nodeid` into a read-only property backed by `self._id`,
so the `item._nodeid = f"{item.nodeid}@{group}"` assignment that pytest-xdist
performs in `remote.py` became a no-op. Under pytest 9, `--dist loadgroup` now
silently ignores `pytest.mark.xdist_group`, which makes every module that relies
on it run on several workers at once.
`test_s3.py` was already hardened against that by giving each worker its own
moto server, so its mark is now dead weight above the fixtures that actually
provide the isolation; drop it.
`test_http.py` was not: every worker started `http.server` on the hardcoded
port 8999, so the second worker to start one died with "Address already in
use" and every test in it failed with `ClientConnectorError` (reproduced with
pytest 9.2.0 / xdist 3.8.0: 8 passed, 1 failed with ConnectionRefused).
Derive the port from the worker id, like the s3 module does, and drop its mark
too.
Rather than copy the port helper into a second module, move it to
`dask.utils_test` as `xdist_worker_port()` and cover it with a unit test.
Also reap the `http.server` child on teardown: `terminate()` alone left it
running, which emitted a `Popen.__del__` ResourceWarning per worker and could
keep the port bound for the next run.
crusaderky
force-pushed
the
fix/s3-fixture-xdist
branch
from
November 12, 2026 17:15
44005e2 to
33ec806
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
dask/bytes/tests/test_s3.pyandtest_http.pydeclarebecause the modules are not concurrent-safe.
Under pytest 9, that mark is silently ignored.
Symptoms in the test job:
FileNotFoundError: The specified bucket does not exist,NoSuchBucket,OSError: [Errno 39] The bucket you tried to delete is not empty,_lzma.LZMAError, and wrong bucket contents.Fix it by making the fixtures worker-safe, so the module no longer relies on the
xdist_groupmark taking effect.