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

Taught in

References