Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/_pytest/assertion/_typing.py: 0%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

15 statements  

1from __future__ import annotations 

2 

3from dataclasses import dataclass 

4from typing import ClassVar 

5from typing import Literal 

6from typing import Protocol 

7 

8 

9_AssertionTextDiffStyle = Literal["ndiff", "block"] 

10 

11 

12@dataclass(frozen=True, kw_only=True, slots=True) 

13class TruncationBudget: 

14 """Per-explanation budget for truncating assertion output. 

15 

16 ``max_lines`` / ``max_chars`` mirror the ``truncation_limit_lines`` / 

17 ``truncation_limit_chars`` ini values: a positive limit bounds that 

18 dimension; ``0`` leaves it unbounded (the limit is disabled). 

19 """ 

20 

21 #: Default limits applied when the corresponding ini option is left unset. 

22 DEFAULT_MAX_LINES: ClassVar[int] = 8 

23 DEFAULT_MAX_CHARS: ClassVar[int] = DEFAULT_MAX_LINES * 80 

24 

25 max_lines: int = DEFAULT_MAX_LINES 

26 max_chars: int = DEFAULT_MAX_CHARS 

27 

28 

29# Reusable "no cap" budget, used as a default argument (B008). 

30NO_TRUNCATION_BUDGET = TruncationBudget(max_lines=0, max_chars=0) 

31 

32 

33class _HighlightFunc(Protocol): # noqa: PYI046 

34 def __call__(self, source: str, lexer: Literal["diff", "python"] = "python") -> str: 

35 """Apply highlighting to the given source."""