ó {G_Tc@sldZddlZddlZddlmZddlmZmZejdddgƒZ ejdddgƒZ d d d d d ddgZ defd„ƒYZ defd„ƒYZ de fd„ƒYZee dƒde fd„ƒYƒZdd;d„ƒYZdd<d„ƒYZdd=d„ƒYZd„Zd d>d!„ƒYZd"d?d#„ƒYZd$d@d%„ƒYZd&dAd'„ƒYZd(dBd)„ƒYZd*dCd+„ƒYZd,dDd-„ƒYZdd.lmZmZd/„Zd0dEd1„ƒYZd2efd3„ƒYZ d4e fd5„ƒYZ!ee dƒd6e fd7„ƒYƒZ"dd8„Z$e%d9krhe$d:e&ƒndS(FsUnittests for heapq.iÿÿÿÿN(t test_support(tTestCaset skipUnlesstheapqtblockedt_heapqtfreshtheapifytheappoptheappusht heappushpopt heapreplacet _nlargestt _nsmallestt TestModulescBs)eZd„Zeedƒd„ƒZRS(cCs1x*tD]"}|jtt|ƒjdƒqWdS(NR(t func_namest assertEqualtgetattrtpy_heapqt __module__(tselftfname((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_py_functionss srequires _heapqcCs1x*tD]"}|jtt|ƒjdƒqWdS(NR(RRRtc_heapqR(RR((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_c_functionss (t__name__RRRRR(((s+/usr/local/lib/python2.7/test/test_heapq.pyRs tTestHeapcBs•eZdZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd „Zd „Zd„ZRS(cCs@g}g}|j|ƒxMtdƒD]?}tjƒ}|j|ƒ|jj||ƒ|j|ƒq&Wg}x6|r§|jj|ƒ}|j|ƒ|j|ƒqrW|}|jƒ|j||ƒ|j|ƒ|j t |jjgƒy9|j t |jjddƒ|j t |jjdƒWnt k r;nXdS(Ni( tcheck_invarianttrangetrandomtappendtmoduleR RtsortRt assertRaisest TypeErrortNonetAttributeError(Rtheaptdatatititemtresultst data_sorted((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_push_pops.        cCsOxHt|ƒD]:\}}|r |dd?}|j|||kƒq q WdS(Ni(t enumeratet assertTrue(RR%tposR(t parentpos((s+/usr/local/lib/python2.7/test/test_heapq.pyR;scCsvxVtdƒD]H}gt|ƒD]}tjƒ^q }|jj|ƒ|j|ƒq W|jt|jjdƒdS(Ni(RRRRRR!R"R#(RtsizetdummyR%((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_heapifyBs %cCsŸgtdƒD]}tjdƒ^q }g}xF|D]>}|jj||ƒt|ƒdkr5|jj|ƒq5q5W|jƒ|j|t |ƒdƒdS(NièiÐi iöÿÿÿ( RRt randrangeRR tlenRR Rtsorted(RR'R&R%R(((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_naive_nbestJs(  ccs3yx|jj|ƒVqWntk r.nXdS(N(RRt IndexError(RR%((s+/usr/local/lib/python2.7/test/test_heapq.pytheapiterTs  cCsûgtdƒD]}tjdƒ^q }|d }|jj|ƒx8|dD],}||dkrM|jj||ƒqMqMW|jt|j|ƒƒt |ƒdƒ|j t |jjdƒ|j t |jjddƒ|j t |jjgdƒdS(NièiÐi iiöÿÿÿ(RRR3RRR RtlistR8R5R!R"R#R7(RR'R&R%R(((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_nbest\s( )cCs¶gtdƒD]}tjdƒ^q }|d }|jj|ƒx%|dD]}|jj||ƒqMW|jt|j|ƒƒt |ƒdƒ|j|jjgdƒdƒdS(NièiÐi iöÿÿÿtx( RRR3RRR RR9R8R5(RR'R&R%R(((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_nbest_with_pushpopns( )cCs"g}|jj|dƒ}|j||fgdfƒdg}|jj|dƒ}|j||fdgdfƒ|jt|dƒtƒ|jt|ƒtƒdg}|jj|dƒ}|j||fdgdfƒdg}|jj|dƒ}|j||fdgdfƒdS(Ni g$@ii i (RR Rttypetinttfloat(RthR;((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_heappushpopws   cCsáxÚtdƒD]Ì}tjdƒ}gt|ƒD]}tjdƒ^q/}|d@rn|}|jj|ƒn*g}x!|D]}|jj||ƒq{Wgt|ƒD]}|jj|ƒ^q¥}|j|t |ƒƒq WdS(Nidi2ii( txrangeRR3RRRR RRR5(RttrialR0R'R&R%R(t heap_sorted((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_heapsortŠs(  +cCs©g}xOttjdƒƒD]8}td„ttjdƒƒDƒƒ}|j|ƒqW|jtt|Œƒt|j j |Œƒƒ|jt|j j ƒƒgƒdS(Nicss|]}tjdƒVqdS(ièN(RR3(t.0tj((s+/usr/local/lib/python2.7/test/test_heapq.pys œsi ( RBRR3R5RRRtchainR9Rtmerge(RtinputsR'trow((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_merge™s %.cCsBd„}|jtƒ$t|jj|ƒ|ƒƒƒWdQXdS(Ncss6ttdƒƒ}xtdƒD]}||VqWdS(Ni i(R9R(tsR'((s+/usr/local/lib/python2.7/test/test_heapq.pytiterable£s(R!R7R9RRI(RRN((s+/usr/local/lib/python2.7/test/test_heapq.pyt(test_merge_does_not_suppress_index_error¡s cCsædtfd„ƒY}ggggg}x^tdƒD]P}tjdƒ}tjdƒ}||ƒ}||f|_||j|ƒq5Wx|D]}|jƒqWg|jj|ŒD]}|j^q·}|j |t |ƒƒdS(NtIntcBseZRS((RR(((s+/usr/local/lib/python2.7/test/test_heapq.pyRP«si Niiô( R>RRR3tpairRR RRIRR5(RRPRJR'tstreamR;tobjtresult((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_merge_stabilityªs  (c Cs»gtdƒD]}tjdƒ|f^q }x†dd„fD]u}xld D]d}|j|jj||ƒt|ƒ| ƒ|j|jj||d |ƒt|d |ƒ| ƒqKWq>WdS(NièiÐcSs|dddS(Nii#iÐ((R;((s+/usr/local/lib/python2.7/test/test_heapq.pyt»siiii idiiçiLtkey( iiii idiiçièiL(RRR3R#RRt nsmallestR5(RR'R&tftn((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_nsmallest¹s . )c CsÇgtdƒD]}tjdƒ|f^q }x’dd„fD]}xxdD]p}|j|jj||ƒt|d tƒ| ƒ|j|jj||d |ƒt|d |d tƒ| ƒqKWq>WdS(NièiÐcSs|dddS(Nii#iÐ((R;((s+/usr/local/lib/python2.7/test/test_heapq.pyRVÃsiiii idiiçiLtreverseRW( iiii idiiçièiL( RRR3R#RRtnlargestR5tTrue(RR'R&RYRZ((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_nlargestÁs. cs¢‡fd†}ddd„ƒY}dd d„ƒY}gtdƒD]}tjƒ^qB}t|dtƒ}ˆj|||ƒ|ƒˆj|||ƒ|ƒdS( NcsQt||ƒ}ˆjj|ƒgtt|ƒƒD]}ˆjj|ƒj^q2S(N(tmapRRRR4RR;(R&tcompR'(R(s+/usr/local/lib/python2.7/test/test_heapq.pythsortÌstLTcBseZd„Zd„ZRS(cSs ||_dS(N(R;(RR;((s+/usr/local/lib/python2.7/test/test_heapq.pyt__init__ÑscSs|j|jkS(N(R;(Rtother((s+/usr/local/lib/python2.7/test/test_heapq.pyt__lt__Ós(RRRdRf(((s+/usr/local/lib/python2.7/test/test_heapq.pyRcÐs tLEcBseZd„Zd„ZRS(cSs ||_dS(N(R;(RR;((s+/usr/local/lib/python2.7/test/test_heapq.pyRdÖscSs|j|jkS(N(R;(RRe((s+/usr/local/lib/python2.7/test/test_heapq.pyt__le__Øs(RRRdRh(((s+/usr/local/lib/python2.7/test/test_heapq.pyRgÕs idR\(((RRR5R^R(RRbRcRgR'R&ttarget((Rs+/usr/local/lib/python2.7/test/test_heapq.pyttest_comparison_operatorÊs%N(RRR#RR+RR2R6R8R:R<RARERLRORUR[R_Rj(((s+/usr/local/lib/python2.7/test/test_heapq.pyRs            tTestHeapPythoncBseZeZRS((RRRR(((s+/usr/local/lib/python2.7/test/test_heapq.pyRkàssrequires _heapqt TestHeapCcBseZeZRS((RRRR(((s+/usr/local/lib/python2.7/test/test_heapq.pyRlästLenOnlycBseZdZd„ZRS(s:Dummy sequence class defining __len__ but not __getitem__.cCsdS(Ni ((R((s+/usr/local/lib/python2.7/test/test_heapq.pyt__len__ís(RRt__doc__Rn(((s+/usr/local/lib/python2.7/test/test_heapq.pyRmëstGetOnlycBseZdZd„ZRS(s:Dummy sequence class defining __getitem__ but not __len__.cCsdS(Ni ((Rtndx((s+/usr/local/lib/python2.7/test/test_heapq.pyt __getitem__òs(RRRoRr(((s+/usr/local/lib/python2.7/test/test_heapq.pyRpðstCmpErrcBseZdZd„ZRS(s;Dummy element that always raises an error during comparisoncCs t‚dS(N(tZeroDivisionError(RRe((s+/usr/local/lib/python2.7/test/test_heapq.pyt__cmp__÷s(RRRoRu(((s+/usr/local/lib/python2.7/test/test_heapq.pyRsõsccsx|D] }|VqWdS(sRegular generatorN((tseqnR'((s+/usr/local/lib/python2.7/test/test_heapq.pytRús tGcBs eZdZd„Zd„ZRS(sSequence using __getitem__cCs ||_dS(N(Rv(RRv((s+/usr/local/lib/python2.7/test/test_heapq.pyRdscCs |j|S(N(Rv(RR'((s+/usr/local/lib/python2.7/test/test_heapq.pyRrs(RRRoRdRr(((s+/usr/local/lib/python2.7/test/test_heapq.pyRxÿs tIcBs)eZdZd„Zd„Zd„ZRS(s Sequence using iterator protocolcCs||_d|_dS(Ni(RvR'(RRv((s+/usr/local/lib/python2.7/test/test_heapq.pyRds cCs|S(N((R((s+/usr/local/lib/python2.7/test/test_heapq.pyt__iter__ scCsD|jt|jƒkr!t‚n|j|j}|jd7_|S(Ni(R'R4Rvt StopIteration(Rtv((s+/usr/local/lib/python2.7/test/test_heapq.pytnext s  (RRRoRdRzR}(((s+/usr/local/lib/python2.7/test/test_heapq.pyRys  tIgcBs eZdZd„Zd„ZRS(s9Sequence using iterator protocol defined with a generatorcCs||_d|_dS(Ni(RvR'(RRv((s+/usr/local/lib/python2.7/test/test_heapq.pyRds ccsx|jD] }|Vq WdS(N(Rv(Rtval((s+/usr/local/lib/python2.7/test/test_heapq.pyRzs(RRRoRdRz(((s+/usr/local/lib/python2.7/test/test_heapq.pyR~s tXcBs eZdZd„Zd„ZRS(s Missing __getitem__ and __iter__cCs||_d|_dS(Ni(RvR'(RRv((s+/usr/local/lib/python2.7/test/test_heapq.pyRds cCsD|jt|jƒkr!t‚n|j|j}|jd7_|S(Ni(R'R4RvR{(RR|((s+/usr/local/lib/python2.7/test/test_heapq.pyR}!s  (RRRoRdR}(((s+/usr/local/lib/python2.7/test/test_heapq.pyR€s tNcBs eZdZd„Zd„ZRS(sIterator missing next()cCs||_d|_dS(Ni(RvR'(RRv((s+/usr/local/lib/python2.7/test/test_heapq.pyRd)s cCs|S(N((R((s+/usr/local/lib/python2.7/test/test_heapq.pyRz,s(RRRoRdRz(((s+/usr/local/lib/python2.7/test/test_heapq.pyR's tEcBs)eZdZd„Zd„Zd„ZRS(sTest propagation of exceptionscCs||_d|_dS(Ni(RvR'(RRv((s+/usr/local/lib/python2.7/test/test_heapq.pyRd1s cCs|S(N((R((s+/usr/local/lib/python2.7/test/test_heapq.pyRz4scCs dddS(Nii((R((s+/usr/local/lib/python2.7/test/test_heapq.pyR}6s(RRRoRdRzR}(((s+/usr/local/lib/python2.7/test/test_heapq.pyR‚/s  tScBs)eZdZd„Zd„Zd„ZRS(sTest immediate stopcCsdS(N((RRv((s+/usr/local/lib/python2.7/test/test_heapq.pyRd;scCs|S(N((R((s+/usr/local/lib/python2.7/test/test_heapq.pyRz=scCs t‚dS(N(R{(R((s+/usr/local/lib/python2.7/test/test_heapq.pyR}?s(RRRoRdRzR}(((s+/usr/local/lib/python2.7/test/test_heapq.pyRƒ9s  (RHtimapcCs(ttd„ttt|ƒƒƒƒƒS(s Test multiple tiers of iteratorscSs|S(N((R;((s+/usr/local/lib/python2.7/test/test_heapq.pyRVEs(RHR„RwR~Rx(Rv((s+/usr/local/lib/python2.7/test/test_heapq.pytLCst SideEffectLTcBseZd„Zd„ZRS(cCs||_||_dS(N(tvalueR%(RR‡R%((s+/usr/local/lib/python2.7/test/test_heapq.pyRdHs cCsg|j(|j|jkS(N(R%R‡(RRe((s+/usr/local/lib/python2.7/test/test_heapq.pyRfLs (RRRdRf(((s+/usr/local/lib/python2.7/test/test_heapq.pyR†Gs tTestErrorHandlingcBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS(cCs‘x9|jj|jjfD]}|jttf|dƒqWxN|jj|jj|jj|jj fD]"}|jttf|ddƒqgWdS(Ni ( RRRR!R"R$R R R]RX(RRY((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_non_sequenceTs cCsÁx<|jj|jjfD]"}|jttf|tƒƒqWx?|jj|jjfD]%}|jttf|tƒdƒqXWx9|jj |jj fD]}|jt|dtƒƒqšWdS(Ni i( RRRR!R"R$RmR R R]RX(RRY((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_len_only[s  #cCsÄtƒtƒtƒg}x3|jj|jjfD]}|jt||ƒq1Wx6|jj|jjfD]}|jt||dƒqgWx6|jj|jj fD]}|jt|d|ƒq WdS(Ni i( RsRRRR!RtR R R]RX(RtseqRY((s+/usr/local/lib/python2.7/test/test_heapq.pyt test_get_onlycscCsdx]|jj|jj|jj|jj|jj|jjfD]}|jtt f|dƒq=WdS(Ni ( RRRR R R]RXR!R"R$(RRY((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_arg_parsinglsc Cs6x/|jj|jjfD]}x ddtdƒd tdddƒfD]ã}xgttttt fD]P}t j d t fd t ƒ-|j|d ||ƒƒ|d |ƒƒWdQXqcW|j|d t|ƒƒgƒ|jt|d t|ƒƒ|jt|d t|ƒƒ|jt|d t|ƒƒqGWqWdS( Nt123tiètdog333333ó?iÐi˜is%comparing unequal types not supportedtquieti(Rg333333ó?(RR]RXRRBRxRyR~R…RwRtcheck_py3k_warningstDeprecationWarningR^RRƒR!R"R€RRtR‚(RRYRMtg((s+/usr/local/lib/python2.7/test/test_heapq.pyttest_iterable_argsrs.2c seg‰ˆj‡fd†tdƒDƒƒ|jttfƒ!|jjˆtdˆƒƒWdQXdS(Nc3s|]}t|ˆƒVqdS(N(R†(RFR'(R%(s+/usr/local/lib/python2.7/test/test_heapq.pys ƒsiÈi(textendRR!R7t RuntimeErrorRR R†(R((R%s+/usr/local/lib/python2.7/test/test_heapq.pyttest_heappush_mutating_heaps#csYg‰ˆj‡fd†tdƒDƒƒ|jttfƒ|jjˆƒWdQXdS(Nc3s|]}t|ˆƒVqdS(N(R†(RFR'(R%(s+/usr/local/lib/python2.7/test/test_heapq.pys ŠsiÈ(R–RR!R7R—RR(R((R%s+/usr/local/lib/python2.7/test/test_heapq.pyttest_heappop_mutating_heapˆs#N( RRR#RR‰RŠRŒRR•R˜R™(((s+/usr/local/lib/python2.7/test/test_heapq.pyRˆQs     tTestErrorHandlingPythoncBseZeZRS((RRRR(((s+/usr/local/lib/python2.7/test/test_heapq.pyRšstTestErrorHandlingCcBseZeZRS((RRRR(((s+/usr/local/lib/python2.7/test/test_heapq.pyR›”scCs tttttg}tj|Œ|rœttdƒrœddl }dgd}xAt t |ƒƒD]-}tj|Œ|j ƒtjƒ||sD    Ä        ?