.. _redundant-unittest-assert:

redundant-unittest-assert / W1503
=================================

**Message emitted:**

Redundant use of %s with constant value %r

**Description:**

*The first argument of assertTrue and assertFalse is a condition. If a constant is passed as parameter, that condition will be always true. In this case a warning should be emitted.*

**Problematic code:**

.. literalinclude:: /data/messages/r/redundant-unittest-assert/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/r/redundant-unittest-assert/good.py
   :language: python

**Additional details:**

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`.

**Related links:**

- `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>`_

Created by the `stdlib <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/stdlib.py>`__ checker.