a
    /§»ap  ã                   @   sÀ   d Z ddlZddlmZ ddlmZ ddlmZ dZdZdZ	dee
 eee ee
 d	œd
d„Zeedœdd„Zedœdd„Zdee
 ee ee ee
 dœdd„Zee
 eee
 dœ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.
é    N)ÚList)ÚOptional)ÚItemé   i€  zuse '-vv' to show)Ú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   úT/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/_pytest/assertion/truncate.pyÚtruncate_if_required   s    r   )r   r	   c                 C   s   | j jj}|dk otƒ  S )z9Whether or not this test item is eligible for truncation.é   )ÚconfigÚoptionÚverboseÚ_running_on_ci)r   r   r   r   r   r
      s    
r
   )r	   c                  C   s   ddg} t dd„ | D ƒƒS )z0Check if we're currently running on a CI system.ÚCIZBUILD_NUMBERc                 s   s   | ]}|t jv V  qd S )N)ÚosÚenviron)Ú.0Úvarr   r   r   Ú	<genexpr>$   ó    z!_running_on_ci.<locals>.<genexpr>)Úany)Zenv_varsr   r   r   r   !   s    r   )Úinput_linesÚ	max_linesÚ	max_charsr	   c                 C   sÎ   |du rt }|du rt}td | ¡ƒ}t| ƒ|kr>||kr>| S | d|… }t||ƒ}|d d |d< t| ƒt|ƒ }|d7 }d}|dkrš|d|› d�7 }n|d|› d	�7 }|d
t› �7 }| dt|ƒg¡ |S )zâTruncate given list of strings that makes up the assertion explanation.

    Truncates to either 8 lines, or 640 characters - whichever the input reaches
    first. The remaining lines will be replaced by a usage message.
    NÚ éÿÿÿÿz...é   z...Full output truncatedz (z line hidden)z lines hidden)z, )ÚDEFAULT_MAX_LINESÚDEFAULT_MAX_CHARSÚlenÚjoinÚ_truncate_by_char_countÚ	USAGE_MSGÚextendÚstr)r   r   r   Zinput_char_countZtruncated_explanationZtruncated_line_countÚmsgr   r   r   r   '   s&    
r   )r   r   r	   c                 C   s†   t d | ¡ƒ|kr| S d}t| ƒD ](\}}|t |ƒ |kr> qL|t |ƒ7 }q"| d |… }| | }|rx|| }|d |… }| |¡ |S )Nr   r   )r$   r%   Ú	enumerateÚappend)r   r   Ziterated_char_countZiterated_indexZ
input_lineZtruncated_resultZ
final_lineZfinal_line_truncate_pointr   r   r   r&   Q   s    
r&   )N)NN)Ú__doc__r   Útypingr   r   Z_pytest.nodesr   r"   r#   r'   r)   Úintr   Úboolr
   r   r   r&   r   r   r   r   Ú<module>   s.    ÿþ	  ýü*