Repository navigation
Let worker/controller helpers accept a Config and tolerate disabled xdist - #1398
Open
RonnyPfannschmidt wants to merge 2 commits into
Open
RonnyPfannschmidt wants to merge 2 commits into
RonnyPfannschmidt wants to merge 2 commits into
Conversation
…dist is_xdist_worker, is_xdist_controller and get_xdist_worker_id now accept a pytest.Config in addition to a request or session, so plugins can use them from config-only hooks like pytest_configure. is_xdist_controller returns False instead of raising when xdist is disabled with -p no:xdist. Fixes #1397 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Gif5hXSqzpuBiMBEFT8j9
…ure on Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Gif5hXSqzpuBiMBEFT8j9
RonnyPfannschmidt
marked this pull request as ready for review
October 19, 2026 21:47
This branch has not been deployed
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.
Requested by Ronny · project thread
🤖 Written by Claude Opus 5.5 via Claude Code for the pytest-xdist maintainers; I prompted it, it did the work, I read it.
Fixes #1397. Follows the approach @MaciejZiel proposed in the issue.
Before:
is_xdist_worker,is_xdist_controllerandget_xdist_worker_idonly accepted a request or session, so passingconfigfrompytest_configure/pytest_terminal_summaryraisedAttributeError. With-p no:xdist,is_xdist_controller(session)raised becauseconfig.option.distdoes not exist.After: all three accept a
pytest.Configtoo, andis_xdist_controllerreturnsFalsewhen thedistoption is missing.How: a small
_get_config()helper returnsobj.configwhen present, else the object itself (duck-typed, so existing fake request objects keep working).is_xdist_controllerreadsdistwith a"no"default. Its docstring now notes that the result is only reliable frompytest_configureon: earlier hooks (e.g. another plugin's tryfirstpytest_cmdline_main) run before xdist turns-ninto a dist mode and getFalse. Docs gain a short example for config-only hooks and a note thathas_plugin("dsession")is not reliable beforepytest_sessionstart.TestAPI::test_helpers_accept_configruns a conftest with-n2,-n0, no-n, and-p no:xdist, checkingpytest_configure,pytest_sessionstartandpytest_terminal_summary; it fails on master and passes here.changelog/1397.feature.rst.