.. _assert-on-string-literal:

assert-on-string-literal / W0129
================================

**Message emitted:**

Assert statement has a string literal as its first argument. The assert will %s fail.

**Description:**

*Used when an assert statement has a string literal as its first argument, which will cause the assert to always pass.*

**Problematic code:**

.. literalinclude:: /data/messages/a/assert-on-string-literal/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/a/assert-on-string-literal/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 ``unittest`` assertions there is the similar :ref:`redundant-unittest-assert` message.

**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 `basic <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/base/basic_checker.py>`__ checker.