Files
PowerToys/PythonHome/Lib/unittest/util.pyc

47 lines
4.3 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc@s<>dZddlmZmZeZdZed<00>Zd<00>Z d<00>Z
ed<00>Z edd <00>Z d
<00>Z d <00>Zd <00>Zd S(sVarious utility functions.i<><69><EFBFBD><EFBFBD>(t
namedtuplet OrderedDictiPcCs\yt|<00>}Wn tk
r2tj|<00>}nX| sLt|<00>tkrP|S|t dS(Ns [truncated]...(treprt Exceptiontobjectt__repr__tlent _MAX_LENGTH(tobjtshorttresult((s.\Lib\unittest\util.pyt safe_reprs cCsd|j|jfS(Ns%s.%s(t
__module__t__name__(tcls((s.\Lib\unittest\util.pytstrclassscCshd}}g}g}xEtr]y||}||}||kr}|j|<00>|d7}x<>|||kry|d7}q\Wn<57>||kr<>|j|<00>|d7}x|||kr<>|d7}q<>Wn^|d7}z%x|||kr<>|d7}q<>WWd|d7}x|||kr |d7}qWXWqtk
rY|j||<1F>|j||<1F>PqXqW||fS(srFinds 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.
iiN(tTruetappendt
IndexErrortextend(texpectedtactualtitjtmissingt
unexpectedteta((s.\Lib\unittest\util.pytsorted_list_differences:
 

  
  


  cCsg}g}x<>|r<>|j<00>}y|j|<00>Wntk
rR|j|<00>nX|rxI||fD]8}yxtr<>|j|<00>qrWWqftk
r<>qfXqfWqqW|rxU|r|j<00>}|j|<00>yxtr<>|j|<00>q<>WWq<57>tk
rq<>Xq<58>W||fS||fS(s<>Same 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.
(tpoptremovet
ValueErrorRR(RRtignore_duplicateRRtitemtlst((s.\Lib\unittest\util.pytunorderable_list_difference>s4          
tMismatchsactual expected valuecCs<>t|<00>t|<00>}}t|<00>t|<00>}}t<00>}g}x<>t|<00>D]<5D>\}} | |krlqNnd}
} x>t||<00>D]-} || | kr<>|
d7}
||| <q<>q<>Wx=t|<00>D]/\} } | | kr<>| d7} ||| <q<>q<>W|
| krNt|
| | <00>}|j|<00>qNqNWx<57>t|<00>D]<5D>\}} | |krTq6nd} x>t||<00>D]-} || | krj| d7} ||| <qjqjWtd| | <00>}|j|<00>q6W|S(sHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differii(tlistRRt enumeratetranget _MismatchR(RRtstttmtntNULLR
Rtelemtcnt_stcnt_tRt
other_elemtdiff((s.\Lib\unittest\util.pyt_count_diff_all_purposeds<  

 
  
cCs8t<00>}x(|D] }|j|d<00>d||<qW|S(s@Return dict of element counts, in the order they were first seenii(Rtget(titerabletcR.((s.\Lib\unittest\util.pyt_ordered_count<6E>s  c Cs<>t|<00>t|<00>}}g}xZ|j<00>D]L\}}|j|d<00>}||kr,t|||<00>}|j|<00>q,q,WxH|j<00>D]:\}}||kr<>td||<00>}|j|<00>q<>q<>W|S(sHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differi(R7titemsR4R(R( RRR)R*R
R.R/R0R2((s.\Lib\unittest\util.pyt_count_diff_hashable<6C>s  N(t__doc__t collectionsRRRt
__unittestRtFalseR RRR#R(R3R7R9(((s.\Lib\unittest\util.pyt<module>s
 ) $ #