Skip to content

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/data/messages/a/assert-on-string-literal/bad.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
def test():
assert "There is an AssertionError" # [assert-on-string-literal]
def test_division():
a = 9 / 3
assert "No ZeroDivisionError were raised" # [assert-on-string-literal]
5 changes: 4 additions & 1 deletion doc/data/messages/a/assert-on-string-literal/details.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
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.

For ``unittest`` assertions there is the similar :ref:`redundant-unittest-assert` message.
7 changes: 3 additions & 4 deletions doc/data/messages/a/assert-on-string-literal/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
def test():
result = "result"
expected = "expected"
assert result == expected
def test_division():
a = 9 / 3
assert a == 3
3 changes: 3 additions & 0 deletions doc/data/messages/a/assert-on-string-literal/related.rst
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>`_
4 changes: 4 additions & 0 deletions doc/data/messages/a/assert-on-tuple/details.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Directly asserting a non-empty tuple will always pass. The solution is to
test something that could fail, or not assert at all.

For ``unittest`` assertions there is the similar :ref:`redundant-unittest-assert` message.
5 changes: 4 additions & 1 deletion doc/data/messages/r/redundant-unittest-assert/details.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
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.

For assertions using ``assert`` there are similar messages: :ref:`assert-on-string-literal` and :ref:`assert-on-tuple`.
3 changes: 3 additions & 0 deletions doc/data/messages/r/redundant-unittest-assert/related.rst
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>`_