Skip to content

Commit 1dcb90a

Browse files
Add related and details.rst to 'redundant-unittest-assert' style message's doc (#6483)
Co-authored-by: Daniël van Noord <[email protected]>
1 parent 76b8538 commit 1dcb90a

File tree

7 files changed

+24
-8
lines changed

7 files changed

+24
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
def test():
2-
assert "There is an AssertionError" # [assert-on-string-literal]
1+
def test_division():
2+
a = 9 / 3
3+
assert "No ZeroDivisionError were raised" # [assert-on-string-literal]
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
Directly asserting a string literal will always pass.
1+
Directly asserting a string literal will always pass. The solution is to
2+
test something that could fail, or not assert at all.
3+
4+
For ``unittest`` assertions there is the similar :ref:`redundant-unittest-assert` message.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
def test():
2-
result = "result"
3-
expected = "expected"
4-
assert result == expected
1+
def test_division():
2+
a = 9 / 3
3+
assert a == 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- `Tests without assertion <https://stackoverflow.com/a/137418/2519059>`_
2+
- `Testing that there is no error raised <https://stackoverflow.com/questions/20274987>`_
3+
- `Parametrizing conditional raising <https://docs.pytest.org/en/latest/example/parametrize.html#parametrizing-conditional-raising>`_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Directly asserting a non-empty tuple will always pass. The solution is to
2+
test something that could fail, or not assert at all.
3+
4+
For ``unittest`` assertions there is the similar :ref:`redundant-unittest-assert` message.
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
Directly asserting a string literal will always pass.
1+
Directly asserting a string literal will always pass. The solution is to
2+
test something that could fail, or not assert at all.
3+
4+
For assertions using ``assert`` there are similar messages: :ref:`assert-on-string-literal` and :ref:`assert-on-tuple`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- `Tests without assertion <https://stackoverflow.com/a/137418/2519059>`_
2+
- `Testing that there is no error raised <https://stackoverflow.com/questions/20274987>`_
3+
- `Parametrizing conditional raising <https://docs.pytest.org/en/latest/example/parametrize.html#parametrizing-conditional-raising>`_

0 commit comments

Comments
 (0)