ó {G_Tc@sÇdZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl mZe jdƒZdZdZd ejfd „ƒYZd ejejfd „ƒYZd e fd„ƒYZeZeedƒrcddlZeZejjejj e!ƒpAej"dƒZ#defd„ƒYZ$ne edƒZ%e%defd„ƒYƒZ&de fd„ƒYZ'd„Z(e)dkrÃe(ƒndS(sTest script for poplib module.iÿÿÿÿN(tTestCaset skipUnless(t test_support(tHOSTt threadings1 1 2 2 3 3 4 4 5 5 . stFrom: postmaster@python.org Content-Type: text/plain MIME-Version: 1.0 Subject: Dummy line1 line2 line3 . tDummyPOP3HandlercBs’eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z e Z d „Z e Zd „Zd „Zd „ZRS(cCs:tjj||ƒ|jdƒg|_|jdƒdS(Ns s+OK dummy pop3 server ready.(tasynchatt async_chatt__init__tset_terminatort in_buffertpush(tselftconn((s,/usr/local/lib/python2.7/test/test_poplib.pyR#s  cCs|jj|ƒdS(N(R tappend(R tdata((s,/usr/local/lib/python2.7/test/test_poplib.pytcollect_incoming_data)scCs®dj|jƒ}g|_|jdƒdjƒ}|jdƒ}|dkr`||d}nd}t|d|ƒr™t|d|ƒ}||ƒn|jd|ƒdS(Ntt iiÿÿÿÿitcmd_s$-ERR unrecognized POP3 command "%s".(tjoinR tsplittlowertfindthasattrtgetattrR (R tlinetcmdtspacetargtmethod((s,/usr/local/lib/python2.7/test/test_poplib.pytfound_terminator,s   cCs‚dS(N((R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt handle_error;scCstjj||dƒdS(Ns (RRR (R R((s,/usr/local/lib/python2.7/test/test_poplib.pyR >scCs|j|ƒdS(N(R (R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_echoAscCs-|dkr|jdƒn|jdƒdS(Ntguidos-ERR no such users+OK password required(R (R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_userEs cCs-|dkr|jdƒn|jdƒdS(Ntpythons-ERR wrong passwords+OK 10 messages(R (R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_passJs cCs|jdƒdS(Ns +OK 10 100(R (R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_statOscCsD|r |jd||fƒn |jdƒtjj|tƒdS(Ns +OK %s %ss+OK(R RRt LIST_RESP(R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_listRs cCs.|jdttƒƒtjj|tƒdS(Ns +OK %s bytes(R tlent RETR_RESPRR(R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_retr[scCs|jdƒdS(Ns +OK message marked for deletion.(R (R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_deleascCs|jdƒdS(Ns+OK done nothing.(R (R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_noopdscCs|jdƒdS(Ns+OK done nothing.(R (R R((s,/usr/local/lib/python2.7/test/test_poplib.pytcmd_rpopgs(t__name__t __module__RRRR R R!R#R%R&R(tcmd_uidlR+tcmd_topR,R-R.(((s,/usr/local/lib/python2.7/test/test_poplib.pyR!s              tDummyPOP3ServercBsbeZeZejd„Zd„Zd„Zd„Z d„Z d„Z e Z d„Z d„ZRS(cCsˆtjj|ƒtjj|ƒ|j|tjƒ|j|ƒ|j dƒt |_ tj ƒ|_ |jjƒd \|_|_dS(Nii(RtThreadRtasyncoret dispatchert create_sockettsockett SOCK_STREAMtbindtlistentFalsetactivetLockt active_lockt getsocknamethosttport(R taddresstaf((s,/usr/local/lib/python2.7/test/test_poplib.pyRos   cCs0tjƒ|_tjj|ƒ|jjƒdS(N(RtEventt_DummyPOP3Server__flagR4tstarttwait(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRGyscCsst|_|jjƒxF|jr^tjr^|jjƒtjddddƒ|jj ƒqWtj dtƒdS(Nttimeoutgš™™™™™¹?tcountit ignore_all( tTrueR=RFtsetR5t socket_mapR?tacquiretlooptreleaset close_all(R ((s,/usr/local/lib/python2.7/test/test_poplib.pytruns   cCst|_|jƒdS(N(R<R=R(R ((s,/usr/local/lib/python2.7/test/test_poplib.pytstopˆs cCs2|jƒ\}}|j|ƒ|_|jƒdS(N(tacceptthandlertclose(R R taddr((s,/usr/local/lib/python2.7/test/test_poplib.pyt handle_acceptscCs|jƒdS(N(RW(R ((s,/usr/local/lib/python2.7/test/test_poplib.pythandle_connect’scCsdS(Ni((R ((s,/usr/local/lib/python2.7/test/test_poplib.pytwritable–scCs‚dS(N((R ((s,/usr/local/lib/python2.7/test/test_poplib.pyR ™s(R/R0RRVR8tAF_INETRRGRSRTRYRZt handle_readR[R (((s,/usr/local/lib/python2.7/test/test_poplib.pyR3ks     t TestPOP3ClasscBseZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„ZRS(cCs|j|jdƒƒdS(Ns+OK(t assertTruet startswith(R tresp((s,/usr/local/lib/python2.7/test/test_poplib.pytassertOKŸscCsGttdfƒ|_|jjƒtj|jj|jjƒ|_dS(Ni( R3RtserverRGtpoplibtPOP3RARBtclient(R ((s,/usr/local/lib/python2.7/test/test_poplib.pytsetUp¢s cCs|jjƒ|jjƒdS(N(RftquitRcRT(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyttearDown§s cCs|j|jjƒdƒdS(Ns+OK dummy pop3 server ready.(t assertEqualRft getwelcome(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyttest_getwelcome«scCs |jtj|jjdƒdS(Ns echo -err(t assertRaisesRdt error_protoRft _shortcmd(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyttest_exceptions®scCs9|j|jjdƒƒ|jtj|jjdƒdS(NR"tinvalid(RbRftuserRmRdRn(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_user±scCs9|j|jjdƒƒ|jtj|jjdƒdS(NR$Rq(RbRftpass_RmRdRnRr(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_pass_µscCs|j|jjƒdƒdS(Ni id(i id(RjRftstat(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_stat¹scCsX|j|jjƒddddddgdfƒ|j|jjdƒjd ƒƒdS( Nis1 1s2 2s3 3s4 4s5 5it1sOK 1 1(RjRftlistR_tendswith(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_list¼sc CsGddddddddd gd f}|j|jjd ƒ|ƒdS( Ns +OK 116 bytessFrom: postmaster@python.orgsContent-Type: text/plainsMIME-Version: 1.0sSubject: DummyRtline1tline2tline3iqtfoo(RjRftretr(R texpected((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_retrÁs  cCs|j|jjdƒƒdS(NR(RbRftdele(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_deleÉscCs|j|jjƒƒdS(N(RbRftnoop(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_noopÌscCs|j|jjdƒƒdS(NR(RbRftrpop(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_rpopÏsc CsJddddddddd gd f}|j|jjd d ƒ|ƒdS( Ns +OK 116 bytessFrom: postmaster@python.orgsContent-Type: text/plainsMIME-Version: 1.0sSubject: DummyRR|R}R~iqi(RjRfttop(R R((s,/usr/local/lib/python2.7/test/test_poplib.pyttest_topÒs    cCs!|jjƒ|jjdƒdS(NR(Rftuidl(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_uidlÚs (R/R0RbRgRiRlRpRsRuRwR{R‚R„R†RˆRŠRŒ(((s,/usr/local/lib/python2.7/test/test_poplib.pyR^s              tPOP3_SSLs keycert.pemtDummyPOP3_SSLHandlercBs#eZd„Zd„Zd„ZRS(cCsttjj||ƒtj|jdtdtdtƒ|_t|_ |j ƒ|j dƒg|_ |j dƒdS(Ntcertfilet server_sidetdo_handshake_on_connects s+OK dummy pop3 server ready.(RRRtsslt wrap_socketR8tCERTFILERLR<t_ssl_acceptingt_do_ssl_handshakeR R R (R R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRès     cCs²y|jjƒWn‘tjk ro}|jdtjtjfkrIdS|jdtjkri|jƒS‚n?tj k r¤}|jdt j kr®|jƒSn Xt |_ dS(Ni(R8t do_handshakeR’tSSLErrortargstSSL_ERROR_WANT_READtSSL_ERROR_WANT_WRITEt SSL_ERROR_EOFt handle_closeterrorterrnot ECONNABORTEDR<R•(R terr((s,/usr/local/lib/python2.7/test/test_poplib.pyR–ôs cCs'|jr|jƒn tj|ƒdS(N(R•R–RR](R ((s,/usr/local/lib/python2.7/test/test_poplib.pyR]s  (R/R0RR–R](((s,/usr/local/lib/python2.7/test/test_poplib.pyRŽæs sSSL not supportedtTestPOP3_SSLClasscBseZd„Zd„ZRS(cCsSttdfƒ|_t|j_|jjƒtj|jj|jj ƒ|_ dS(Ni( R3RRcRŽRVRGRdRRARBRf(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRgs  cCs|jdtjƒdS(NR(tassertInRdt__all__(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test__all__s(R/R0RgR¥(((s,/usr/local/lib/python2.7/test/test_poplib.pyR¢ s t TestTimeoutscBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs§tjƒ|_tjtjtjƒ|_|jjdƒtj |jƒ|_ tj d|j d|j|jfƒ|_ |j jtƒ|j jƒ|jjƒdS(Ni<ttargetR™(RREtevtR8R\R9tsockt settimeoutRt bind_portRBR4Rctthreadt setDaemonRLRGRH(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRgs* cCs|jjƒ|`dS(N(R¬R(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRi&s cCsq|jdƒ|jƒzHy-|jƒ\}}|jdƒ|jƒWntjk r]nXWd|jƒXdS(Nis + Hola mundo (R;RMRUtsendRWR8RI(R R¨tservR RX((s,/usr/local/lib/python2.7/test/test_poplib.pyRc*s   cCst|jtjƒƒtjdƒztjt|jƒ}WdtjdƒX|j |j j ƒdƒ|j j ƒdS(Ni( t assertIsNoneR8tgetdefaulttimeouttsetdefaulttimeoutRdReRRBtNoneRjR©t gettimeoutRW(R tpop((s,/usr/local/lib/python2.7/test/test_poplib.pyttestTimeoutDefault6s cCsw|jtjƒƒtjdƒztjt|jddƒ}WdtjdƒX|j|j j ƒƒ|j j ƒdS(NiRI( R°R8R±R²RdReRRBR³R©R´RW(R Rµ((s,/usr/local/lib/python2.7/test/test_poplib.pyttestTimeoutNone@s cCsEtjt|jddƒ}|j|jjƒdƒ|jjƒdS(NRIi(RdReRRBRjR©R´RW(R Rµ((s,/usr/local/lib/python2.7/test/test_poplib.pyttestTimeoutValueJs(R/R0RgRiRcR¶R·R¸(((s,/usr/local/lib/python2.7/test/test_poplib.pyR¦s   cCsAtttg}tjƒ}ztj|ŒWdtj|ŒXdS(N(R^R¦R¢Rtthreading_setupt run_unittesttthreading_cleanup(ttestst thread_info((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_mainPs   t__main__(*t__doc__RdR5RR8tosttimeRŸtunittestRRttestRttest.test_supportRt import_moduleRR'R*RRR6R4R3R^R<t SUPPORTS_SSLRR’RLtpathRtdirnamet__file__tcurdirR”RŽt requires_sslR¢R¦R¾R/(((s,/usr/local/lib/python2.7/test/test_poplib.pyts:        J2B *$ 6