Return the truncation parameters related to the given item, as (should truncate, max lines, max chars).
(item: Item)
| 29 | |
| 30 | |
| 31 | def _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 | |
| 52 | def _truncate_explanation( |
no test coverage detected