ó {G_Tc@s³ddlZddlmZmZmZmZmZddlZddlZddlm Z m Z m Z ddl Z yddl Z Wnek reZ nXedƒZejeejƒdƒdƒZejeejƒdƒdƒZdejfd „ƒYZd ejfd „ƒYZd efd „ƒYZdeejfd„ƒYZdeejfd„ƒYZded„Zeed„ZdZ d„Z!e"dkr¯e!ƒndS(iÿÿÿÿN(tTESTFNt run_unittestt import_moduletunlinktrequires(tprecisionbigmemtestt_1Gt_4Gtzlibtcopysrequires Compress.copy()srequires Decompress.copy()tChecksumTestCasecBsYeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( cCsB|jtjdƒtjddƒƒ|jtjddƒƒdS(NtitabcIÿÿÿÿ(t assertEqualRtcrc32t assertTrue(tself((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_crc32starts%cCsX|jtjddƒdƒ|jtjddƒdƒ|jtjddƒdƒdS(NR iii°(R RR(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_crc32emptyscCsB|jtjdƒtjddƒƒ|jtjddƒƒdS(NR iR Iÿÿÿÿ(R Rtadler32R(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_adler32start"s%cCsX|jtjddƒdƒ|jtjddƒdƒ|jtjddƒdƒdS(NR iii°(R RR(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_adler32empty&scCs|j|d@|d@ƒdS(Nlÿÿ(R (Rtseentexpected((s*/usr/local/lib/python2.7/test/test_zlib.pyt assertEqual32+scCs¾|jtjddƒdƒ|jtjddƒdƒ|jtjddƒdƒ|jtjddƒdƒ|jtjdƒtjddƒƒ|jtjdƒtjddƒƒdS(Ntpenguinil !ƒKii”ª¶CiöÏ i÷Ö (RRRRR (R((s*/usr/local/lib/python2.7/test/test_zlib.pyt test_penguins0s %cCsrd}|jtj|ƒdƒ|jtjdƒdƒ|jtj||ƒdƒ|jtjdƒdƒdS(s7test issue1202 compliance: signed crc32, adler32 in 2.xtabcdefghijklmnopi“À:”tspami=ÿÚCi Õi²ON(R RRR(Rtfoo((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_abcdefghijklmnop9s cCsNd}|jtj|ƒtj|ƒƒ|jtjdƒtjdƒƒdS(NRR(R tbinasciiRR(RR((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_same_as_binascii_crc32Bs"cCs||jtjddƒtjddƒƒ|jtjddƒtjddƒƒ|jtjdd ƒtjdd ƒƒdS( NthamiÿÿÿÿlÿÿRi'Ðÿl' iiI€i€I€(R RR(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_negative_crc_iv_inputGs (( t__name__t __module__RRRRRRRR R"(((s*/usr/local/lib/python2.7/test/test_zlib.pyR s      tExceptionTestCasecBs,eZd„Zd„Zd„Zd„ZRS(cCs |jtjtjddƒdS(NtERRORi (t assertRaisesRterrortcompress(R((s*/usr/local/lib/python2.7/test/test_zlib.pyt test_badlevelTscCsI|jttjdtjdƒ|jttjdtjtjdƒdS(Nii(R't ValueErrorRt compressobjtDEFLATEDt MAX_WBITS(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_badcompressobjZs cCs|jttjdƒdS(Niÿÿÿÿ(R'R+Rt decompressobj(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_baddecompressobjascCs<|jttjƒjdƒ|jttjƒjdƒdS(Niiÿÿÿÿ(R'R+RR0tflush(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompressobj_badflushes(R#R$R*R/R1R3(((s*/usr/local/lib/python2.7/test/test_zlib.pyR%Rs   tBaseCompressTestCasecBseZd„Zd„ZRS(cCsŠd}dd|}djgtdƒD]&}tj|tjd|ƒƒ^q'ƒ}||t|ƒd}z||ƒWdd}XdS( Nis%%0%dxiR i iii(tjointrangeRta2b_hextrandomt getrandbitstlentNone(Rtsizet compress_funct_1Mtfmttitdata((s*/usr/local/lib/python2.7/test/test_zlib.pytcheck_big_compress_bufferls 9cCs}d|}ztj|dƒ}Wdd}X||ƒ}z9|jt|ƒ|ƒ|jt|jdƒƒdƒWdd}XdS(Ntxii(RR)R;R R:tstrip(RR<tdecompress_funcRAt compressed((s*/usr/local/lib/python2.7/test/test_zlib.pytcheck_big_decompress_buffer{s  #(R#R$RBRG(((s*/usr/local/lib/python2.7/test/test_zlib.pyR4ks tCompressTestCasecBsgeZd„Zd„Zd„Zeded ddƒd„ƒZeded ddƒd „ƒZRS( cCs,tjtƒ}|jtj|ƒtƒdS(N(RR)t HAMLET_SCENER t decompress(RRC((s*/usr/local/lib/python2.7/test/test_zlib.pyt test_speechscCs6td}tj|ƒ}|jtj|ƒ|ƒdS(Ni€(RIRR)R RJ(RRARC((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_speech128‘s cCs3tjtƒ}|jtjdtj|d ƒdS(NsAError -5 while decompressing data: incomplete or truncated streamiÿÿÿÿ(RR)RItassertRaisesRegexpR(RJ(RRC((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_incomplete_stream—s R<itmemuseicCsd„}|j||ƒdS(NcSstj|dƒS(Ni(RR)(ts((s*/usr/local/lib/python2.7/test/test_zlib.pyt¢s(RB(RR<R)((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_big_compress_buffer s icCs|j|tjƒdS(N(RGRRJ(RR<((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_big_decompress_buffer¥sii( R#R$RKRLRNRRRRRS(((s*/usr/local/lib/python2.7/test/test_zlib.pyRH‹s    "tCompressObjectTestCasecBsKeZd„Zd„Zd„Zedddd„Zd„Zdddd„Z ed„Z d „Z d „Z d „Z d „Zejeed ƒdƒd„ƒZd„Zd„Zd„Zed„ƒZed„ƒZd„Zed„ƒZed„ƒZeded ddƒd„ƒZ eded!ddƒd„ƒZ!RS("cCsŠtd}tjƒ}|j|ƒ}|jƒ}|jtj|jƒtjƒ}|j||ƒ}|jƒ}|j |||ƒdS(Ni€( RIRR,R)R2R'R(R0RJR (RRAtcotx1tx2tdcoty1ty2((s*/usr/local/lib/python2.7/test/test_zlib.pyt test_pair¬s     c Cs d}tj}d}d}tj}tj|||||ƒ}|jtƒ}|jƒ}tj|ƒ} | j||ƒ} | jƒ} |j t| | ƒdS(Niiôÿÿÿi ( RR-t Z_FILTEREDR,R)RIR2R0RJR ( RtleveltmethodtwbitstmemleveltstrategyRURVRWRXRYRZ((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_compressoptions¸s    c CsÊtd}tjƒ}g}xAtdt|ƒdƒD]'}|j|j|||d!ƒƒq5W|j|jƒƒdj|ƒ}tj ƒ}|j dj|ƒƒ}|jƒ}|j |||ƒdS(Ni€iiR ( RIRR,R6R:tappendR)R2R5R0RJR ( RRARUtbufsR@tcombufRXRYRZ((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_compressincrementalÇs  %  ii@c Cs¯|p t}|d}tjƒ}g}xAtdt|ƒ|ƒD]'}|j|j||||!ƒƒqAW|j|jƒƒdj|ƒ} |j |tj | ƒƒtj ƒ} g}xdtdt| ƒ|ƒD]J}|j| j | |||!ƒƒ|j d| j dt| j ƒƒqÒW|r<|j| jƒƒn3x0t rn| j dƒ} | rj|j| ƒq?Pq?W|j d| j dt| j ƒƒ|j |dj|ƒƒdS(Ni€iR s!(A) uct should be '': not %d longs!(B) uct should be '': not %d long(RIRR,R6R:RcR)R2R5R RJR0tunconsumed_tailtTrue( RR2tsourcetcxtdcxRARURdR@ReRXtchunk((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompincÖs6   % ! cCs|jdtƒdS(NR2(RmRh(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompincflushùsc CsV|p t}|d}tjƒ}g}xAtdt|ƒ|ƒD]'}|j|j||||!ƒƒqAW|j|jƒƒdj|ƒ}|j |tj |ƒdƒtj ƒ} g}|} x^| r"| j | |ƒ} |j t| ƒ|kdt| ƒ|fƒ|j| ƒ| j } qÅW|j| jƒƒ|j |dj|ƒdƒdS(Ni€iR scompressed data failureschunk too big (%d>%d)sWrong data retrieved(RIRR,R6R:RcR)R2R5R RJR0t assertFalseRg( RRiRjRkRARURdR@ReRXtcbRl((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompimaxüs*   %    c Cs¿td}tjƒ}g}xAtdt|ƒdƒD]'}|j|j|||d!ƒƒq5W|j|jƒƒdj|ƒ}|j |tj |ƒdƒtj ƒ}g}|}xr|r*dt|ƒd} |j || ƒ} |j t| ƒ| kdt| ƒ| fƒ|j| ƒ|j }q¹W|rG|j|jƒƒnXxU| rž|j d| ƒ} |j t| ƒ| kdt| ƒ| fƒ|j| ƒqJW|j |dj|ƒd ƒdS( Ni€iiR scompressed data failureii schunk too big (%d>%d)sWrong data retrieved(RIRR,R6R:RcR)R2R5R RJR0RoRg( RR2RARURdR@ReRXRpt max_lengthRl((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompressmaxlens6  %     cCs|jdtƒdS(NR2(RsRh(R((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompressmaxlenflush7scCs<tjƒ}|jt|jddƒ|jd|jƒdS(NR iÿÿÿÿ(RR0R'R+RJR Rg(RRX((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_maxlenmisc:s cCsQd}tjƒ}|j|dƒ}||j|jƒ7}|j|jdƒdS(Ns xœKLJMiR (RR0RJRgR (RtcdataRXtddata((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_clear_unconsumed_tail@s  c Csdddg}g|D]$}tt|ƒrtt|ƒ^q}td}x³|D]«}x¢tdƒD]”}tj|ƒ}|j|d ƒ}|j|ƒ}|j|dƒ} |jƒ} |jtj dj ||| | gƒƒ|d||fƒ~qdWqQWdS( Nt Z_NO_FLUSHt Z_SYNC_FLUSHt Z_FULL_FLUSHii i¸ R s*Decompress failed: flush mode=%i, level=%i( thasattrRtgetattrRIR6R,R)R2R RJR5( Rtsync_opttoptRAtsyncR]tobjtatbtctd((s*/usr/local/lib/python2.7/test/test_zlib.pyt test_flushesIs $   'Rzsrequires zlib.Z_SYNC_FLUSHc Csåddl}tjtjƒ}tjƒ}y|jƒ}Wn;tk rwy|jƒ}Wqxtk rs|}qxXnX|jdƒt ddd|ƒ}|j |ƒ}|j tj ƒ}|j ||ƒ}|j||dƒdS(Niÿÿÿÿiiit generators17K random source doesn't matchiD(R8RR,tZ_BEST_COMPRESSIONR0t WichmannHilltAttributeErrortRandomtseedtgenblockR)R2RzRJR ( RR8RURXtgenRAtfirsttsecondtexpanded((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_odd_flush]s      cCsKtjtjƒ}|j|jƒƒtjƒ}|j|jƒdƒdS(NR (RR,RˆRR2R0R (RRURX((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_empty_flushs cCsd}|jtj|ƒdƒ|jtjtj|d ƒtjƒ}|j|d ƒ}||jƒ7}|j|dƒdS(Ns xœKËÏ‚ERiûÿÿÿ(R RRJR'R(R0R2(RRCRXty((s*/usr/local/lib/python2.7/test/test_zlib.pyt!test_decompress_incomplete_stream‰s cCsgd}d}tj|ƒ}tjƒ}|j|dƒ~tj|ƒ}|j|jƒ|dƒdS(NtabcdefghijklmnopqrstuvwxyztQWERTYUIOPASDFGHJKLZXCVBNMi(RR)R0RJR R2(Rtinput1tinput2RARX((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_flush_with_freed_input–s c Cst}tjƒ}tjtjƒ}g}|j|j|ƒƒ|jƒ}|}|j|j|ƒƒ|j|jƒƒdj |ƒ}|j|j|ƒƒ|j|jƒƒdj |ƒ}|j tj |ƒ||ƒ|j tj |ƒ||ƒdS(NR ( RItswapcaseRR,RˆRcR)R R2R5R RJ( Rtdata0tdata1tc0tbufs0tc1tbufs1ts0ts1((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_compresscopy¢s  cCs:tjƒ}|jtƒ|jƒ|jt|jƒdS(N(RR,R)RIR2R'R+R (RR„((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_badcompresscopy¹s   c Csnd}d}tj|ƒ}||}xBdD]:}x1ddt|ƒt|ƒfD]}tjƒ}d}x°tdt|ƒ|ƒD]–} | t|ƒkr°|j|jdƒn|dkrð||j|| | |!ƒ7}|j|jdƒq‚||j|j|| | |!|ƒ7}q‚W||j ƒ7}|j||ƒ|j|jdƒ|j|j|ƒqQWq,WdS( NR–t 0123456789iièiiR (iiè( RR)R:R0R6R t unused_dataRJRgR2( RRit remainderR”RCtmaxlentstepRXRAR@((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompress_unused_dataÁs(  %   #c CsÊt}tj|ƒ}tjƒ}g}|j|j|d ƒƒ|jƒ}|}|j|j|dƒƒdj|ƒ}|j|j|dƒƒdj|ƒ}|j||ƒ|j||ƒdS(Ni R ( RIRR)R0RcRJR R5R ( RRAtcomptd0RŸtd1R¡R¢R£((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_decompresscopyÚs  cCsItjtƒ}tjƒ}|j|ƒ|jƒ|jt|jƒdS(N( RR)RIR0RJR2R'R+R (RRAR…((s*/usr/local/lib/python2.7/test/test_zlib.pyttest_baddecompresscopyðs    R<iROics2tjdƒ‰‡fd†}|j||ƒdS(Nicsˆj|ƒˆjƒS(N(R)R2(RP(R„(s*/usr/local/lib/python2.7/test/test_zlib.pyRQþs(RR,RB(RR<R)((R„s*/usr/local/lib/python2.7/test/test_zlib.pyRRûsics/tjƒ‰‡fd†}|j||ƒdS(Ncsˆj|ƒˆjƒS(N(RJR2(RP(R…(s*/usr/local/lib/python2.7/test/test_zlib.pyRQs(RR0RG(RR<RJ((R…s*/usr/local/lib/python2.7/test/test_zlib.pyRSs Nii("R#R$R[RbRftFalseR;RmRnRqRsRtRuRxR†tunittestt skipUnlessR|RR’R“R•Rštrequires_Compress_copyR¤R¥R«trequires_Decompress_copyR¯R°RRRRRS(((s*/usr/local/lib/python2.7/test/test_zlib.pyRTªs.  #    !   "ic Cs¸|dk r|j|ƒn|j}||ks=|dkrF|}ng}xXtd||ƒD]D}|jdjgt|ƒD]}t|ddƒƒ^q~ƒƒq_Wdj|ƒ| S(sDlength-byte stream of random data from a seed (in step-byte blocks).iiR iÿN(R;RŒtrandintR6RcR5tchr(RŒtlengthRªR‡R¶tblocksR@RC((s*/usr/local/lib/python2.7/test/test_zlib.pyRs   3cCsQ|dk r|j|ƒn|jdƒ}gt|ƒD]}|j|ƒ^q8S(s=Return a list of number lines randomly chosen from the sources N(R;RŒtsplitR6tchoice(RitnumberRŒR‡tsourcestn((s*/usr/local/lib/python2.7/test/test_zlib.pyt choose_liness s LAERTES O, fear me not. I stay too long: but here my father comes. Enter POLONIUS A double blessing is a double grace, Occasion smiles upon a second leave. LORD POLONIUS Yet here, Laertes! aboard, aboard, for shame! The wind sits in the shoulder of your sail, And you are stay'd for. There; my blessing with thee! And these few precepts in thy memory See thou character. Give thy thoughts no tongue, Nor any unproportioned thought his act. Be thou familiar, but by no means vulgar. Those friends thou hast, and their adoption tried, Grapple them to thy soul with hoops of steel; But do not dull thy palm with entertainment Of each new-hatch'd, unfledged comrade. Beware Of entrance to a quarrel, but being in, Bear't that the opposed may beware of thee. Give every man thy ear, but few thy voice; Take each man's censure, but reserve thy judgment. Costly thy habit as thy purse can buy, But not express'd in fancy; rich, not gaudy; For the apparel oft proclaims the man, And they in France of the best rank and station Are of a most select and generous chief in that. Neither a borrower nor a lender be; For loan oft loses both itself and friend, And borrowing dulls the edge of husbandry. This above all: to thine ownself be true, And it must follow, as the night the day, Thou canst not then be false to any man. Farewell: my blessing season this in thee! LAERTES Most humbly do I take my leave, my lord. LORD POLONIUS The time invites you; go; your servants tend. LAERTES Farewell, Ophelia; and remember well What I have said to you. OPHELIA 'Tis in my memory lock'd, And you yourself shall keep the key of it. LAERTES Farewell. cCstttttƒdS(N(RR R%RHRT(((s*/usr/local/lib/python2.7/test/test_zlib.pyt test_mainas t__main__(#R²ttest.test_supportRRRRRRR8RRRtsystmmapt ImportErrorR;RR³R|R,R´R0RµtTestCaseR R%tobjectR4RHRTRR¿RIRÀR#(((s*/usr/local/lib/python2.7/test/test_zlib.pyts8 (        ; ÿ_G