o
    hk                     @  sv   d Z ddlmZ ddlmZ ddlmZ ddlmZ dZ	dZ
dZ		ddddZd ddZ				d!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   i  zuse '-vv' to showNexplanation	list[str]itemr   
max_length
int | Nonereturnc                 C  s   t |rt| S | S )zGTruncate this assertion explanation if the given test item is eligible.)_should_truncate_item_truncate_explanation)r   r	   r
    r   R/var/www/html/zoom/venv/lib/python3.10/site-packages/_pytest/assertion/truncate.pytruncate_if_required   s   r   boolc                 C  s    | j tj}|dk ot  S )z9Whether or not this test item is eligible for truncation.   )configget_verbosityr   VERBOSITY_ASSERTIONSr   running_on_ci)r	   verboser   r   r   r      s   r   input_lines	max_lines	max_charsc           	      C  s   |du rt }|du rt}td| }|d }|d }t| |kr'||kr'| S | d| }d}td||kr>t||}nd}t| t| }|d r[|d d |d< |rZ|d	7 }nd|d< g |dd
| d|d	krndnd dt S )a  Truncate given list of strings that makes up the assertion explanation.

    Truncates to either 8 lines, or 640 characters - whichever the input reaches
    first, taking the truncation explanation into account. The remaining lines
    will be replaced by a usage message.
    N F   r   TFz...   z...Full output truncated (z linesz
 hidden), )DEFAULT_MAX_LINESDEFAULT_MAX_CHARS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   "   sH   r   intc                 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%   f   s   
r%   )N)r   r   r	   r   r
   r   r   r   )r	   r   r   r   )NN)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    
	D