ó ükWc@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/lib/python2.7/test/test_poplib.pyR#s  cCs|jj|ƒdS(N(R tappend(R tdata((s&/usr/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/lib/python2.7/test/test_poplib.pytfound_terminator,s   cCs‚dS(N((R ((s&/usr/lib/python2.7/test/test_poplib.pyt handle_error;scCstjj||dƒdS(Ns (RRR (R R((s&/usr/lib/python2.7/test/test_poplib.pyR >scCs|j|ƒdS(N(R (R R((s&/usr/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/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/lib/python2.7/test/test_poplib.pytcmd_passJs cCs|jdƒdS(Ns +OK 10 100(R (R R((s&/usr/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/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/lib/python2.7/test/test_poplib.pytcmd_retr[scCs|jdƒdS(Ns +OK message marked for deletion.(R (R R((s&/usr/lib/python2.7/test/test_poplib.pytcmd_deleascCs|jdƒdS(Ns+OK done nothing.(R (R R((s&/usr/lib/python2.7/test/test_poplib.pytcmd_noopdscCs|jdƒdS(Ns+OK done nothing.(R (R R((s&/usr/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/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/lib/python2.7/test/test_poplib.pyRos   cCs@|j st‚tjƒ|_tjj|ƒ|jjƒdS(N(R=tAssertionErrorRtEventt_DummyPOP3Server__flagR4tstarttwait(R ((s&/usr/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/lib/python2.7/test/test_poplib.pytruns   cCs&|jst‚t|_|jƒdS(N(R=RER<R(R ((s&/usr/lib/python2.7/test/test_poplib.pytstopˆs cCs2|jƒ\}}|j|ƒ|_|jƒdS(N(tacceptthandlertclose(R R taddr((s&/usr/lib/python2.7/test/test_poplib.pyt handle_acceptscCs|jƒdS(N(RX(R ((s&/usr/lib/python2.7/test/test_poplib.pythandle_connect’scCsdS(Ni((R ((s&/usr/lib/python2.7/test/test_poplib.pytwritable–scCs‚dS(N((R ((s&/usr/lib/python2.7/test/test_poplib.pyR ™s(R/R0RRWR8tAF_INETRRHRTRURZR[t handle_readR\R (((s&/usr/lib/python2.7/test/test_poplib.pyR3ks     t TestPOP3ClasscBs˜eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(cCs|j|jdƒƒdS(Ns+OK(t assertTruet startswith(R tresp((s&/usr/lib/python2.7/test/test_poplib.pytassertOKŸscCsGttdfƒ|_|jjƒtj|jj|jjƒ|_dS(Ni( R3RtserverRHtpoplibtPOP3RARBtclient(R ((s&/usr/lib/python2.7/test/test_poplib.pytsetUp¢s cCs|jjƒ|jjƒdS(N(RgtquitRdRU(R ((s&/usr/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/lib/python2.7/test/test_poplib.pyttest_getwelcome«scCs |jtj|jjdƒdS(Ns echo -err(t assertRaisesRet error_protoRgt _shortcmd(R ((s&/usr/lib/python2.7/test/test_poplib.pyttest_exceptions®scCs9|j|jjdƒƒ|jtj|jjdƒdS(NR"tinvalid(RcRgtuserRnReRo(R ((s&/usr/lib/python2.7/test/test_poplib.pyt test_user±scCs9|j|jjdƒƒ|jtj|jjdƒdS(NR$Rr(RcRgtpass_RnReRoRs(R ((s&/usr/lib/python2.7/test/test_poplib.pyt test_pass_µscCs|j|jjƒdƒdS(Ni id(i id(RkRgtstat(R ((s&/usr/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/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/lib/python2.7/test/test_poplib.pyt test_retrÁs  cCs/|jtj|jjdtjddƒdS(Nsecho +%si ta(RnReRoRgRpt_MAXLINE(R ((s&/usr/lib/python2.7/test/test_poplib.pyttest_too_long_linesÉscCs|j|jjdƒƒdS(NR€(RcRgtdele(R ((s&/usr/lib/python2.7/test/test_poplib.pyt test_deleÍscCs|j|jjƒƒdS(N(RcRgtnoop(R ((s&/usr/lib/python2.7/test/test_poplib.pyt test_noopÐscCs|j|jjdƒƒdS(NR€(RcRgtrpop(R ((s&/usr/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/lib/python2.7/test/test_poplib.pyttest_topÖs    cCs!|jjƒ|jjdƒdS(NR€(Rgtuidl(R ((s&/usr/lib/python2.7/test/test_poplib.pyt test_uidlÞs (R/R0RcRhRjRmRqRtRvRxR|RƒR†RˆRŠRŒRŽR(((s&/usr/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/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/lib/python2.7/test/test_poplib.pyRšøs cCs'|jr|jƒn tj|ƒdS(N(R™RšRR^(R ((s&/usr/lib/python2.7/test/test_poplib.pyR^s  (R/R0RRšR^(((s&/usr/lib/python2.7/test/test_poplib.pyR’ês sSSL not supportedtTestPOP3_SSLClasscBseZd„Zd„ZRS(cCsSttdfƒ|_t|j_|jjƒtj|jj|jj ƒ|_ dS(Ni( R3RRdR’RWRHReR‘RARBRg(R ((s&/usr/lib/python2.7/test/test_poplib.pyRhs  cCs|jdtjƒdS(NR‘(tassertInRet__all__(R ((s&/usr/lib/python2.7/test/test_poplib.pyt test__all__s(R/R0RhR©(((s&/usr/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/lib/python2.7/test/test_poplib.pyRh s* cCs|jjƒ|`dS(N(R°R(R ((s&/usr/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/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/lib/python2.7/test/test_poplib.pyttestTimeoutDefault:s 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/lib/python2.7/test/test_poplib.pyttestTimeoutNoneDs cCsEtjt|jddƒ}|j|jjƒdƒ|jjƒdS(NRJi(ReRfRRBRkR­R¸RX(R R¹((s&/usr/lib/python2.7/test/test_poplib.pyttestTimeoutValueNs(R/R0RhRjRdRºR»R¼(((s&/usr/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/lib/python2.7/test/test_poplib.pyt test_mainTs   t__main__(*t__doc__ReR5RR8tosttimeR£tunittestRRttestRttest.test_supportRt import_moduleRR'R*RRR6R4R3R_R<t SUPPORTS_SSLRR–RMtpathRtdirnamet__file__tcurdirR˜R’t requires_sslR¦RªRÂR/(((s&/usr/lib/python2.7/test/test_poplib.pyts:        J2F *$ 6