֦i_ d Z ddlmZmZ ddlmZ dZdZdZdZ dZ
dZee ez ez ez e
z z
Zedk\ sJ d Z
d Zdd
Zd Zd Zd
Zd Z edd Zd Zd Zy)zVarious utility functions. )
namedtupleCounter)commonprefixTP c n t | |z
|z
}|t kD rd| d | || t | |z
d fz } | S )Nz%s[%d chars]%s)len_PLACEHOLDER_LEN)s prefixlen suffixlenskips &/usr/lib64/python3.12/unittest/util.py_shortenr sK q6I )D*9
tQs1v 7I7J5KLLH c t t t | } t t t | }|t
k r| S t
| t t
|z
t z t z z
}|t kD rIt t z t z |z
z t
k sJ t t | t fd| D S t t t t fd| D S )Nc 3 . K | ] }|d z y wN .0r prefixr
s r z'_common_shorten_repr..' s :TVa
m+Ts c 3 T K | ] }t |d t t z ! y wr )r
_MIN_DIFF_LEN_MIN_END_LENr s r r z'_common_shorten_repr..* s- Q (1YZ=-NNs %()tuplemap safe_reprmaxr
_MAX_LENGTHr _MIN_BEGIN_LENr _MIN_COMMON_LENr )argsmaxlen
common_lenr r
s @@r _common_shorten_reprr( s Y%&D
S$
F
$
FFI9$~58HHJJO# 00?B"$&12 2 2&.*=:T:::
fno
>F r c t | }|rt | t
k r|S |d t
dz S # t $ r t j | }Y Bw xY w)Nz [truncated]...)repr Exceptionobject__repr__r
r" )objshortresults r r r - sW &c CK+-
,;"333 &%&s / AAc 8 | j d| j S )N.)
__module____qualname__)clss r strclassr6 6 s nnc&6&677r c dx}}g }g } | | }|| }||k r-|j | |dz
}| | |k( ry|dz
}| | |k( rnj||kD r-|j | |dz
}|| |k( rG|dz
}|| |k( rn8|dz
} | | |k( r|dz
}| | |k( r|dz
}|| |k( r|dz
}|| |k( r # |dz
}|| |k( r|dz
}|| |k( rw w xY w# t $ r. |j | |d |j ||d Y ||fS w xY w)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 N)append
IndexErrorextend)expectedactualijmissing
unexpectedeas r sorted_list_differencerD 9 s
IAGJ
Aq A1uq!QqkQ&FA qkQ&Q!!!$QQi1nFA Qi1n Q"1+*Q #1+* FA )q.Q !)q.+ ( FA )q.Q !)q. NN8AB<(fQRj)J sA :C 1C 8C ?B2 C 0C 2CCC 1D
D
c g }| r%| j } |j | | r%||fS # t $ r |j | Y #w xY w)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.)popremove
ValueErrorr9 )r<