ó {G_Tc@stddlZddlZddlZddlZddlZddlZddlmZyddlZWne k rdZnXej Z dZ erÕdej fd„ƒYZdejfd„ƒYZd„Znejed ƒd ejfd „ƒYƒZd efd „ƒYZdejfd„ƒYZdejfd„ƒYZdd„ZedkrpedeƒndS(iÿÿÿÿN(t test_supportsQUIT t echo_servercBs eZdZd„Zd„ZRS(icCsVtjj|ƒ||_tjtjtjƒ|_tj |jƒ|_ d|_ dS(N( t threadingtThreadt__init__teventtsockettAF_INETt SOCK_STREAMtsockRt bind_porttporttNonetstart_resend_event(tselfR((s./usr/local/lib/python2.7/test/test_asynchat.pyRs  cCs|jjdƒ|jjƒ|jjƒ\}}d|_x<t|jkry|jdƒ}|sfPn|j||_q>W|jjtdƒ|_|j r«|j j ƒnyJxC|jró|j |j|j ƒ}t jdƒ|j||_q±WWnnX|jƒ|jjƒdS(Nitgü©ñÒMbP?(R tlistenRtsettaccepttbuffert SERVER_QUITtrecvtreplaceR twaittsendt chunk_sizettimetsleeptclose(Rtconntclienttdatatn((s./usr/local/lib/python2.7/test/test_asynchat.pytruns*      (t__name__t __module__RRR!(((s./usr/local/lib/python2.7/test/test_asynchat.pyRs t echo_clientcBsGeZd„Zd„Zejdkr3d„Znd„Zd„ZRS(cCs\tjj|ƒg|_|jtjtjƒ|jt |fƒ|j |ƒd|_ dS(NR( tasynchatt async_chatRtcontentst create_socketRRRtconnecttHOSTtset_terminatorR(Rt terminatort server_port((s./usr/local/lib/python2.7/test/test_asynchat.pyR@s   cCsdS(N((R((s./usr/local/lib/python2.7/test/test_asynchat.pythandle_connectHstdarwincCsdS(N((R((s./usr/local/lib/python2.7/test/test_asynchat.pyt handle_exptNscCs|j|7_dS(N(R(RR((s./usr/local/lib/python2.7/test/test_asynchat.pytcollect_incoming_dataQscCs |jj|jƒd|_dS(NR(R'tappendR(R((s./usr/local/lib/python2.7/test/test_asynchat.pytfound_terminatorTs( R"R#RR.tsystplatformR0R1R3(((s./usr/local/lib/python2.7/test/test_asynchat.pyR$>s     cCsMtjƒ}t|ƒ}|jƒ|jƒ|jƒtjdƒ||fS(Ng{®Gáz„?(RtEventRtstartRtclearRR(Rts((s./usr/local/lib/python2.7/test/test_asynchat.pytstart_echo_serverYs      s!Threading required for this test.t TestAsynchatcBsŒeZeZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd „Zd „ZRS(cCstjƒ|_dS(N(Rtthreading_setupt_threads(R((s./usr/local/lib/python2.7/test/test_asynchat.pytsetUpgscCstj|jŒdS(N(Rtthreading_cleanupR=(R((s./usr/local/lib/python2.7/test/test_asynchat.pyttearDownjscCsàtjƒ}t|ƒ}||_|jƒ|jƒ|jƒtjdƒt ||j ƒ}|j dƒ|j d|ƒ|j d|ƒ|j t ƒt jd|jddddƒ|jƒ|j|jd d gƒdS( Ng{®Gáz„?shello sworld%ssI'm not dead yet!%stuse_polltcounti,ttimeouts hello worldsI'm not dead yet!(RR6RRR7RR8RRR$R tpushRtasyncoretlooptusepolltjoint assertEqualR'(Rttermt server_chunkRR9tc((s./usr/local/lib/python2.7/test/test_asynchat.pytline_terminator_checkms          cCs%xdD]}|jd|ƒqWdS(Niiis (iii(RM(Rtl((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_line_terminator1ƒs cCs%xdD]}|jd|ƒqWdS(Niiis (iii(RM(RRN((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_line_terminator2ˆs cCs%xdD]}|jd|ƒqWdS(Niiitqqq(iii(RM(RRN((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_line_terminator3s cCsˆtƒ\}}t||jƒ}d}|j|ƒ|jtƒtjd|jddddƒ|jƒ|j |j || gƒdS(Nshello world, I'm not dead yet! RARBi,RCg{®Gáz„?( R:R$R RDRRERFRGRHRIR'(RttermlenR9RRLR((s./usr/local/lib/python2.7/test/test_asynchat.pytnumeric_terminator_check’s   cCs|jdƒ|jdƒdS(Nil(RT(R((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_numeric_terminator1žs cCs|jdƒdS(Nl(RT(R((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_numeric_terminator2¤scCs”tƒ\}}td|jƒ}d}|j|ƒ|jtƒtjd|jddddƒ|j ƒ|j |j gƒ|j |j |ƒdS(Nshello world, I'm not dead yet! RARBi,RCg{®Gáz„?( R:R$R R RDRRERFRGRHRIR'R(RR9RRLR((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_none_terminator§s   cCs“tƒ\}}td|jƒ}d}tj|tddƒ}|j|ƒtjd|j dddd ƒ|j ƒ|j |j d d gƒdS( Ns shello world I'm not dead yet! t buffer_sizeiRARBi,RCg{®Gáz„?s hello worldsI'm not dead yet!( R:R$R R%tsimple_producerRtpush_with_producerRERFRGRHRIR'(RR9RRLRtp((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_simple_producer´s  cCs~tƒ\}}td|jƒ}d}|j|tƒtjd|jddddƒ|jƒ|j |j dd gƒdS( Ns shello world I'm not dead yet! RARBi,RCg{®Gáz„?s hello worldsI'm not dead yet!( R:R$R RZRRERFRGRHRIR'(RR9RRLR((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_string_producer¿s cCs„tƒ\}}td|jƒ}|jdƒ|jtƒtjd|jddddƒ|jƒ|j |j dd d gƒdS( Ns shello world I'm not dead yet! RARBi,RCg{®Gáz„?s hello worldRsI'm not dead yet!( R:R$R RDRRERFRGRHRIR'(RR9RRL((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_empty_lineÉs   cCs½tƒ\}}tjƒ|_td|jƒ}|jdƒ|jtƒ|jƒt j d|j ddddƒ|jj ƒ|j ƒ|j|jgƒ|jt|jƒdkƒdS( Ns shello world I'm not dead yet! RARBi,RCg{®Gáz„?i(R:RR6R R$R RDRtclose_when_doneRERFRGRRHRIR't assertTruetlenR(RR9RRL((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_close_when_doneÔs     (R"R#tFalseRGR>R@RMRORPRRRTRURVRWR\R]R^Rb(((s./usr/local/lib/python2.7/test/test_asynchat.pyR;cs         tTestAsynchat_WithPollcBseZeZRS((R"R#tTrueRG(((s./usr/local/lib/python2.7/test/test_asynchat.pyRdëstTestHelperFunctionscBseZd„ZRS(cCs<|jtjddƒdƒ|jtjddƒdƒdS(Nsqwerty s it qwertydkjfi(RIR%tfind_prefix_at_end(R((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_find_prefix_at_endïs(R"R#Ri(((s./usr/local/lib/python2.7/test/test_asynchat.pyRfîstTestFifocBseZd„Zd„ZRS(cCstjƒ}|jdƒ|jdƒ|jt|ƒdƒ|j|jƒdƒ|j|jƒdƒ|jt|ƒdƒ|j|jƒdƒ|j|jƒtƒ|j|jƒdƒ|jt|ƒdƒ|j|jƒt ƒ|j|jƒdƒdS( Nitaiii(ii(iRk(iN( R%tfifoRDRIRatfirsttpoptis_emptyRcReR (Rtf((s./usr/local/lib/python2.7/test/test_asynchat.pyt test_basicôs   cCsŠtjdddgƒ}|jt|ƒdƒ|j|jƒdƒ|j|jƒdƒ|j|jƒdƒ|j|jƒd ƒdS( Ntxiiii(iRr(ii(ii(iN(R%RlRIRaRnR (RRp((s./usr/local/lib/python2.7/test/test_asynchat.pyttest_given_lists (R"R#RqRs(((s./usr/local/lib/python2.7/test/test_asynchat.pyRjós cCstjttttƒdS(N(Rt run_unittestR;RdRfRj(tverbose((s./usr/local/lib/python2.7/test/test_asynchat.pyt test_main s t__main__Ru(RER%RRtunittestR4ttestRRt ImportErrorR R*RRRR&R$R:t skipUnlesstTestCaseR;RdRfRjRvR"Re(((s./usr/local/lib/python2.7/test/test_asynchat.pyts*0     . ‡