-
-
Notifications
You must be signed in to change notification settings - Fork 713
test(pytest): support python_versions in pytest_test macro #4064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rickeylev
merged 5 commits into
bazel-contrib:main
from
rickeylev:add_pytest_multiversion_support
Aug 17, 2026
+140
−2
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
808f896
test(pytest): add pytest_multipy_test macro for multi-version testing
rickeylev 24ad895
test(pytest): update pytest_multipy_test to test Python 3.14 and 3.13
rickeylev 4654775
Merge remote-tracking branch 'upstream/main' into add_pytest_multiver…
rickeylev e4320d6
test(pytest): fold python_versions into pytest_test
rickeylev a68ab82
test(pytest): refactor pytest_test to use if-else with helper for pyt…
rickeylev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| """Tests for pytest_test.""" | ||
|
|
||
| load("@rules_testing//lib:test_suite.bzl", "test_suite") | ||
| load( | ||
| "//tests/support/pytest_test:pytest_test.bzl", | ||
| "get_version_test_name", | ||
| ) | ||
|
|
||
| _tests = [] | ||
|
|
||
| def _test_get_version_test_name(env): | ||
| want = { | ||
| ("foo_test", "3.14"): "foo_py3.14_test", | ||
| ("foo_test", "3.10"): "foo_py3.10_test", | ||
| ("foo_test", "py3.14"): "foo_py3.14_test", | ||
| ("foo_tests", "3.14"): "foo_py3.14_tests", | ||
| ("foo", "3.14"): "foo_py3.14", | ||
| ("test_foo", "3.14"): "test_foo_py3.14", | ||
| ("basic_test", "3.11"): "basic_py3.11_test", | ||
| ("pytest_default_test", "3.12"): "pytest_default_py3.12_test", | ||
| } | ||
|
|
||
| actual = { | ||
| (name, ver): get_version_test_name(name, ver) | ||
| for (name, ver) in want.keys() | ||
| } | ||
| env.expect.that_dict(actual).contains_exactly(want) | ||
|
|
||
| _tests.append(_test_get_version_test_name) | ||
|
|
||
| def pytest_test_test_suite(name): | ||
| """Create the test suite. | ||
|
|
||
| Args: | ||
| name: The name of the test suite. | ||
| """ | ||
| test_suite(name = name, basic_tests = _tests) |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this - it is quite important to have this sort of thing. Could we create
pytest_testmacro and acceptpython_versionorpython_versionsattributes which would do the underlying wiring by themselves?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually originally did that but wasn't sure if I liked it. Since it was also your first instinct, lets go with that.
I also remembered config_settings (because of bootstrap_impl tests) and thought: well, why not accept arbitrary settings?
And then the api looked like this:
Which, eh...
thoughts?