_pytest.assertion.truncate module

Utilities for truncating assertion output.

Current default behaviour is to truncate assertion explanations at ~8 terminal lines, unless running in “-vv” mode or running on CI.

truncate_if_required(explanation, item, max_length=None)[source]

Truncate this assertion explanation if the given test item is eligible.

_should_truncate_item(item)[source]

Whether or not this test item is eligible for truncation.

_truncate_explanation(input_lines, max_lines=None, max_chars=None)[source]

Truncate given list of strings that makes up the assertion explanation.

Truncates to either 8 lines, or 640 characters - whichever the input reaches first. The remaining lines will be replaced by a usage message.

_truncate_by_char_count(input_lines, max_chars)[source]