o
    h=                     @  sp   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
dZdddZdddZdddZdddZdS ) 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 showexplanation	list[str]itemr   returnc                 C  s$   t |\}}}|rt| ||dS | S )zGTruncate this assertion explanation if the given test item is eligible.)	max_lines	max_chars)_get_truncation_parameters_truncate_explanation)r   r
   should_truncater   r    r   [/var/www/html/openai_agents/venv/lib/python3.10/site-packages/_pytest/assertion/truncate.pytruncate_if_required   s   r   tuple[bool, int, int]c                 C  s~   | j d}t|dur|nt}| j d}t|dur|nt}| j tj}|dk o/t	  }|o9|dkp9|dk}|||fS )zgReturn the truncation parameters related to the given item, as (should truncate, max lines, max chars).truncation_limit_linesNtruncation_limit_chars   r   )
configgetiniintDEFAULT_MAX_LINESDEFAULT_MAX_CHARSget_verbosityr   VERBOSITY_ASSERTIONSr   running_on_ci)r
   r   r   verboser   r   r   r   r      s   
r   input_linesr   r   r   c           	      C  s   t d| }|d }|d }t | |kr||kr| S |dkr&| d| }n| }d}t d||kr=|dkr=t||}nd}|| krE|S t | t | }|d r`|d d	 |d< |r_|d
7 }nd	|d< g |dd| d|d
krsd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)	r!   r   r   input_char_counttolerable_max_charstolerable_max_linestruncated_explanationtruncated_chartruncated_line_countr   r   r   r   4   sH   r   c                 C  sp   d}t | D ]\}}|t| |kr n|t|7 }q| d | }| | }|r1|| }|d | }|| |S )Nr   )	enumerater'   append)r!   r   iterated_char_countiterated_index
input_linetruncated_result
final_linefinal_line_truncate_pointr   r   r   r)   z   s   
r)   N)r   r	   r
   r   r   r	   )r
   r   r   r   )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   r   r   <module>   s    


F