File tree 7 files changed +24
-8
lines changed
r/redundant-unittest-assert
7 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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 number Diff line number Diff line change 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 number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change 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 number Diff line number Diff line change
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 >`_
You can’t perform that action at this time.
0 commit comments