o ?Og_@sdZddlmZmZddlmZdZdZdZdZ dZ dZ ee ee ee Z e dks.Jdd Z d d Zdd dZddZddZddZddZeddZddZddZdS)zVarious utility functions.) namedtupleCounter) commonprefixTP cCsBt|||}|tkrd|d|||t||df}|S)Nz%s[%d chars]%s)len_PLACEHOLDER_LEN)s prefixlenZ suffixlenskipr 4/opt/alt/python310/lib64/python3.10/unittest/util.py_shortens&rcsttt|}ttt|}|tkr|St|tt|tt}|t krJttt |tks8Jt t|tfdd|DSt tt tfdd|DS)Nc3s |] }|dVqdSNr .0r prefixr r r 'sz'_common_shorten_repr..c3s(|]}t|dttVqdSr)r _MIN_DIFF_LEN _MIN_END_LENrrr rr*s ) tuplemap safe_reprmaxr _MAX_LENGTHr_MIN_BEGIN_LENr _MIN_COMMON_LENr)argsmaxlenZ common_lenr rr_common_shorten_reprs*   r!FcCsNzt|}Wntyt|}Ynw|rt|tkr|S|dtdS)Nz [truncated]...)repr Exceptionobject__repr__rr)objZshortresultr r rr-s  rcCsd|j|jfS)Nz%s.%s) __module__ __qualname__)clsr r rstrclass6sr+cCs^d}}g}g} z||}||}||kr0|||d7}|||kr/|d7}|||ks%n^||krN|||d7}|||krM|d7}|||ksCn@|d7}z&|||krc|d7}|||ksYW|d7}|||krx|d7}|||ksnn|d7}|||kr|d7}|||kswWnty|||d|||dY||fSwq )arFinds 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. rTN)append IndexErrorextend)expectedactualijmissingZ unexpectedear r rsorted_list_difference9sX            r7cCsHg}|r |}z||Wnty||Ynw|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-)r0r1r4itemr r runorderable_list_differencebs r<cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr )xyr r r three_way_cmpssr?ZMismatchzactual expected valuecCs,t|t|}}t|t|}}t}g}t|D]G\}} | |ur$qd} } t||D]} || | kr=| d7} ||| <q-t|D]\} } | | krR| d7} ||| <qB| | krbt| | | }||qt|D],\}} | |urpqgd} t||D]} || | kr| d7} ||| <qwtd| | }||qg|S)HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr,)listrr$ enumeraterange _Mismatchr-)r1r0r tmnZNULLr'r2elemcnt_scnt_tr3Z other_elemdiffr r r_count_diff_all_purposeysD      rLc Cst|t|}}g}|D]\}}||d}||kr(t|||}||q|D]\}}||vr@td||}||q-|S)r@r)ritemsgetrDr-) r1r0r rEr'rHrIrJrKr r r_count_diff_hashables     rON)F)__doc__ collectionsrrZos.pathrZ __unittestrr rrrrrr!rr+r7r<r?rDrLrOr r r rs6     )  #