[flake8-pytest-style] Implement pytest.warns diagnostics (PT029, PT030, PT031)#15444
Merged
charliermarsh merged 4 commits intoastral-sh:mainfrom Jan 13, 2025
Merged
[flake8-pytest-style] Implement pytest.warns diagnostics (PT029, PT030, PT031)#15444charliermarsh merged 4 commits intoastral-sh:mainfrom
flake8-pytest-style] Implement pytest.warns diagnostics (PT029, PT030, PT031)#15444charliermarsh merged 4 commits intoastral-sh:mainfrom
Conversation
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PT031 | 144 | 144 | 0 | 0 | 0 |
| PT030 | 28 | 28 | 0 | 0 | 0 |
| PT029 | 10 | 10 | 0 | 0 | 0 |
charliermarsh
approved these changes
Jan 13, 2025
Member
charliermarsh
left a comment
There was a problem hiding this comment.
This looks great, thanks.
| /// with pytest.warns(MyWarning): | ||
| /// setup() | ||
| /// func_to_test() # not executed if `setup()` triggers `MyWarning` | ||
| /// assert foo() # not executed |
Member
There was a problem hiding this comment.
I couldn't figure out from the docs... Is this true? Does the block stop as soon as the warning is triggered? Or is this a copy-paste error from the raises variant.
Contributor
Author
There was a problem hiding this comment.
That comment was a copy error, apologies!
Member
There was a problem hiding this comment.
Are you able to PR a revision to the docs?
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.
Summary
Implements upstream diagnostics
PT029,PT030,PT031that function as pytest.warns corollaries ofPT010,PT011,PT012respectively. Most of the implementation and documentation is designed to mirror those existing diagnostics.Closes #14239
Test Plan
Tests for
PT029,PT030,PT031largely copied fromPT010,PT011,PT012respectively.cargo nextest run