
    [j$                    l    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  Z
dZddZddZddZ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)running_on_ci)Config)Item   P   zuse '-vv' to showexplanation	list[str]itemr   returnc                T    t          |          \  }}}|rt          | ||          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   s        ^/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/_pytest/assertion/truncate.pytruncate_if_requiredr      sF    ,Ft,L,L)OY	 
$
 
 
 	

     tuple[bool, int, int]c                b   | j                             d          }t          ||nt                    }| j                             d          }t          ||nt                    }| j                             t          j                  }|dk     ot                       }|o|dk    p|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   )r   r   r   verboser   s        r   r   r      s     ""#;<<I!6II<MNNI""#;<<I!6II<MNNIk''(CDDGk9-//&9O%J9q=+IIMOIy00r   input_linesr   r   r   c                   |dz   }|dk    st          |           |dz   k    r(|dk    st          d | D                       |k    r| S | }n
| d|         }|dk    ot          d |D                       |k    }|rt          ||          }|dxx         dz  cc<   t          |           t          |          z
  t          |          z   }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 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.

    If max_chars=0, no truncation by character count is performed.
    If max_lines=0, no truncation by line count is performed.

    When this function is launched we know max_lines > 0 or max_chars > 0
    because _get_truncation_parameters was called first.
    F   r   r   c              3  4   K   | ]}t          |          V  d S Nlen).0ss     r   	<genexpr>z(_truncate_explanation.<locals>.<genexpr>U   s(       = =AQ = = = = = =r   Nc              3  4   K   | ]}t          |          V  d S r'   r(   )r*   es     r   r,   z(_truncate_explanation.<locals>.<genexpr>^   s(      661A666666r   z... z...Full output truncated (z line   r+   z
 hidden), )r)   sum_truncate_by_char_countr   	USAGE_MSG)r#   r   r   tolerable_max_charstruncated_explanationneed_to_truncate_chartruncated_line_counts          r   r   r   4   sz   : 	B  A~~[))Y]::>>S = = = = ===ATTT + !,JYJ 7 	A 	M66 5666669LL   
 7!9!
 !
 "&K34555<Q8R8RR 	
	K%9 	K 	K%**22	K 	K?H	K 	K r   c                    d}t          |           D ]/\  }}|t          |          z   |k    r n|t          |          z  }0| d |         }| |         }|r||z
  }|d |         }|                    |           |S )Nr   )	enumerater)   append)r#   r   iterated_char_countiterated_index
input_linetruncated_result
final_linefinal_line_truncate_points           r   r3   r3   q   s    &/&<&< / /"
Z09<<Es:. #?N?3^,J <$-0C$C! :!: :;
J'''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.compatr   _pytest.configr   _pytest.nodesr   r   r   r4   r   r   r   r3    r   r   <module>rH      s     # " " " " " ( ( ( ( ( ( ! ! ! ! ! !        %* 		 	 	 	1 1 1 1*: : : :z     r   