assertion rewriting
pytest's trick of rewriting plain assert statements as it imports test files so failures print the values involved.
In more detail
Because of it, a failing assert total == 1100 reports that total was 1000, and comparisons of lists, dictionaries and long strings print a readable difference. This is why plain assert is enough in pytest and special assertion methods usually add nothing.
Related terms
- assertion — A check that a condition is true, which stops a test or program with a failure if it is false.
- failure report — What the test runner prints when a test fails: which test, which line, and the values that did not match.
- diff — A listing of the differences between two versions of something, such as two files, two commits or two screenshots.
Taught in
- Introducing pytest — Automated Testing, TDD & Quality Engineering
- Making Failures Explain Themselves — Automated Testing, TDD & Quality Engineering