gh-158146: Test keyword arguments to warnings.warn_explicit - #158147
Closed
seanabreau wants to merge 1 commit into
Closed
seanabreau wants to merge 1 commit into
seanabreau wants to merge 1 commit into
Conversation
Exercise each positional/keyword split with string messages and warning instances in both warnings implementations. Assisted-by: Codex:GPT-6
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
1 task
Member
|
Personally I think testing every combination of the arguments this way is a little too complex and implicit. Maybe testing the most meaningful combinations is a better choice? I'm not sure about this, so maybe we can wait for other reviewers' opinions. |
Member
|
Sorry, but I'm going to close this. We generally don't specifically test such things (it's usually covered implicitly by other tests), and this test seems a little overkill. |
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.
Closes #158146.
Test that
warnings.warn_explicit()accepts its four required parameters by position or keyword, for both string messages and warning instances. Placing the test inWarnTestsexercises the C and pure-Python implementations and verifies the emitted warning's message, category, filename, and line number.pytest's
Node.warn()relies on this calling convention. The test was prompted by RustPython #8814; CPython's existing behavior is unchanged.Validation on a macOS debug build of CPython main (
80f9aa0):CWarnTestsandPyWarnTestscases pass../python.exe -m test test_warnings: success, 199 tests run, 6 skipped../python.exe -m test test_warnings -m '*test_warn_explicit_keyword_args' -R 3:3: passes without leaks in the measured repetitions.make patchcheckand configured pre-commit checks pass. No NEWS entry is needed for a test-only change.The same test method also catches the original RustPython bug (eight failing keyword-call subtests) and passes with RustPython #8814 applied.
AI assistance: Codex prepared the test and PR description and ran validation.