
    F\h_                         S r SSKJrJr  SSKJr  SrSrSrSr	Sr
Sr\\	\-   \-   \-   \
-   -
  r\S:  d   eS rS	 rSS
 jrS rS rS rS r\" SS5      rS rS rg)zVarious utility functions.    )
namedtupleCounter)commonprefixTP         c                 n    [        U 5      U-
  U-
  nU[        :  a  SU S U X0[        U 5      U-
  S  4-  n U $ )Nz%s[%d chars]%s)len_PLACEHOLDER_LEN)s	prefixlen	suffixlenskips       $/usr/lib/python3.13/unittest/util.py_shortenr      sI    q6I	)D*9ts1v	7I7J5KLLH    c                    ^^ [        [        [        U 5      5      n [        [        [        U 5      5      nU[
        ::  a  U $ [        U 5      m[	        T5      m[
        UT-
  [        -   [        -   -
  nU[        :  aK  [        [        -   [        -   UT-
  -   [
        :  d   e[        T[        U5      m[        UU4S jU  5       5      $ [        T[        [        5      m[        UU4S jU  5       5      $ )Nc              3   4   >#    U  H  nTUTS  -   v   M     g 7fN .0r   prefixr   s     r   	<genexpr>'_common_shorten_repr.<locals>.<genexpr>'   s     :TVa	
m+Ts   c              3   Z   >#    U  H   nT[        UTS  [        [        5      -   v   M"     g 7fr   )r   _MIN_DIFF_LEN_MIN_END_LENr   s     r   r   r   *   s,       Q (1YZ=-NNs   (+)tuplemap	safe_reprmaxr
   _MAX_LENGTHr   _MIN_BEGIN_LENr   _MIN_COMMON_LENr   )argsmaxlen
common_lenr   r   s      @@r   _common_shorten_reprr)      s    Y%&DS$ F$FFI9$~58HHJJO# 00?B"$&12 	2 2&.*=:T:::fno>F       r   c                      [        U 5      nU(       a  [	        U5      [
        :  a  U$ US [
         S-   $ ! [         a    [        R                  U 5      n NIf = f)Nz [truncated]...)repr	Exceptionobject__repr__r
   r#   )objshortresults      r   r!   r!   -   sW    &c CK+-,;"333	  &%&s   5 AAc                 <    U R                   < SU R                  < 3$ )N.)
__module____qualname__)clss    r   strclassr7   6   s    nnc&6&677r   c                    S=p#/ n/ n  X   nX   nXg:  a.  UR                  U5        US-  nX   U:X  a  US-  nX   U:X  a  M  OlXg:  a.  UR                  U5        US-  nX   U:X  a  US-  nX   U:X  a  M  O9US-  n X   U:X  a  US-  nX   U:X  a  M  US-  nX   U:X  a  US-  nX   U:X  a  M  M  ! US-  nX   U:X  a  US-  nX   U:X  a  M  f f = f! [         a+    UR                  XS 5        UR                  XS 5         XE4$ f = f)a^  Finds 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.
r      N)append
IndexErrorextend)expectedactualijmissing
unexpectedeas           r   sorted_list_differencerE   9   sa    IAGJ
	A	Auq!QkQ&FA kQ&!!!$Qi1nFA i1n Q"+*Q #+* FA )q.Q !)q.+ ( FA )q.Q !)q. 	NN8B<(fRj)		s;   8C 0C 8C >B3 C 3CCC 0D
	D
c                     / nU (       a+  U R                  5       n UR                  U5        U (       a  M+  X!4$ ! [         a    UR                  U5         N)f = f)zSame 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>   rA   items       r   unorderable_list_differencerK   b   sV     G
||~	!MM$ ( ?	  	!NN4 	!s   8 AAc                     X:  X:  -
  $ )z.Return -1 if x < y, 0 if x == y and 1 if x > yr   )xys     r   three_way_cmprO   s   s    Eaer   Mismatchzactual expected valuec                 B   [        U 5      [        U5      p2[        U5      [        U5      pT[        5       n/ n[        U5       H{  u  pXL a  M  S=p[	        X5       H  nX,   U	:X  d  M  U
S-  n
XbU'   M     [        U5       H  u  pX:X  d  M  US-  nXcU'   M     X:w  d  M^  [        XU	5      nUR                  U5        M}     [        U5       HO  u  pXL a  M  Sn[	        X5       H  nX<   U	:X  d  M  US-  nXcU'   M     [        SX5      nUR                  U5        MQ     U$ )HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differr   r9   )listr
   r-   	enumeraterange	_Mismatchr:   )r>   r=   r   tmnNULLr1   r?   elemcnt_scnt_tr@   
other_elemdiffs                  r   _count_diff_all_purposer`   y   s#    <hqq63q6q8DFQ<<qAtt|
!  'q\MA!
! * >U40DMM$    Q<<qAtt|
!  E(d   Mr   c                 L   [        U 5      [        U5      p2/ nUR                  5        H;  u  pVUR                  US5      nXg:w  d  M  [        XgU5      nUR	                  U5        M=     UR                  5        H)  u  pWXR;  d  M  [        SXu5      nUR	                  U5        M+     U$ )rR   r   )r   itemsgetrV   r:   )	r>   r=   r   rW   r1   r[   r\   r]   r_   s	            r   _count_diff_hashablerd      s     6?GH-qFwwydA>U40DMM$	 !
 wwy=Q,DMM$ ! Mr   N)F)__doc__collectionsr   r   os.pathr   
__unittestr#   r   r$   r   r%   r   r   r)   r!   r7   rE   rK   rO   rV   r`   rd   r   r   r   <module>ri      s      +  
 !11OC !#/01   *48&R" z#:;	!Fr   