assertion message
Your own text added after an assert, following a comma, that pytest prints when the assertion fails.
In more detail
Use it for context the values cannot supply, such as which record in a batch failed. Do not restate the assertion, because pytest already prints the values, and a message that disagrees with the code misleads.
Example
assert total == expected, f"batch row {i} in {currency}"Related terms
- assertion — A check that a condition is true, which stops a test or program with a failure if it is false.
- f-string — A Python string with an f before the opening quote, in which expressions in curly brackets are replaced by their values.
- failure report — What the test runner prints when a test fails: which test, which line, and the values that did not match.
Taught in
- Making Failures Explain Themselves — Automated Testing, TDD & Quality Engineering