
    ~/j$                        S r SSKJr  SSKJr  SSKJr  SSKJr  Sr	\	S-  r
SrSS	 jrSS
 jr        SS jrSS jrg)zUtilities for truncating assertion output.

Current default behaviour is to truncate assertion explanations at
terminal lines, unless running with an assertions verbosity level of at least 2 or running on CI.
    )annotations)running_on_ci)Config)Item   P   zuse '-vv' to showc                F    [        U5      u  p#nU(       a  [        U UUS9$ U $ )zGTruncate this assertion explanation if the given test item is eligible.)	max_lines	max_chars)_get_truncation_parameters_truncate_explanation)explanationitemshould_truncater
   r   s        Y/root/lseg-credit/backend/venv/lib/python3.13/site-packages/_pytest/assertion/truncate.pytruncate_if_requiredr      s2    ,Ft,L)O	$
 	

     c                   U R                   R                  S5      n[        Ub  UO[        5      nU R                   R                  S5      n[        Ub  UO[        5      nU R                   R                  [        R                  5      nUS:  =(       a    [        5       (       + nU=(       a    US:  =(       d    US:  nXAU4$ )zgReturn the truncation parameters related to the given item, as (should truncate, max lines, max chars).truncation_limit_linestruncation_limit_chars   r   )	configgetiniintDEFAULT_MAX_LINESDEFAULT_MAX_CHARSget_verbosityr   VERBOSITY_ASSERTIONSr   )r   r
   r   verboser   s        r   r   r      s     ""#;<I!6I<MNI""#;<I!6I<MNIkk''(C(CDGk9-/&9O%J9q=+IIMOy00r   c                   US-   nUS:X  d  [        U 5      US-   ::  a!  US:X  d  [        S U  5       5      U::  a  U $ U nOU SU nUS:  =(       a    [        S U 5       5      U:  nU(       a  [        XB5      nUS==   S-  ss'   [        U 5      [        U5      -
  [        U5      -   n/ UQS	PS
U SUS:X  a  S	OS S[         3P$ )a  Truncate given list of strings that makes up the assertion explanation.

Truncates to either max_lines, or max_chars - whichever the input reaches
first, taking the truncation explanation into account. The remaining lines
will be replaced by a usage message.

If max_chars=0, no truncation by character count is performed.
If max_lines=0, no truncation by line count is performed.

When this function is launched we know max_lines > 0 or max_chars > 0
because _get_truncation_parameters was called first.
F   r   r   c              3  8   #    U  H  n[        U5      v   M     g 7fNlen).0ss     r   	<genexpr>(_truncate_explanation.<locals>.<genexpr>U   s      =AQ   Nc              3  8   #    U  H  n[        U5      v   M     g 7fr#   r$   )r&   es     r   r(   r)   ^   s     6 51A 5r*   z... z...Full output truncated (z line   r'   z
 hidden), )r%   sum_truncate_by_char_countr   	USAGE_MSG)input_linesr
   r   tolerable_max_charstruncated_explanationneed_to_truncate_chartruncated_line_counts          r   r   r   4   s   : 	B  A~[)Y]:>S = ==ATT + !,JY 7 	A 	M6 5669LL   7!!
 "&K3455<Q8RR 	
 %%9$:%%*2
4Jyk	K r   c                    Sn[        U 5       H'  u  p4U[        U5      -   U:  a    OU[        U5      -  nM)     U S W nX   nU(       a	  X-
  nUS U nUR                  U5        U$ )Nr   )	enumerater%   append)r3   r   iterated_char_countiterated_index
input_linetruncated_result
final_linefinal_line_truncate_points           r   r1   r1   q   s    &/&<"Z09<s:. '= #?N3,J$-$C! :!:;
J'r   N)r   	list[str]r   r   returnrA   )r   r   rB   ztuple[bool, int, int])r3   rA   r
   r   r   r   rB   rA   )r3   rA   r   r   rB   rA   )__doc__
__future__r   _pytest.compatr   _pytest.configr   _pytest.nodesr   r   r   r2   r   r   r   r1    r   r   <module>rI      si    # ( !   %* 		1*::: : 	:zr   