PY3.W0129

Assert on string literal

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

Noncompliant Code:

Copy
def test_division():
    a = 9 / 3
    assert "No ZeroDivisionError were raised"

Compliant Code:

Copy
def test_division():
    a = 9 / 3
    assert a == 3

Additional Details:

Directly asserting a string literal will always pass. The solution is to test something that could fail, or not assert at all.

The content on this page is adapted from the Pylint User Guide, Copyright ©2003-2022, Logilab, PyCQA and contributors. All rights reserved. https://pylint.pycqa.org/en/latest/index.html#, and is used under the Python Software Foundation License Version 2. Examples, recipes, and other code in the Pylint documentation are additionally licensed under the Zero Clause BSD License.