B I0`3+@sdZddlmZmZddlmZdZdZdZdZ dZ dZ ee ee ee Z e dks\t dd Zd d Zdd dZddZddZddZddZeddZddZddZdS)zVarious utility functions.) namedtupleCounter) commonprefixTP cCsBt|||}|tkr>d|d|||t||df}|S)Nz%s[%d chars]%s)len_PLACEHOLDER_LEN)s prefixlenZ suffixlenskipr 2/opt/alt/python37/lib64/python3.7/unittest/util.py_shortens&rcsttt|}ttt|}|tkr(|St|tt|tt}|t krttt |tkspt t t|tfdd|DSt tt tfdd|DS)Nc3s|]}|dVqdS)Nr ).0r )prefixr r r 'sz'_common_shorten_repr..c3s&|]}t|dttVqdS)N)r _MIN_DIFF_LEN _MIN_END_LEN)rr )rr r rr*s) tuplemap safe_reprmaxr _MAX_LENGTHr_MIN_BEGIN_LENr _MIN_COMMON_LENAssertionErrorr)argsmaxlenZ common_lenr )rr r_common_shorten_reprs    rFcCsPy t|}Wntk r*t|}YnX|r|rB|}y||Wqtk r>||YqXqW||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+)r.r/r2itemr r runorderable_list_differencebsr: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 valuecCsDt|t|}}t|t|}}t}g}xt|D]\}} | |krJq8d} } x.t||D] } || | kr^| d7} ||| <q^Wx,t|D] \} } | | kr| d7} ||| <qW| | kr8t| | | }||q8Wxlt|D]`\}} | |krqd} x2t||D]$} || | kr| d7} ||| <qWtd| | }||qW|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr*)listrr" enumeraterange _Mismatchr+)r/r.r tmnZNULLr%r0elemcnt_scnt_tr1Z other_elemdiffr r r_count_diff_all_purposeys<     rIc Cst|t|}}g}x>|D]2\}}||d}||kr t|||}||q Wx2|D]&\}}||kr`td||}||q`W|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differr)ritemsgetrAr+) r/r.r rBr%rErFrGrHr r r_count_diff_hashables   rLN)F)__doc__ collectionsrrZos.pathrZ __unittestrr rrrrrrrrr)r5r:r=rArIrLr r r rs*   ) #