o
    Ú­j  ã                
   @   sÎ   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
ee dedee dee fdd„Zdedefdd„Z				ddee dee dee dee fdd„Zdee dedee fdd„Zd	S )z±Utilities for truncating assertion output.

Current default behaviour is to truncate assertion explanations at
~8 terminal lines, unless running in "-vv" mode or running on CI.
é    )ÚList)ÚOptional)Úutil)ÚItemé   i€  zuse '-vv' to showNÚexplanationÚitemÚ
max_lengthÚ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   úW/var/www/html/CropPilot/venv/lib/python3.10/site-packages/_pytest/assertion/truncate.pyÚtruncate_if_required   s   r   c                 C   s   | j jj}|dk ot ¡  S )z9Whether or not this test item is eligible for truncation.é   )ÚconfigÚoptionÚverboser   Úrunning_on_ci)r   r   r   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< |dd
|› d|d	krkdnd› dt› �g 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   TFéÿÿÿÿz...é   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   !   sB   ÿÿ€ÿÿþ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!   d   s   
r!   )N)NN)Ú__doc__Útypingr   r   Ú_pytest.assertionr   Ú_pytest.nodesr   r   r   r"   ÚstrÚintr   Úboolr   r   r!   r   r   r   r   Ú<module>   s>    ÿÿÿÿ
þ	ýÿþý
ü"C