In Python, an assertion is a statement that confirms something about the state of your program. You can think of an assert statement like a https://qvault.io/clean-code/writing-good-unit-tests-dont-mock-database-connections/ that is performed at runtime.

Code language: Python (python) tl;dr Assertions are simply boolean expressions that raise exceptions if their condition is False The assert statement is the built-in syntax for assertions in Python Developers often use assert to do type checking, and input/output validation for function signatures The assert statement is used for debugging purposes

You can catch an assertion error just like you would any other error in Python.

Related Articles