{G_Tc@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZmZddlmZyddlZWnek rdZnXdd,dYZdd-dYZd d.d YZd d/d YZd ZdejfdYZdejfdYZdejfdYZdejfdYZdefdYZ ej!e"edddejfdYZ#dej$fdYZ%dej$fdYZ&d e%fd!YZ'd"ejfd#YZ(d$e(fd%YZ)ej!e"ed&d'd(e(fd)YZ*d*Z+e,d+kre+ndS(0iN(t test_support(tTESTFNt run_unittesttunlinktHOST(tStringIOt dummysocketcBs#eZdZdZdZRS(cCs t|_dS(N(tFalsetclosed(tself((s./usr/local/lib/python2.7/test/test_asyncore.pyt__init__scCs t|_dS(N(tTrueR(R ((s./usr/local/lib/python2.7/test/test_asyncore.pytclosescCsdS(Ni*((R ((s./usr/local/lib/python2.7/test/test_asyncore.pytfilenos(t__name__t __module__R R R (((s./usr/local/lib/python2.7/test/test_asyncore.pyRs  t dummychannelcBseZdZdZRS(cCst|_dS(N(Rtsocket(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR !scCs|jjdS(N(RR (R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR $s(RRR R (((s./usr/local/lib/python2.7/test/test_asyncore.pyR s t exitingdummycBs,eZdZdZeZeZeZRS(cCsdS(N((R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR (scCstjdS(N(tasyncoretExitNow(R ((s./usr/local/lib/python2.7/test/test_asyncore.pythandle_read_event+s(RRR Rthandle_write_eventt handle_closethandle_expt_event(((s./usr/local/lib/python2.7/test/test_asyncore.pyR's   t crashingdummycBs5eZdZdZeZeZeZdZRS(cCs t|_dS(N(Rt error_handled(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR 3scCs tdS(N(t Exception(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR6scCs t|_dS(N(R R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyt handle_error=s(RRR RRRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyR2s   c Cszy#|jd|j\}}Wntjk r<nXd}x|dkrtj|ggg\}}}|r|jd} |j| jddd| krPqn|d8}tj dqFW|j Wd|j |j XdS( Niiii s tig{Gz?( tlistentacceptRttimeouttselecttrecvtwritetreplacettimetsleepR tset( tevttbuftservtconntaddrtntrtwtetdata((s./usr/local/lib/python2.7/test/test_asyncore.pytcapture_serverAs& !   tHelperFunctionTestscBsYeZdZejeedddZdZdZ dZ dZ RS(cCst}|jtjtj||jtjtj||jtjtj|t}tj||j|j t t}tj||j|j t t}tj||j|j t dS(N( Rt assertRaisesRRtreadR#t _exceptionRt assertEqualRR (R ttr1ttr2((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_readwriteexc[s       tpollsselect.poll requiredc CsHd}tjdftjdftjdftjdftjdftjdff}dd dY}x|D]\}}|}|jt||t t j ||x-|D]%}|jt||||kqWt }|j t jt j ||t} |j| jt t j | ||j| jtqnWdS( NR5texptR#RRttestobjcBs>eZdZdZdZdZdZdZRS(cSs1t|_t|_t|_t|_t|_dS(N(RR5R#RR<R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR s     cSs t|_dS(N(R R5(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscSs t|_dS(N(R R#(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscSs t|_dS(N(R R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscSs t|_dS(N(R R<(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscSs t|_dS(N(R R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRs(RRR RRRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyR=s      (sreadsexptswritescloseds error_handled((R!tPOLLINtPOLLPRItPOLLOUTtPOLLERRtPOLLHUPtPOLLNVALR7tgetattrRRt readwriteRR4RRRR ( R t attributestexpectedR=tflagt expectedattrttobjtattrR8R9((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_readwritexs(       #  cCs|jtdS(N(tcloseall_checkR(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_closeallscCs|jtdS(N(RMR (R ((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_closeall_defaultscCsg}i}xJtdD]<}t}|j||j|jjt|||(RRrR7treprtid(R Ru((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_reprs cCstj}t}tj}d}d}z'|t_|j||j|Wd|t_X|jj}|j|d|d|gdS(NsLovely spam! Wonderful spam!sI don't like spam!slog: %s( RRrRR\tstderrtlogtgetvaluet splitlinesR7(R RutfpRztl1tl2tlines((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_logs      c Cstj}t}tj}d}d}d}z:|t_|j|d|j||j|dWd|t_X|jj}d|d|d|g}|j||dS( Ns#Have you got anything without spam?s.Why can't she have egg bacon spam and sausage?sTHAT'S got spam in it!tEGGStSPAMsEGGS: %ssinfo: %ssSPAM: %s( RRrRR\tstdouttlog_infoR|R}R7( R RuR~RRRtl3RRG((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_log_infos      cCstj}d|_t}tj}z?|t_|j|j|j|j |j Wd|t_X|j j }dddddg}|j ||dS(Ns*warning: unhandled incoming priority eventswarning: unhandled read eventswarning: unhandled write events warning: unhandled connect eventswarning: unhandled accept event((RRrtignore_log_typesRR\Rt handle_exptt handle_readt handle_writethandle_connectt handle_acceptR|R}R7(R RuR~RRRG((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_unhandleds&           cCstjtj}|jtdt|dtjdtc}tj d|j }|j |tj |j t |d|jt|djtWdQXdS(Nsdispatcher instancetfootrecordtalwaysii(RRrRtassertRaisesRegexptAttributeErrorRDtwarningstcatch_warningsR t simplefiltertfamilyR7tAF_INETRTt assertTruet issubclasstcategorytDeprecationWarning(R RuR/R((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_issue_85946s    cCsftjtj}ttdr@|j|tjtjntjd}|j|dkdS(NtstrerroriR( Rt _strerrorterrnotEPERMRnR`R7RR(R terr((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_strerrorGs ( RRRpRqRvRyRRRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRos        tdispatcherwithsend_noreadcBseZdZdZRS(cCstS(N(R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRsQscCsdS(N((R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRTs(RRRsR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRPs tDispatcherWithSendTestscBsDeZeZdZdZejede j dZ RS(cCsdS(N((R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRpZscCstjdS(N(RRS(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRq]ss!Threading required for this test.c Csctj}tjtjtj}|jdtj|}t}|||f}tj dt d|}|j zt j dd}t}|jtjtj|jt|ft j d|j||j||jdd} x-|jr+| d kr+tj| d 8} qW|j|j|j|d Wd|jXdS( Nittargettargsg?s$Suppose there isn't a 16-ton weight?g?s iiii(t threadingtEventRRt SOCK_STREAMt settimeoutRt bind_portRtThreadR2tstartR%R&Rt create_sockettconnectRtsendt out_bufferRR;twaitR7R|tjoin( R R(tsocktporttcapRRiR1RuR-((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_send`s2            ( RRRtusepollRpRqRlRmRRt reap_threadsR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRWs   tDispatcherWithSendTests_UsePollcBseZeZRS((RRR R(((s./usr/local/lib/python2.7/test/test_asyncore.pyRst file_wrappersasyncore.file_wrapper requiredtFileWrapperTestcBsPeZdZdZdZdZejee dddZ RS(cCs5d|_ttd}|j|jWdQXdS(NsIt's not dead, it's sleeping!R/(RutfileRR#(R th((s./usr/local/lib/python2.7/test/test_asyncore.pyRps cCsttdS(N(RR(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRqscCstjttj}tj|}tj||j|j||j|j ||j |j dd|j |j dd|j|j t|j ddS(Ni s It's not deadis, it'si(R`topenRtO_RDONLYRRR tassertNotEqualtfdR R7R"R5R4tOSError(R RR/((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_recvs  cCsd}d}tjttjtjB}tj|}tj||j||j ||j|j t tj |j ||dS(Ns Come again?sI want to buy some cheese.(R`RRtO_WRONLYtO_APPENDRRR R#RR7RR5Ru(R td1td2RR/((s./usr/local/lib/python2.7/test/test_asyncore.pyRs    tfile_dispatchers!asyncore.file_dispatcher requiredcstjttj}gdtjffdY}||}tj|tjdddtdd|j dj |j dS( NtFileDispatchercseZfdZRS(csj|jddS(Ni(RQR"(R (R1(s./usr/local/lib/python2.7/test/test_asyncore.pyRs(RRR((R1(s./usr/local/lib/python2.7/test/test_asyncore.pyRsR g{Gz?tuse_polltcountiR( R`RRRRRR tloopR R7RRu(R RRts((R1s./usr/local/lib/python2.7/test/test_asyncore.pyttest_dispatchers  ( RRRpRqRRRlRmRnRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRs    tBaseTestHandlercBsAeZddZdZdZdZdZdZRS(cCs tjj||t|_dS(N(RRrR RRH(R R((s./usr/local/lib/python2.7/test/test_asyncore.pyR scCstddS(Ns'handle_accept not supposed to be called(R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscCstddS(Ns(handle_connect not supposed to be called(R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscCstddS(Ns%handle_expt not supposed to be called(R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscCstddS(Ns&handle_close not supposed to be called(R(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRscCsdS(N((R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRsN( RRtNoneR RRRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRs      t TCPServercBsAeZdZeeddZedZdZdZ RS(sYA server which listens on an address and dispatches the connection to a handler. icCs]tjj||jtjtj|j|j||f|j d||_ dS(Ni( RRrR RRRRtset_reuse_addrtbindRthandler(R RthostR((s./usr/local/lib/python2.7/test/test_asyncore.pyR s   cCs|jjd S(Ni(Rt getsockname(R ((s./usr/local/lib/python2.7/test/test_asyncore.pytaddressscCs0|j}|dk r,|j|dndS(Ni(RRR(R tpair((s./usr/local/lib/python2.7/test/test_asyncore.pyRs  cCsdS(N((R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRs( RRt__doc__RRR tpropertyRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRs  t BaseClientcBseZdZdZRS(cCs4tj||jtjtj|j|dS(N(RR RRRRR(R R((s./usr/local/lib/python2.7/test/test_asyncore.pyR s cCsdS(N((R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRs(RRR R(((s./usr/local/lib/python2.7/test/test_asyncore.pyRs t BaseTestAPIcBseZdZddZdZdZdZdZdZe j e j j dd d Zd Zd Zd ZdZdZe jedejdZRS(cCstjdS(N(RRS(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRqsicCst|d}d}x\tjrt|dkrttjddddd|j|jrZdS|d8}tj|qW|jddS( NidiR g{Gz?RiRs flag not set( tfloatRRRRRRHR%R&R_(R tinstanceR R((s./usr/local/lib/python2.7/test/test_asyncore.pytloop_waiting_for_flags  cCs?dtfdY}t}||j}|j|dS(Nt TestClientcBseZdZRS(cSs t|_dS(N(R RH(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR s(RRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyR s(RRRR(R Rtservertclient((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_handle_connect s cCs?dtfdY}|}t|j}|j|dS(Nt TestListenercBseZdZdZRS(cSs]tj||jtjtj|jtdf|jd|jj d |_ dS(Niii( RR RRRRRRRRR(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR s   cSs t|_dS(N(R RH(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR s(RRR R(((s./usr/local/lib/python2.7/test/test_asyncore.pyRs (RRRR(R RRR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_handle_accepts cCsXdtfdY}dtfdY}t|}||j}|j|dS(NRcBseZdZRS(cSs t|_dS(N(R RH(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR+s(RRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyR*st TestHandlercBseZdZRS(cSs%tj|||jdddS(Ntxi(RR R(R R+((s./usr/local/lib/python2.7/test/test_asyncore.pyR /s(RRR (((s./usr/local/lib/python2.7/test/test_asyncore.pyR.s(RRRRR(R RRRR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_handle_read's  cCs?dtfdY}t}||j}|j|dS(NRcBseZdZRS(cSs t|_dS(N(R RH(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyR;s(RRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyR:s(RRRR(R RRR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_handle_write7s cCsXdtfdY}dtfdY}t|}||j}|j|dS(NRcBseZdZdZRS(cSs|jddS(Ni(R"(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRHscSst|_|jdS(N(R RHR (R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRMs (RRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRFs RcBseZdZRS(cSstj|||jdS(N(RR R (R R+((s./usr/local/lib/python2.7/test/test_asyncore.pyR Rs(RRR (((s./usr/local/lib/python2.7/test/test_asyncore.pyRQs(RRRRR(R RRRR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_handle_closeBs   tsunoss OOB support is broken on SolariscCsXdtfdY}dtfdY}t|}||j}|j|dS(NRcBseZdZRS(cSs t|_dS(N(R RH(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRbs(RRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRasRcBseZdZRS(cSs0tj|||jjtdtjdS(Ni(RR RRtchrtMSG_OOB(R R+((s./usr/local/lib/python2.7/test/test_asyncore.pyR fs(RRR (((s./usr/local/lib/python2.7/test/test_asyncore.pyRes(RRRRR(R RRRR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_handle_exptZs  cCs?dtfdY}t}||j}|j|dS(NRcBseZdZdZRS(cSs dddS(Ng?i((R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRqscSs4t|_yWntk r#n XtddS(Nsexception not raised(R RHtZeroDivisionErrorR(R ((s./usr/local/lib/python2.7/test/test_asyncore.pyRss   (RRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRps (RRRR(R RRR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_handle_errorns cCst}t|j}|j|j|j|j|j|jtjddd|j dd|j|j|j|j|j|j|j|j|j |j|j|j|j|j|j|j|j|j |j|j|j|jdS(NR g{Gz?RRid( RRRt assertFalset connectedRt acceptingRRRR (R RR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_connection_attributess$   cCsXtj}|jtjtj|j|jjtj|j|jjtjdS(N( RRrRRRRR7Rttype(R R((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_create_sockets cCstj}|jtjtj|jtdf|jd|jj d}tj}|jtjtj|j tj |jt|fdS(Niii( RRrRRRRRRRRR4terror(R ts1Rts2((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_binds   cCstj}zy|jtjtjdWn!tjk rOtjdnzXtjtj}|j |jj tjtj|j tj tj |j|j|jj tjtjWd|jXdS(Nis+SO_REUSEADDR not supported on this platform(Rt setsockoptt SOL_SOCKETt SO_REUSEADDRRRltskipRRrRt getsockoptRRRRRR (R RR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_set_reuse_addrs   s!Threading required for this test.cCst}tjdd}|j|j|jxtdD]}tjtjtj }|j d|j tj tj tjdddz/y|j|jWntjk rnXWd|jXqEWdS(NRcSstjddddS(NR g?Ri(RR(((s./usr/local/lib/python2.7/test/test_asyncore.pytsig?tiiii(RRRRt addCleanupRtxrangeRRRRRRt SO_LINGERtstructtpackRRRR (R RRiRR((s./usr/local/lib/python2.7/test/test_asyncore.pyttest_quick_connects   (RRRqRRRRRRRltskipIfR\tplatformt startswithRRRRRRRmRRRR (((s./usr/local/lib/python2.7/test/test_asyncore.pyRs         tTestAPI_UseSelectcBseZeZRS((RRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pyRsR;sselect.poll requiredtTestAPI_UsePollcBseZeZRS((RRR R(((s./usr/local/lib/python2.7/test/test_asyncore.pyRscCs)tttttttg}t|dS(N(R3RoRRRRRR(ttests((s./usr/local/lib/python2.7/test/test_asyncore.pyt test_mains  t__main__(((((-RRlR!R`RR\R%RRR ttestRttest.test_supportRRRRRRt ImportErrorRRRRRR2tTestCaseR3Rotdispatcher_with_sendRRRRmRnRRrRRRRRRRR(((s./usr/local/lib/python2.7/test/test_asyncore.pytsN          "     k2 0