MCPcopy
hub / github.com/pytest-dev/pytest / _get_truncation_parameters

Function _get_truncation_parameters

src/_pytest/assertion/truncate.py:31–49  ·  view source on GitHub ↗

Return the truncation parameters related to the given item, as (should truncate, max lines, max chars).

(item: Item)

Source from the content-addressed store, hash-verified

29
30
31def _get_truncation_parameters(item: Item) -> tuple[bool, int, int]:
32 """Return the truncation parameters related to the given item, as (should truncate, max lines, max chars)."""
33 # We do not need to truncate if one of conditions is met:
34 # 1. Verbosity level is 2 or more;
35 # 2. Test is being run in CI environment;
36 # 3. Both truncation_limit_lines and truncation_limit_chars
37 # .ini parameters are set to 0 explicitly.
38 max_lines = item.config.getini("truncation_limit_lines")
39 max_lines = int(max_lines if max_lines is not None else DEFAULT_MAX_LINES)
40
41 max_chars = item.config.getini("truncation_limit_chars")
42 max_chars = int(max_chars if max_chars is not None else DEFAULT_MAX_CHARS)
43
44 verbose = item.config.get_verbosity(Config.VERBOSITY_ASSERTIONS)
45
46 should_truncate = verbose < 2 and not running_on_ci()
47 should_truncate = should_truncate and (max_lines > 0 or max_chars > 0)
48
49 return should_truncate, max_lines, max_chars
50
51
52def _truncate_explanation(

Callers 1

truncate_if_requiredFunction · 0.85

Calls 4

running_on_ciFunction · 0.90
intClass · 0.85
getiniMethod · 0.45
get_verbosityMethod · 0.45

Tested by

no test coverage detected