
    d_                         d Z ddlmZmZ ddlmZ dZdZdZdZ	dZ
dZee	ez   ez   ez   e
z   z
  Zedk    sJ d Zd	 ZddZd Zd Zd Zd Z edd          Zd Zd ZdS )zVarious utility functions.    )
namedtupleCounter)commonprefixTP         c                     t          |           |z
  |z
  }|t          k    r(d| d |         || t          |           |z
  d          fz  } | S )Nz%s[%d chars]%s)len_PLACEHOLDER_LEN)s	prefixlen	suffixlenskips         /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/unittest/util.py_shortenr      sW    q66I	)D*9*tQs1vv	7I7J7J5KLLH    c                  V   t          t          t          |                     } t          t          t          |                     }|t
          k    r| S t          |           t	                    t
          |z
  t          z   t          z   z
  }|t          k    rZt          t          z   t          z   |z
  z   t
          k     sJ t          t          |          t          fd| D                       S t          t          t                    t          fd| D                       S )Nc              3   2   K   | ]}|d          z   V  d S N .0r   prefixr   s     r   	<genexpr>z'_common_shorten_repr.<locals>.<genexpr>'   s0      ::Va	

m+::::::r   c              3   d   K   | ]*}t          |d          t          t                    z   V  +d S r   )r   _MIN_DIFF_LEN_MIN_END_LENr   s     r   r   z'_common_shorten_repr.<locals>.<genexpr>*   sP           (1YZZ=-NNN            r   )tuplemap	safe_reprmaxr
   _MAX_LENGTHr   _MIN_BEGIN_LENr   _MIN_COMMON_LENr   )argsmaxlen
common_lenr   r   s      @@r   _common_shorten_reprr(      s8   Y%%&&DS$  F$FFI9$~58HHJJO## 00?B"$&12 2 2 2&.*==:::::T::::::fno>>F                     r   Fc                     	 t          |           }n*# t          $ r t                              |           }Y nw xY w|rt	          |          t
          k     r|S |d t
                   dz   S )Nz [truncated]...)repr	Exceptionobject__repr__r
   r"   )objshortresults      r   r    r    -   sv    &c & & &%%& CKK+--,;,"333s    $99c                 $    | j         d| j        S )N.)
__module____qualname__)clss    r   strclassr6   6   s    nnnc&6&677r   c                    dx}}g }g }	 	 | |         }||         }||k     r8|                     |           |dz  }| |         |k    r|dz  }| |         |k    n||k    r8|                     |           |dz  }||         |k    r|dz  }||         |k    nm|dz  }	 | |         |k    r|dz  }| |         |k    |dz  }||         |k    r|dz  }||         |k    n'# |dz  }||         |k    r|dz  }||         |k    w xY wnJ# t          $ r= |                    | |d                    |                    ||d                    Y nw xY wG||fS )ar  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   T   N)append
IndexErrorextend)expectedactualijmissing
unexpectedeas           r   sorted_list_differencerD   9   s    IAGJ	Aq	A1uuq!!!QqkQ&&FA qkQ&&Q!!!$$$QQi1nnFA Qi1nn Q"1+**Q #1+** FA )q..Q !)q.. FA )q..Q !)q...... 	 	 	NN8ABB<(((fQRRj)))E	/6 Js+   BD C :#D $DD AEEc                     g }| rR|                                  }	 |                    |           n%# t          $ r |                    |           Y nw xY w| R||fS )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
ValueErrorr9   )r<   r=   r@   items       r   unorderable_list_differencerJ   b   s     G
 !||~~	!MM$ 	! 	! 	!NN4     	!	  ! F?s   0 AAc                     | |k    | |k     z
  S )z.Return -1 if x < y, 0 if x == y and 1 if x > yr   )xys     r   three_way_cmprN   s   s    Ea!er   Mismatchzactual expected valuec                    t          |           t          |          }}t          |          t          |          }}t                      }g }t          |          D ]\  }}	|	|u r
dx}
}t	          ||          D ]}||         |	k    r
|
dz  }
|||<   t          |          D ]\  }}||	k    r
|dz  }|||<   |
|k    r&t          |
||	          }|                    |           t          |          D ][\  }}	|	|u r
d}t	          ||          D ]}||         |	k    r
|dz  }|||<   t          d||	          }|                    |           \|S )HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differr   r8   )listr
   r,   	enumeraterange	_Mismatchr9   )r=   r<   r   tmnNULLr0   r>   elemcnt_scnt_tr?   
other_elemdiffs                  r   _count_diff_all_purposer_   y   s    <<hqAq663q66qA88DFQ<<    44<<q! 	 	Att||
!&q\\ 	 	MAzT!!
!E>>UE400DMM$Q<< 	 	44<<q! 	 	Att||
!E4((dMr   c                    t          |           t          |          }}g }|                                D ]G\  }}|                    |d          }||k    r&t          |||          }|                    |           H|                                D ]/\  }}||vr&t          d||          }|                    |           0|S )rQ   r   )r   itemsgetrU   r9   )	r=   r<   r   rV   r0   rZ   r[   r\   r^   s	            r   _count_diff_hashablerc      s     6??GH--qAFwwyy    edAE>>UE400DMM$wwyy    eq==Qt,,DMM$Mr   N)F)__doc__collectionsr   r   os.pathr   
__unittestr"   r   r#   r   r$   r   r   r(   r    r6   rD   rJ   rN   rU   r_   rc   r   r   r   <module>rh      s;       + + + + + + + +            
 !11OC !#/01        *4 4 4 48 8 8& & &R  "   Jz#:;;	! ! !F    r   