o
0i_ @ s d Z ddlmZmZ ddlmZ dZdZdZdZ dZ
dZee e e e e
Zedks.J dd Z
d
d Zdd
dZdd Zdd Zdd Zdd ZeddZdd Zdd ZdS )zVarious utility functions. )
namedtupleCounter)commonprefixTP c C sB t | | | }|tkrd| d | || t | | d f } | S )Nz%s[%d chars]%s)len_PLACEHOLDER_LEN)s prefixlenZ suffixlenskip r
4/opt/alt/python310/lib64/python3.10/unittest/util.py_shorten s &r c s t tt| } ttt| }|tkr| S t| t t| t t }|t krJtt t | tk s8J t
t| t fdd| D S t
tt t fdd| D S )Nc 3 s | ]} |d V qd S Nr
.0r
prefixr r
r ' s z'_common_shorten_repr..c 3 s( | ]} t |d tt V qd S r )r
_MIN_DIFF_LEN_MIN_END_LENr r r
r r * s )tuplemap safe_reprmaxr _MAX_LENGTHr _MIN_BEGIN_LENr _MIN_COMMON_LENr )argsmaxlenZ
common_lenr
r r _common_shorten_repr s*
r! Fc C sN zt | }W n ty t| }Y nw |rt|tk r|S |d t d S )Nz [truncated]...)repr Exceptionobject__repr__r r )objZshortresultr
r
r r - s r c C s d| j | jf S )Nz%s.%s)
__module____qualname__)clsr
r
r strclass6 s r+ c C s^ d }}g }g } z| | }|| }||k r0| | |d7 }| | |kr/|d7 }| | |ks%n^||krN| | |d7 }|| |krM|d7 }|| |ksCn@|d7 }z&| | |krc|d7 }| | |ksYW |d7 }|| |krx|d7 }|| |ksnn|d7 }|| |kr|d7 }|| |ksw W n ty || |d |||d Y ||fS w q )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
IndexErrorextend)expectedactualijmissingZ
unexpectedear
r
r sorted_list_difference9 sX
r7 c C sH g }| r | }z|| W n ty || Y nw | s||fS )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
ValueErrorr- )r0 r1 r4 itemr
r
r unorderable_list_differenceb s r<