-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add related and details.rst to 'redundant-unittest-assert' style message's doc #6483
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
Changes from 1 commit
b170853
54e8a90
e73767a
9d90186
9234cdb
a82ce25
8263e52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Directly asserting a string literal will always pass. | ||
Directly asserting a string literal will always pass. The solution is to | ||
test something that could fail, or not assert at all. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,9 @@ | |
|
||
class DummyTestCase(unittest.TestCase): | ||
def test_dummy(self): | ||
actual = "test_result" | ||
self.assertEqual(actual, "expected") | ||
# Nothing, as an assert of a string literal will always pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually kind of like the current example. I think the comment works nicely in |
||
pass | ||
|
||
def test_division(): | ||
a = 9 / 3 | ||
assert a == 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- `Tests without assertion <https://stackoverflow.com/a/137418/2519059>`_ | ||
- `Testing that there is no error raised <https://stackoverflow.com/questions/20274987>`_ | ||
- `Parametrizing conditional raising <https://docs.pytest.org/en/latest/example/parametrize.html#parametrizing-conditional-raising>`_ |
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.
Why are we adding an example for another message here?
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 added an example expecting this code to raise a
[redundant-unittest-assert]
, but I think those two messages should be the same one. I think it can illustrate the two ways to fix the issue.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.
But this example is about
unittest
assertions, not normalassert
. I don't think we should merge those.