
    Bh=                    z    d Z ddlmZ ddlmZ ddlmZ ddlmZ dZ	e	dz  Z
dZdd	Zdd
Z	 	 	 	 	 	 	 	 ddZddZy)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)util)Config)Item   P   zuse '-vv' to showc                D    t        |      \  }}}|rt        | ||      S | S )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        e/var/www/html/Telegram-Engagement-Pod-/env/lib/python3.12/site-packages/_pytest/assertion/truncate.pytruncate_if_requiredr      s4    ,Ft,L)OY	$
 	

     c                n   | j                   j                  d      }t        ||nt              }| j                   j                  d      }t        ||nt              }| j                   j                  t        j                        }|dk  xr t        j                          }|xr |dkD  xs |dkD  }|||fS )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   running_on_ci)r   r
   r   verboser   s        r   r   r      s     ""#;<I!6I<MNI""#;<I!6I<MNIkk''(C(CDGk>$*<*<*>&>O%J9q=+IIMOIy00r   c                   t        dj                  |             }|dz   }|dz   }t        |       |k  r||k  r| S |dkD  r| d| }n| }d}t        dj                  |            |kD  r|dkD  rt        ||      }nd}|| k(  r|S t        |       t        |      z
  }|d   r|d   d	z   |d<   |r|d
z  }nd	|d<   g |dd| d|d
k(  rdnd dt         S )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.
     F   r   r   NTFz...   z...Full output truncated (z linesz
 hidden), )lenjoin_truncate_by_char_count	USAGE_MSG)	input_linesr
   r   input_char_counttolerable_max_charstolerable_max_linestruncated_explanationtruncated_chartruncated_line_counts	            r   r   r   4   sG    277;/0 	B  $a-K// 331} +JY 7 +N
277()*-@@YQR] 7!9!
 +$${+c2G.HHR $9"$=$Eb! A%  %*b!	
 %%9$:%%*2
4Jyk	K r   c                    d}t        |       D ]&  \  }}|t        |      z   |kD  r n|t        |      z  }( | d  }| |   }|r
||z
  }|d | }|j                  |       |S )Nr   )	enumerater'   append)r+   r   iterated_char_countiterated_index
input_linetruncated_result
final_linefinal_line_truncate_points           r   r)   r)   z   s    &/&<"
Z09<s:. '= #?N3^,J$-0C$C! :!:;
J'r   N)r   	list[str]r   r   returnr;   )r   r   r<   ztuple[bool, int, int])r+   r;   r
   r   r   r   r<   r;   )r+   r;   r   r   r<   r;   )__doc__
__future__r   _pytest.assertionr   _pytest.configr   _pytest.nodesr   r   r   r*   r   r   r   r)    r   r   <module>rC      sn    # " !   %* 		1*CCC C 	CLr   