HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3.10/unittest/__pycache__/util.cpython-310.pyc
o

�w[e_�@s�dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	eeee
Zedks.J�dd	�Z
d
d�Zdd
d�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�ZdS)zVarious utility functions.�)�
namedtuple�Counter)�commonprefixT�P��cCsBt|�||}|tkrd|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlen�	suffixlen�skip�r�$/usr/lib/python3.10/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr|St|��t���t|�tt}|t	krJttt	|�tks8J�t
�t|��t��fdd�|D��St
�tt	��t��fdd�|D��S)Nc3s �|]}�|�d�VqdS�Nr��.0r
��prefixrrr�	<genexpr>'s�z'_common_shorten_repr.<locals>.<genexpr>c3s(�|]}�t|�d�tt�VqdSr)r�
_MIN_DIFF_LEN�_MIN_END_LENrrrrr*s� �)�tuple�map�	safe_repr�maxr�_MAX_LENGTHr�_MIN_BEGIN_LENr	�_MIN_COMMON_LENr)�args�maxlen�
common_lenrrr�_common_shorten_reprs*�
���r#FcCsNzt|�}Wntyt�|�}Ynw|rt|�tkr|S|dt�dS)Nz [truncated]...)�repr�	Exception�object�__repr__rr)�obj�short�resultrrrr-s�rcCsd|j|jfS)Nz%s.%s)�
__module__�__qualname__)�clsrrr�strclass6sr.cCs^d}}g}g}	z�||}||}||kr0|�|�|d7}|||kr/|d7}|||ks%n^||krN|�|�|d7}|||krM|d7}|||ksCn@|d7}z&|||krc|d7}|||ksYW|d7}|||krx|d7}|||ksnn|d7}|||kr�|d7}|||ks�wWnty�|�||d��|�||d��Y||fSwq	)arFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    rT�N)�append�
IndexError�extend)�expected�actual�i�j�missing�
unexpected�e�arrr�sorted_list_difference9sX
��
�����������r;cCsHg}|r |��}z|�|�Wnty|�|�Ynw|s||fS)z�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.)�pop�remove�
ValueErrorr0)r3r4r7�itemrrr�unorderable_list_differencebs��r@cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr)�x�yrrr�
three_way_cmpssrC�Mismatchzactual expected valuecCs,t|�t|�}}t|�t|�}}t�}g}t|�D]G\}}	|	|ur$qd}
}t||�D]}|||	kr=|
d7}
|||<q-t|�D]\}}
|
|	krR|d7}|||<qB|
|krbt|
||	�}|�|�qt|�D],\}}	|	|urpqgd}t||�D]}|||	kr�|d7}|||<qwtd||	�}|�|�qg|S)�HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr/)�listrr&�	enumerate�range�	_Mismatchr0)r4r3r
�t�m�n�NULLr*r5�elem�cnt_s�cnt_tr6�
other_elem�diffrrr�_count_diff_all_purposeysD��
��rSc	Cs�t|�t|�}}g}|��D]\}}|�|d�}||kr(t|||�}|�|�q|��D]\}}||vr@td||�}|�|�q-|S)rEr)r�items�getrIr0)	r4r3r
rJr*rNrOrPrRrrr�_count_diff_hashable�s
�
�rVN)F)�__doc__�collectionsrr�os.pathr�
__unittestrr	rrrrrr#rr.r;r@rCrIrSrVrrrr�<module>s6
���
	)
#