Chapters
Python114 chapters

ReferenceException types

AssertionError

An assert condition was false.

Signature

AssertionError(message)

Returns

Raised by assert, and by test frameworks.

Example

Python
try:
    assert 1 == 2, "these should match"
except AssertionError as problem:
    print("AssertionError:", problem)

Output

AssertionError: these should match

See also