diff --git a/doc/data/messages/a/assert-on-string-literal/bad.py b/doc/data/messages/a/assert-on-string-literal/bad.py index d7c735baba..adbe2a473e 100644 --- a/doc/data/messages/a/assert-on-string-literal/bad.py +++ b/doc/data/messages/a/assert-on-string-literal/bad.py @@ -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] diff --git a/doc/data/messages/a/assert-on-string-literal/details.rst b/doc/data/messages/a/assert-on-string-literal/details.rst index 76c2a271e5..188d8817e5 100644 --- a/doc/data/messages/a/assert-on-string-literal/details.rst +++ b/doc/data/messages/a/assert-on-string-literal/details.rst @@ -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. diff --git a/doc/data/messages/a/assert-on-string-literal/good.py b/doc/data/messages/a/assert-on-string-literal/good.py index 2426496978..ba2707575f 100644 --- a/doc/data/messages/a/assert-on-string-literal/good.py +++ b/doc/data/messages/a/assert-on-string-literal/good.py @@ -1,4 +1,3 @@ -def test(): - result = "result" - expected = "expected" - assert result == expected +def test_division(): + a = 9 / 3 + assert a == 3 diff --git a/doc/data/messages/a/assert-on-string-literal/related.rst b/doc/data/messages/a/assert-on-string-literal/related.rst new file mode 100644 index 0000000000..ee8d29fa22 --- /dev/null +++ b/doc/data/messages/a/assert-on-string-literal/related.rst @@ -0,0 +1,3 @@ +- `Tests without assertion `_ +- `Testing that there is no error raised `_ +- `Parametrizing conditional raising `_ diff --git a/doc/data/messages/a/assert-on-tuple/details.rst b/doc/data/messages/a/assert-on-tuple/details.rst new file mode 100644 index 0000000000..6efb4497f6 --- /dev/null +++ b/doc/data/messages/a/assert-on-tuple/details.rst @@ -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. diff --git a/doc/data/messages/r/redundant-unittest-assert/details.rst b/doc/data/messages/r/redundant-unittest-assert/details.rst index 76c2a271e5..d65cdeaee4 100644 --- a/doc/data/messages/r/redundant-unittest-assert/details.rst +++ b/doc/data/messages/r/redundant-unittest-assert/details.rst @@ -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`. diff --git a/doc/data/messages/r/redundant-unittest-assert/related.rst b/doc/data/messages/r/redundant-unittest-assert/related.rst new file mode 100644 index 0000000000..ee8d29fa22 --- /dev/null +++ b/doc/data/messages/r/redundant-unittest-assert/related.rst @@ -0,0 +1,3 @@ +- `Tests without assertion `_ +- `Testing that there is no error raised `_ +- `Parametrizing conditional raising `_