Yf9 @ s
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 e e e
Z e d k s| t
d d Z d
d Z d d
d Z d d Z d d Z d d Z d d Z e d d Z d d Z d d Z d d Z d S) zVarious utility functions. )
namedtupleOrderedDict)commonprefixTP c C sU t | | | } | t k rQ d | d | | | t | | d f } | S)Nz%s[%d chars]%s)len_PLACEHOLDER_LEN)s prefixlenZ suffixlenskip r
2/opt/alt/python35/lib64/python3.5/unittest/util.py_shorten s 1r c s t t t | } t t t | } | t k r: | St | t t | t t } | t k r t t t | t k s t
t t | t f d d | D St t t t f d d | D S)Nc 3 s# | ] } | d Vq d S)Nr
).0r
)prefixr r
r ' s z'_common_shorten_repr..c 3 s/ | ]% } t | d t t Vq d S)N)r
_MIN_DIFF_LEN_MIN_END_LEN)r r
)r r r
r r * s )tuplemap safe_reprmaxr _MAX_LENGTHr _MIN_BEGIN_LENr _MIN_COMMON_LENAssertionErrorr )argsmaxlenZ
common_lenr
)r r r _common_shorten_repr s r Fc C sc y t | } Wn! t k
r3 t j | } Yn X| sM t | t k rQ | S| d t d S)Nz [truncated]...)repr Exceptionobject__repr__r r )objZshortresultr
r
r r - s
r c C s d | j | j f S)Nz%s.%s)
__module____qualname__)clsr
r
r strclass6 s r) c C so d } } g } g } xLy| | } | | } | | k rw | j | | d 7} x | | | k rs | d 7} qV Wn | | k r | j | | d 7} x | | | k r | d 7} q Wn^ | d 7} z% x | | | k r | d 7} q WWd | d 7} x | | | k r| d 7} q WXWq t k
r`| j | | d | j | | d PYq Xq W| | 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 N)append
IndexErrorextend)expectedactualijmissingZ
unexpectedear
r
r sorted_list_difference9 s:
r5 c C s\ g } xI | rQ | j } y | j | Wq t k
rM | j | Yq Xq W| | 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.)popremove
ValueErrorr+ )r. r/ r2 itemr
r
r unorderable_list_differenceb s
r: c C s | | k | | k S)z.Return -1 if x < y, 0 if x == y and 1 if x > yr
)xyr
r
r
three_way_cmps s r= ZMismatchzactual expected valuec C s t | t | } } t | t | } } t } g } x t | D] \ } } | | k ri qN d }
} x; t | | D]* } | | | k r |
d 7}
| | |