Repository navigation
feat(pytest_test): stop adding pytest-shard and pytest-randomly by default - #4529
Merged
rickeylev merged 6 commits intoNov 21, 2026
Merged
Conversation
aignas
marked this pull request as draft
November 18, 2026 15:17
pytest_test was released with the `pytest_shard` and `pytest_randomly` args, so removing them would break the BUILD files that set them. Keep both: they add the target to the `deps` when set. `pytest_shard` is deprecated, as pytest-bazel 1.0 shards the tests itself, and `pytest_randomly` is now optional. Document what pytest-bazel does, add a news entry and use pytest-bazel 1.0.0rc1, which fixes the rootdir when the test files are passed as args without the sandbox.
pytest_test and pytest-bazel were only described in the API docs. Add a page on how to set up and use pytest_test, which links to the pytest-bazel docs for its features and flags.
Collaborator
Author
|
This PR was prepared with an AI coding agent (Claude Code) working on behalf of @aignas, who directed the work and owns the changes. The agent does not monitor this PR: @aignas reads and answers review comments, and may use the agent to make the requested changes. This is an automatically generated agent comment. |
aignas
marked this pull request as ready for review
November 19, 2026 15:19
rickeylev
approved these changes
Nov 21, 2026
| | Test timeouts | Prints the stacks of all threads, and of the `pytest-xdist` workers, when Bazel stops the test. | [Timeout][timeout], [xdist][xdist] | | ||
| | `bazel-testlogs` | Writes the JUnit XML with the output of failed tests, keeps the `tmp_path` of failed tests in `test.outputs` and writes the warnings to `test.warnings`. | [JUnit XML][junit-xml], [Keep failed tmp_path][keep-failed-tmp-path], [Warnings][warnings] | | ||
| | `TEST_TMPDIR` | Points `TMPDIR` and pytest's `tmp_path` at it, so tests do not write outside the sandbox. | [Temporary directories][tmpdir] | | ||
| | `bazel run` | Debug a test with `bazel run //pkg:test -- --pdb`, as `bazel test` gives tests no terminal. | [Debugging][debugging] | |
Collaborator
There was a problem hiding this comment.
I think there's a bazel issue filed about this. The underlying cause is some fancy shell bazel does for other reasons, wich ends up breaking the standard streams for interactive console debugging.
rickeylev
reviewed
Nov 21, 2026
…ests Consumers supply @pypi//pytest_bazel from their own lockfile, where versions below 0.3.0 fail on sharded tests without pytest-shard and versions below 1.0 lack the documented defaults, while inline deps handling duplicated //python:none labels and added pytest_shard on unsharded targets. Normalize and deduplicate plugin deps once in pytest_test, document the minimum pytest-bazel versions and /pytest link, relax the dev lockfile pin to >=1.0.0, and add analysis_test coverage for default and opt-in deps.
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.
pytest_test added pytest-shard and pytest-randomly to the deps of every
test, so users had to add both to their requirements even when they did
not want a random test order. pytest-bazel 1.0 shards the tests itself
and seeds pytest-randomly only when it is installed, so neither plugin
is needed any more.
Stop adding them by default. The
pytest_shardandpytest_randomlyargs stay for compatibility:
pytest_shardis deprecated andpytest_randomlyopts into a random test order. Use pytest-bazel 1.0.0for the tests of rules_python.
Also add a "Testing with pytest" docs page on how to set up
pytest_test, with the main features of pytest-bazel and links to its
docs.
Fixes #4251