feat: warn about parametrization IDs that break -k selection - #14987
Open
royy92 wants to merge 1 commit into
Open
feat: warn about parametrization IDs that break -k selection#14987royy92 wants to merge 1 commit into
royy92 wants to merge 1 commit into
Conversation
Co-authored-by: ChatGPT <noreply@openai.com>
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.
What
Add a warning for custom parametrization IDs that cannot be safely used as part of a
-kidentifier.Also document guidance for choosing custom IDs that work with
-k.Why
Custom parametrization IDs can contain characters such as parentheses, commas, whitespace, or
=that have special meaning in-kexpressions.This can produce valid collected test IDs that cannot be selected directly with
-k, as reported in #6626.Following the discussion in #6626, this starts with warnings for custom IDs only. Built-in generated IDs are left unchanged for separate consideration.
How
Add
is_safe_identifier_part()using the existing-kexpression scanner to check whether a custom ID can be safely embedded in an identifier.Warn with
PytestWarningwhen a custom ID that prevents direct-kselection comes from:pytest.param(..., id=...).ids=[...].idscallable.pytest_make_parametrize_id.Built-in generated IDs are not warned about.
Test
Add coverage for:
pytest.paramIDs.ids=[...].pytest_make_parametrize_id.and,or,not, and an empty ID.The relevant test suites pass with 304 tests.
closes #XYZWto the PR description and/or commits (whereXYZWis the issue number). See the github docs for more information.Co-authored-bycommit trailers.changelogdirectory, with a name like<ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.AUTHORSin alphabetical order.