ó {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   cCs@|j st‚tjƒ|_tjj|ƒ|jjƒdS(N(R=tAssertionErrorRtEventt_DummyPOP3Server__flagR4tstarttwait(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRHyscCsst|_|jjƒxF|jr^tjr^|jjƒtjddddƒ|jj ƒqWtj dtƒdS(Nttimeoutgš™™™™™¹?tcountit ignore_all( tTrueR=RGtsetR5t socket_mapR?tacquiretlooptreleaset close_all(R ((s,/usr/local/lib/python2.7/test/test_poplib.pytruns   cCs&|jst‚t|_|jƒdS(N(R=RER<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(RX(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/R0RRWR8tAF_INETRRHRTRURZR[t 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( R3RtserverRHtpoplibtPOP3RARBtclient(R ((s,/usr/local/lib/python2.7/test/test_poplib.pytsetUp¢s cCs|jjƒ|jjƒdS(N(RgtquitRdRU(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyttearDown§s cCs|j|jjƒdƒdS(Ns+OK dummy pop3 server ready.(t assertEqualRgt getwelcome(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyttest_getwelcome«scCs |jtj|jjdƒdS(Ns echo -err(t assertRaisesRet error_protoRgt _shortcmd(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyttest_exceptions®scCs9|j|jjdƒƒ|jtj|jjdƒdS(NR"tinvalid(RcRgtuserRnReRo(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_user±scCs9|j|jjdƒƒ|jtj|jjdƒdS(NR$Rr(RcRgtpass_RnReRoRs(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_pass_µscCs|j|jjƒdƒdS(Ni id(i id(RkRgtstat(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(RkRgtlistR`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(RkRgtretr(R texpected((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_retrÁs  cCs|j|jjdƒƒdS(NR€(RcRgtdele(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_deleÉscCs|j|jjƒƒdS(N(RcRgtnoop(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_noopÌscCs|j|jjdƒƒdS(NR€(RcRgtrpop(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~Riqi(RkRgttop(R R‚((s,/usr/local/lib/python2.7/test/test_poplib.pyttest_topÒs    cCs!|jjƒ|jjdƒdS(NR€(Rgtuidl(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test_uidlÚs (R/R0RcRhRjRmRqRtRvRxR|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_socketR8tCERTFILERMR<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( R3RRdRRWRHReRŽRARBRg(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRhs  cCs|jdtjƒdS(NRŽ(tassertInRet__all__(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyt test__all__s(R/R0RhR¦(((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š(RRFtevtR8R]R9tsockt settimeoutRt bind_portRBR4Rdtthreadt setDaemonRMRHRI(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRhs* cCs|jjƒ|`dS(N(R­R(R ((s,/usr/local/lib/python2.7/test/test_poplib.pyRj&s cCsq|jdƒ|jƒzHy-|jƒ\}}|jdƒ|jƒWntjk r]nXWd|jƒXdS(Nis + Hola mundo (R;RNRVtsendRXR8RJ(R R©tservR RY((s,/usr/local/lib/python2.7/test/test_poplib.pyRd*s   cCst|jtjƒƒtjdƒztjt|jƒ}WdtjdƒX|j |j j ƒdƒ|j j ƒdS(Ni( t assertIsNoneR8tgetdefaulttimeouttsetdefaulttimeoutReRfRRBtNoneRkRªt gettimeoutRX(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(NiRJ( R±R8R²R³ReRfRRBR´RªRµRX(R R¶((s,/usr/local/lib/python2.7/test/test_poplib.pyttestTimeoutNone@s cCsEtjt|jddƒ}|j|jjƒdƒ|jjƒdS(NRJi(ReRfRRBRkRªRµRX(R R¶((s,/usr/local/lib/python2.7/test/test_poplib.pyttestTimeoutValueJs(R/R0RhRjRdR·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__ReR5RR8tosttimeR tunittestRRttestRttest.test_supportRt import_moduleRR'R*RRR6R4R3R_R<t SUPPORTS_SSLRR“RMtpathRtdirnamet__file__tcurdirR•Rt requires_sslR£R§R¿R/(((s,/usr/local/lib/python2.7/test/test_poplib.pyts:        J2B *$ 6