B � f_�@s�dZddlmZmZddlmZdZdZdZdZ dZ dZ ee ee ee Z e dks\t �dd �Zd d �Zdd d�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�ZdS)zVarious utility functions.�)� namedtuple�Counter)� commonprefixT�P� �cCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s� prefixlenZ suffixlen�skip�r �2/opt/alt/python37/lib64/python3.7/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t kr�ttt |�tkspt �t �t|��t��fdd�|D��St �tt ��t��fdd�|D��S)Nc3s|]}�|�d�VqdS)Nr )�.0r )�prefixr r r� 'sz'_common_shorten_repr..c3s&|]}�t|�d�tt�VqdS)N)r� _MIN_DIFF_LEN� _MIN_END_LEN)rr )rr r rr*s) �tuple�map� safe_repr�maxr� _MAX_LENGTHr�_MIN_BEGIN_LENr �_MIN_COMMON_LEN�AssertionErrorr)�args�maxlenZ common_lenr )rr r�_common_shorten_reprs    rFcCsPy t|�}Wntk r*t�|�}YnX|r|rB|��}y|�|�Wqtk r>|�|�YqXqW||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� ValueErrorr+)r.r/r2�itemr r r�unorderable_list_differencebsr:cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr )�x�yr r r� three_way_cmpssr=ZMismatchzactual expected valuecCsDt|�t|�}}t|�t|�}}t�}g}x�t|�D]�\}} | |krJq8d} } x.t||�D] } || | kr^| d7} ||| <q^Wx,t|�D] \} } | | kr�| d7} ||| <q�W| | kr8t| | | �}|�|�q8Wxlt|�D]`\}} | |kr�q�d} x2t||�D]$} || | k�r�| d7} ||| <�q�Wtd| | �}|�|�q�W|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr*)�listrr"� enumerate�range� _Mismatchr+)r/r.r �t�m�nZNULLr%r0�elem�cnt_s�cnt_tr1Z other_elem�diffr r r�_count_diff_all_purposeys<     rIc Cs�t|�t|�}}g}x>|��D]2\}}|�|d�}||kr t|||�}|�|�q Wx2|��D]&\}}||kr`td||�}|�|�q`W|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differr)r�items�getrAr+) r/r.r rBr%rErFrGrHr r r�_count_diff_hashable�s   rLN)F)�__doc__� collectionsrrZos.pathrZ __unittestrr rrrrrrrrr)r5r:r=rArIrLr r r r�s*   ) #