
    9[gk                        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
ZddZ	 	 d	 	 	 	 	 	 	 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   i  zuse '-vv' to showNc                2    t        |      rt        |       S | S )zGTruncate this assertion explanation if the given test item is eligible.)_should_truncate_item_truncate_explanation)explanationitem
max_lengths      U/var/www/html/bid-api/venv/lib/python3.12/site-packages/_pytest/assertion/truncate.pytruncate_if_requiredr      s     T"$[11    c                    | j                   j                  t        j                        }|dk  xr t	        j
                          S )z9Whether or not this test item is eligible for truncation.   )configget_verbosityr   VERBOSITY_ASSERTIONSr   running_on_ci)r   verboses     r   r	   r	      s7    kk''(C(CDGQ;3t11333r   c                   |t         }|t        }t        dj                  |             }|dz   }|dz   }t        |       |k  r||k  r| S | d| }d}t        dj                  |            |kD  rt	        ||      }nd}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 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)	input_lines	max_lines	max_charsinput_char_counttolerable_max_charstolerable_max_linestruncated_explanationtruncated_chartruncated_line_counts	            r   r
   r
   "   s=    %	%	 277;/0 	B  $a-K// 33'
3N
277()*-@@ 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"   f   s    &/&<"
Z09<s:. '= #?N3^,J$-0C$C! :!:;
J'r   )N)r   	list[str]r   r   r   
int | Nonereturnr6   )r   r   r8   bool)NN)r$   r6   r%   r7   r&   r7   r8   r6   )r$   r6   r&   intr8   r6   )__doc__
__future__r   _pytest.assertionr   _pytest.configr   _pytest.nodesr   r   r   r#   r   r	   r
   r"    r   r   <module>rA      s    # " !    	 BF"&4>4 ! AAA A 	AHr   