Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyc


#NvNc@s`dZddlZddlZddlmZddlZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZdd	lmZdd
lmZmZmZmZmZddlmZddlmZdd
lmZmZmZddl m!Z!m"Z"m#Z#ddl$m%Z%ddlm&Z&m'Z'ej(de)ddZ*e#j+j,rvdZ-ne.Z-dej/fdYZ0dej1fdYZ2de
j3fdYZ4de4fdYZ5de4fdYZ6de4fd YZ7d!e4fd"YZ8d#e8fd$YZ9d%e
j3fd&YZ:d'ej1fd(YZ;d)e&j<fd*YZ=d+e
j3fd,YZ>d-e
j3fd.YZ?d/e
j3fd0YZ@d1e
j3fd2YZAd3e
j3fd4YZBd5e
j3fd6YZCd7e
j3fd8YZDd9e
j3fd:YZEd;e
j3fd<YZFd=e
j3fd>YZGd?fd@YZHdAe
j3eHfdBYZIdCeJfdDYZKdEeJfdFYZLdGfdHYZMdIe
j3eMfdJYZNdKfdLYZOdMfdNYZPdOe
j3fdPYZQdQe
j3fdRYZRdS(Ss
FTP tests.
iN(tStringIO(t
implements(tverifyClass(tunittesttutil(tinsecureRandom(tIRealm(tbasic(treactorttasktprotocoltdeferterror(t	IConsumer(tUnauthorizedLogin(tportaltcheckerstcredentials(tfailuretfilepathtruntime(t
proto_helpers(tftptloopbacktcategorytmessagesbFTPClient\.changeDirectory is deprecated in Twisted 8\.2 and newer\.  Use FTPClient\.cwd instead\.sCannot run on WindowstDummycBs;eZdZdZdZdZdZdZRS(cCsg|_g|_dS(N(tlinestrawData(tself((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt__init__,s	cCs|j|_dS(N(tfactorytf(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytconnectionMade/scCs|jj|dS(N(Rtappend(Rtline((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytlineReceived1scCs|jj|dS(N(RR"(Rtdata((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytrawDataReceived3scCsdS(N((RR#((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytlineLengthExceeded5sN(	t__name__t
__module__tNonetlognameRR!R$R&R'(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR*s				t_BufferingProtocolcBs#eZdZdZdZRS(cCsd|_tj|_dS(Nt(tbufferRtDeferredtd(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR!:s	cCs|j|7_dS(N(R.(RR%((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytdataReceived=scCs|jj|dS(N(R0tcallback(Rtreason((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytconnectionLost?s(R(R)R!R1R4(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR,9s		tFTPServerTestCasecBsJeZdZejZdZdZddZ	dddZ
dZRS(sw
    Simple tests for an FTP server with the default settings.

    @ivar clientFactory: class used as ftp client.
    t	anonymouscsOj_tjjtjj_tjt	j
j}|jtj
tjt	jd|dj_tjdjdd}j|jjjtjfd}|j_|jj}tjtj}|jd|}fd}|j |tj!|gS(NRt
userAnonymousit	interfaces	127.0.0.1csNj`|}|j_fd}j|jd|S(Ncs)jjdk	r%jjjndS(N(tserverProtocolt	transportR*tloseConnection((R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
cleanupServerfs(Rt
buildProtocoltwrappedProtocolR9t
addCleanupR2R*(taddrR
R<(RR=td1(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt_rememberProtocolInstance`s	

cs#|_jjjjdS(N(tclientR?R:R;(RC(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	gotClientrs	("tmktempt	directorytostmkdirRtFilePathtdirPathRtPortalRtFTPRealmtregisterCheckerRtAllowAnonymousAccessRt
IAnonymoust
FTPFactoryR7RRt	listenTCPR?t
stopListeningR=RR/tgetHosttportR
t
ClientCreatort
clientFactoryt
connectTCPtaddCallbackt
gatherResults(RtpRTRBtportNumt
clientCreatortd2RD((RR=RAs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytsetUpMs(

cs@|dkrtjd}nfd}|j|S(sAsserts that a sending an FTP command receives the expected
        response.

        Returns a Deferred.  Optionally accepts a deferred to chain its actions
        to.
        cs1jj}fd}|j|S(Ncsj|dS(N(tassertEqual(t
responseLines(RtexpectedResponseLines(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytgotResponses(RCtqueueStringCommandRX(tignoredR0Rb(RRatcommand(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytqueueCommandsN(R*RtsucceedRX(RReRat
chainDeferredRf((RRaRes9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytassertCommandResponsexscso|dkrtjd}nfd}|j|j|tjfd}|j|S(NcsjjS(N(RCRc(Rd(RRe(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRfscs*dk	r&j|jdndS(Ni(R*R_targs(t	exception(texpectedResponseR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytfaileds(R*RRgRXt
assertFailureRt
CommandFailed(RReRlRhRfRm((RReRls9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytassertCommandFaileds
cCs.|jddg}|jddgd|S(NsUSER anonymouss8331 Guest login ok, type your email address as password.sPASS test@twistedmatrix.coms2230 Anonymous login ok, access restrictions apply.Rh(Ri(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt_anonymousLogins	N(R(R)t__doc__RtFTPClientBasicRVR7R^R*RiRpRq(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR5Ds		,tFTPAnonymousTestCasecBseZdZdZdZRS(s
    Simple tests for an FTP server with different anonymous username.
    The new anonymous username used in this test case is "guest"
    tguestcCs.|jddg}|jddgd|S(s
        Tests whether the changing of the anonymous username is working or not.
        The FTP server should not comply about the need of password for the
        username 'guest', letting it login as anonymous asking just an email
        address as password.
        s
USER guests8331 Guest login ok, type your email address as password.sPASS test@twistedmatrix.coms2230 Anonymous login ok, access restrictions apply.Rh(Ri(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_anonymousLogins	(R(R)RrR7Rv(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRtstBasicFTPServerTestCasecBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZejeZdZdZdZdZRS(c
sddddddddd	d
g
}fd}g}xM|D]E}jj|}j|tj|j||j|q@Wtj|dt	S(
skWhen not logged in, all commands other than USER and PASS should
        get NOT_LOGGED_IN errors.
        tCDUPtCWDtLISTtMODEtPASVtPWDtRETRtSTRUtSYSTtTYPEcs9|jd}j|djdd|dfdS(Niit530s"Response didn't start with 530: %r(Rjt
failUnlesst
startswith(RktfailureResponseLines(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
checkResponses
tfireOnOneErrback(
RCRcRnRRoRXR"RtDeferredListtTrue(RtcommandListRt	deferredsRetdeferred((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestNotLoggedInReplys

cCs|jddgS(s.Issuing PASS before USER should give an error.sPASS foos=503 Incorrect sequence of commands: USER required before PASS(Rp(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestPASSBeforeUSERscCs|jddgS(s2Issuing USER without a username is a syntax error.tUSERs,500 Syntax error: USER requires an argument.(Rp(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestNoParamsForUSERscCs+|jjd}|jddgd|S(s2Issuing PASS without a password is a syntax error.sUSER footPASSs,500 Syntax error: PASS requires an argument.Rh(RCRcRp(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestNoParamsForPASSs
	cCs
|jS(N(Rq(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestAnonymousLoginscCs%|j}|jddgd|S(s)Issuing QUIT should return a 221 message.tQUITs221 Goodbye.Rh(RqRi(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestQuits
	cCst|j_tj}|jjj|tj|j	ddg}|j
ddgd|}|j
ddgd|}|S(NsUSER anonymouss$331 Password required for anonymous.sPASS test@twistedmatrix.coms!530 Sorry, Authentication failed.RhR}s$530 Please login with USER and PASS.(tFalseRtallowAnonymousRt'InMemoryUsernamePasswordDatabaseDontUseRRMRtIUsernamePasswordRiRp(RtdenyAlwaysCheckerR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestAnonymousLoginDenieds 
				cCs%|j}|jddgd|S(s
        When an anonymous user attempts to edit the server-side filesystem, they
        will receive a 550 error with a descriptive message.
        s
MKD newdirs:550 Anonymous users are forbidden to change the filesystemRh(RqRp(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_anonymousWriteDenied
s
	cCs%|j}|jddgd|S(Nt	GIBBERISHs'502 Command 'GIBBERISH' not implementedRh(RqRp(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestUnknownCommands
	cCs%|j}|jddgd|S(NsRETR foosE503 Incorrect sequence of commands: PORT or PASV required before RETRRh(RqRp(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestRETRBeforePORT s
	cCs%|j}|jddgd|S(NsSTOR foosE503 Incorrect sequence of commands: PORT or PASV required before STORRh(RqRp(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestSTORBeforePORT(s
	cCsB|j}|jddgd||jddgd||S(NsMODE zs&504 Not implemented for parameter 'z'.RhsSTRU Is&504 Not implemented for parameter 'I'.(RqRp(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestBadCommandArgs0s		cCs|jtjddtd}xXtdD]J}t|}d||<djtt|}|jt	tj|q2WdS(Ns25,234,129,22,100,23s
25.234.129.22idiit,(s
25.234.129.22id(
R_RtdecodeHostPorttrangetlisttjointmaptstrtassertRaisest
ValueError(RtnumstitbadValuets((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestDecodeHostPort<s
ccstj|j}|V|jtj|jjd}|V|j}tj|dd\}}|j||j	j
jj|j	j
jdS(NR|ii(RtwaitForDeferredRqt	getResultRCRcRRR_R9tdtpPortRSRTR:R;(RtwfdtpasvCmdR`thostRT((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestPASVFs
cCs)|j}|jddgd||S(NRs215 UNIX Type: L8Rh(RqRi(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestSYSTYscCs8d}||j_|jt|jjtjdS(s
        Exceptions other than L{error.CannotListenError} which are raised by
        C{listenFactory} should be raised to the caller of L{FTP.getDTPPort}.
        cSs
tdS(N(tRuntimeError(t
portNumberR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
listenFactoryesN(R9RRRt
getDTPPortR
tFactory(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_portRangeForwardError`s	cCsd}||j_|jjtj}|j|dtdd|j_|jjtj}|j|dtdd|j_|jt	j
|jjtjdS(s3
        L{FTP.passivePortRange} should determine the ports which
        L{FTP.getDTPPort} attempts to bind. If no port from that iterator can
        be bound, L{error.CannotListenError} should be raised, otherwise the
        first successful result from L{FTP.listenFactory} should be returned.
        cSs(|dkr$tjd|dn|S(NiViViVt	localhostR(iViViV(RtCannotListenError(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRtsiiViiVN(R9RRR
RR_txrangetpassivePortRangeRRR(RRRT((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_portRangems		cCsGtdd}||j_|jjd}|j||jjdS(s
        The L{FTP} instances created by L{ftp.FTPFactory.buildProtocol} have
        their C{passivePortRange} attribute set to the same object the
        factory's C{passivePortRange} attribute is set to.
        iiN(RRRR=R*R_R>(Rt	portRangeR
((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt"test_portRangeInheritedFromFactorys(R(R)RRRRRRRRRRRRRRRtdeferredGeneratorRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRws&													
			
	tFTPServerTestCaseAdvancedClientcBs)eZdZejZdZdZRS(s:
    Test FTP server with the L{ftp.FTPClient} class.
    csGfd}jjd\}}|j|tj||gS(sl
        Try to make an STOR as anonymous, and check that we got a permission
        denied error.
        cs2|jtjj|jjddddS(Nis550 foo: Permission denied.(ttrapRRoR_tvalueRj(tres(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytebstfoo(RCt	storeFilet
addErrbackRRY(RRRAR]((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_anonymousSTORs
csdtjfdYfd}jtjd|fd}jjd\}}|j|tj||gS(sj
        Any errors during writing a file inside a STOR should be returned to
        the client.
        tFailingFileWritercBseZdZRS(cSstjtjdS(Ntblah(RtfailRtIsNotADirectoryError(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytreceives(R(R)R(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRscstjdS(N(RRgR*(tatb(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytfailingSTORstopenForWritingcs<j|jtjj|jjddddS(Nis'550 Cannot rmd, blah is not a directory(tflushLoggedErrorsRRRoR_RRj(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs

tfailing_file(	Rt_FileWritertpatchtFTPAnonymousShellRCRRRRY(RRRRAR]((RRs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_STORwriteErrors
(R(R)RrRt	FTPClientRVRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs		t#FTPServerPasvDataConnectionTestCasecBsVeZddZddZdZdZdZdZdZ	dZ
RS(	cCs(|jjd}d}|j|S(NR|cSs?tj|dd\}}tjtt}|jd|S(Niis	127.0.0.1(RRR
RURR,RW(R`RRTtcc((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytgotPASVs(RCRcRX(RRdR0R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt_makeDataConnections	csc|dkrtjd}n|jjfd}|j|d}|j|S(Ncs.jj}|j}tj||gS(N(RCRcR0RRY(t
downloaderRAR](RRe(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRfs	cSs|\}}|jS(N(R.(t.0RdR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytdownloadDones	(R*RRgRXR(RReRhRfR((RRes9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	_downloads
	cs;j}jdd|fd}|j|S(NRzRhcsjd|dS(NR-(R_(tresult(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
checkEmptys(RqRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
testEmptyLISTscs"tjtjjjdtjtjjjdj}jdd|fd}|j|jdd|fd}|j|jdd|fd	}|j|fd
}|j|jdd|fd}|j|S(NRtbarRzRhcs'jdt|d jddS(Niis
(R_tlentsplit(tdownload(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
checkDownloadssNLST cs7|d jd}|jjddg|dS(Nis
RR(RtsortR_(Rt	filenames(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs
sLIST foocsjd|dS(NR-(R_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRscsjjdS(NsCWD foo(RCRc(Rd(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytchdir	scsjd|dS(NR-(R_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs(RGRHtpathRRFRqRRX(RR0RR((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestTwoDirLISTs"



csj}xtdddD]}ttjjjd|fd}|jd||jj	d|fd||fd	}|j
|qW|S(
Niiis%d.txttwbtxsRETR %d.txtRhcsj|t|dS(N(R_R(Rtsize(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs(RqRtfileRGRRRFtwritetcloseRRX(RR0RtfObjR((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestManyLargeDownloadss(
csgj}jjdjjjdjjdd|fd}|j|S(sp
        NLST with no argument returns the directory listing for the current
        working directory.
        stest.txtRsNLST Rhcs7|d jd}|jjddg|dS(Nis
Rstest.txt(RRR_(RR(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR3s
(RqRJtchildttouchtcreateDirectoryRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_NLSTEmpty%scs;j}jdd|fd}|j|S(sH
        NLST on a non-existent file/directory returns nothing.
        sNLST nonexistent.txtRhcsjd|dS(NR-(R_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRBs(RqRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_NLSTNonexistent:scsQj}jjdjjdd|fd}|j|S(sN
        NLST on an existent file returns only the path to that file.
        stest.txts
NLST test.txtRhcs*|d jd}jdg|dS(Nis
stest.txt(RR_(RR(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRRs(RqRJRRRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_NLSTOnPathToFileGs
N(R(R)R*RRRRRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs
	
	)			
t#FTPServerPortDataConnectionTestCasecBs/eZdZddZdZdZRS(cCsg|_tj|S(N(t	dataPortsRR^(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^Zs	cstjdtjffdY}tjd|dd}|jj|dtj	d|j
j}|jj
|S(NtDataFactorycseZeZfdZRS(cs/tjj||}tjdj||S(Ni(R
t
ServerFactoryR=Rt	callLaterR2(RR@RZ(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR=ds(R(R)R,R
R=((R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRbsiR8s	127.0.0.1sPORT (RR/R
RRRQRR"RtencodeHostPortRSRTRCRc(RRdRtdataPorttcmd((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^scCs]g|jD]}tj|j^q
}tjtj|}|j|tj|dtS(NR(	RRt
maybeDeferredRRRttearDownR"RR(RRTtlR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRns
(
cs>j}d}|j|fd}|j|S(NcsStjdtjdd}|jj|j}|jfd|S(NiR8s	127.0.0.1csS(N((t_(R[(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt<lambda>s(RRQR
RRSRTRRRX(RdRTR0((R[s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytloggedIn{s	cs#jdtjd|dgS(NsPORT s	127.0.0.1s425 Can't open data connection.(RpRR(R[(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
gotPortNums(RqRX(RR0RR((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestPORTCannotConnectus
	
N(R(R)R^R*RRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRYs		tDTPFactoryTestscBsMeZdZdZdZdZdZdZdZdZ	RS(s&
    Tests for L{ftp.DTPFactory}.
    cCsStj|_dtfdY}||_tj|jd|j|_dS(sf
        Create a fake protocol interpreter and a L{ftp.DTPFactory} instance to
        test.
        tProtocolInterpretercBseZdZRS(N(R(R)R*tdtpInstance(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRsN(	R	tClockRtobjecttprotocolInterpreterRt
DTPFactoryR*R(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^s
cCsg}|j|jjtj}|j|j|jjd|jj	d|j
||jj	d|j||j
|jjdS(s
        L{ftp.DTPFactory.setTimeout} uses the reactor passed to its initializer
        to set up a timed event to time out the DTP setup after the specified
        number of seconds.
        iiiN(
RnRRRtPortConnectionErrorRXR"t
setTimeoutRtadvancetassertFalset
assertTruetcalls(RtfinishedR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_setTimeouts

cCsE|jjd}|j|tj|j|jjdddS(s
        A L{ftp.DTPFactory} instance's C{buildProtocol} method can be used once
        to create a L{ftp.DTP} instance.
        N(RR=R*tassertIsInstanceRtDTPtassertIdentical(RR
((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_buildProtocolOncescCs9|jjd|jjd}|j|jjdS(s
        If a timeout has been set up using L{ftp.DTPFactory.setTimeout}, it is
        cancelled by L{ftp.DTPFactory.buildProtocol}.
        i
N(RRR=R*RRR(RR
((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_timeoutAfterConnectionscCs[|j|jjtj}|jjd|jjd|j|jj	dd|S(s
        If L{ftp.DTPFactory.buildProtocol} is called after the timeout
        specified by L{ftp.DTPFactory.setTimeout} has elapsed, C{None} is
        returned.
        i
N(RnRRRRRRRR#R=R*(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_connectionAfterTimeouts
cCsg}|j|jjtj}|j|j|jjd|j||jj	dd|j||jj
d|S(s
        L{ftp.DTPFactory.deferred} fails with L{PortConnectionError} when
        L{ftp.DTPFactory.clientConnectionFailed} is called.  If the timeout
        specified with L{ftp.DTPFactory.setTimeout} expires after that, nothing
        additional happens.
        i
N(RnRRRRRXR"RRtclientConnectionFailedR*RRR(RRR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!test_timeoutAfterConnectionFaileds

cCs[|j|jjtj}|jjd|jjd|jjdt
jd|S(s
        If L{ftp.DTPFactory.clientConnectionFailed} is called after the timeout
        specified by L{ftp.DTPFactory.setTimeout} has elapsed, nothing beyond
        the normal timeout before happens.
        i
RN(RnRRRRRRRR'R*RtTimeoutError(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!test_connectionFailedAfterTimeouts
(
R(R)RrR^R R$R%R&R(R*(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs						t
PrintLinescBs eZdZdZdZRS(s)Helper class used by FTPFileListingTests.cCs
||_dS(N(t_lines(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRscCs9x%|jD]}|jj|dq
W|jjdS(Ns
(R,R:RR;(RR#((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR!s(R(R)RrRR!(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR+s	tMyFTPFileListProtocolcBseZdZdZRS(cCsg|_tjj|dS(N(totherRtFTPFileListProtocolR(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR%s	cCs|jj|dS(N(R.R"(RR#((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytunknownLine)s(R(R)RR0(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR-$s	tFTPFileListingTestscBs5eZdZdZdZdZdZRS(cs;ttjt|}|jfd|S(NcsjjfS(N(tfilesR.(R
(tfileList(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR1s(R-Rt
loopbackAsyncR+RX(RRR0((R3s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytgetFilesForLines.s	cs.d}fd}j|gj|S(Ns<-rw-r--r--   1 root     other        531 Jan 29 03:26 READMEcs|\\}}j|dt|j|ddkdj|ddkdj|dd	kdj|d
dkdj|dd
kdj|ddkdj|ddkdj|ddkdj|dddS(Nsunexpect unparsable lines: %stfiletypet-smisparsed fileitemtpermss	rw-r--r--smisparsed permstownertroottgroupR.RitdatesJan 29 03:26tfilenametREADMEtnlinksismisparsed nlinkst
linktargetsmisparsed linktarget(tfailIftreprR(RR.R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcheck7s(R5RX(RR#RC((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestOneLine4scs@d}d}d}fd}j|||gj|S(Ns7drw-r--r--   2 root     other        531 Jan  9  2003 As<lrw-r--r--   1 root     other          1 Jan 29 03:26 B -> Aswoohoo! cs|\\}}\}j|dkdj|ddkdj|ddkdj|d	d
kdj|dd
kdj|ddkdj|ddkdj|ddkdj|ddkdj|ddj|ddkdj|ddkdj|d	d
kdj|dd
kdj|ddkdj|ddkdj|dd kdj|ddkdj|ddkddS(!Ns	woohoo! 
sincorrect other lineR6R0smisparsed fileitemR8s	rw-r--r--smisparsed permsR9R:smisparsed ownerR;R.smisparsed groupRismisparsed sizeR<sJan  9  2003smisparsed dateR=tAsmisparsed filenameR?ismisparsed nlinksR@smisparsed linktargetRisJan 29 03:26tB(RRA(Rtfile1tfile2R.(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRCHs((R5RX(Rtline1tline2tline3RC((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestVariantLinesDs
cs+fd}jddgj|S(NcsF|\}}j|dj|ddgkdt|dS(Nsunexpected file entriessABC
snot a file
sincorrect unparsable lines: %s(RARRB(RR2tothers(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRCas	tABCs
not a file(R5RX(RRC((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestUnknownLine`scsetjddtjffdY}fd}tj|}|j|S(Ns<-rw-r--r--   1 root     other        531 Jan 29 2003 README
t	PrintLinecseZfdZRS(cs!|jj|jjdS(N(R:RR;(R(texampleLine(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR!ms(R(R)R!((RQ(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRPlscs_jd}j|ddkdj|ddkdj|ddkddS(	NiRismisparsed fileitemR<sJan 29 2003R=R>(R2R(RdR(RR3(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRCqs
(RR/R
tProtocolRR4RX(RRPRCR0((RQRR3s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestYeargs(R(R)R5RDRLRORS(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR1-s
				tFTPClientTestscBseZdZdZRS(cstj}d|_tjd|dd}|j|j|jj}ddddd|d	?|d
@fdgfd|_	t
jd
d}tjtt
jd
d}|j
d|}d}|j||j|t
jS(NiR8s	127.0.0.1s1220 ready, dude (vsFTPd 1.0.0: beat me, break me)s 331 Please specify the password.s230 Login successful. Have fun.s200 Binary it is, then.s+227 Entering Passive Mode (127,0,0,1,%d,%d)iis550 Failed to open file.cs
tS(N(R+(R@(t	responses(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRstpassiveicSstj}|jd|S(Ns/file/that/doesnt/exist(R
RRtretrieveFile(RCRZ((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRDs(R
RtnoisyRRQR?RRRSRTR=RRRURWRXRnRo(RR RTR[RCRR0RD((RUs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestFailedRETR}s&			
cstj}tj}|j|||_|jdt}gfd}|j|ddl	m
}|jtj
||j|S(sl
        Test the ftp command errbacks when a connection lost happens during
        the operation.
        s	some pathcsj|dS(N(R"R*(R(tm(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt_ebs
i(tCONNECTION_LOST(RRRt StringTransportWithDisconnectiontmakeConnectionR
RRRttwisted.internet.mainR\R4RtFailureR(Rt	ftpClientttrR0R[R\((RZs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_errbacksUponDisconnects
	
(R(R)RYRc(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRT{s	tFTPClientTestCasecBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZege_dZege_dZege_dZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+Z/d,Z0RS(-s,
    Test advanced FTP client commands.
    cCsDtj|_tj|_|jj|j|j|j_dS(sG
        Create a FTP client and connect it to fake transport.
        N(RRRCRR]R:R^R
(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^scCs|jjtjdS(s
        Deliver disconnection notification to the client so that it can
        perform any cleanup which may be required.
        N(RCR4RtConnectionLost(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRscCs|j|jjd|jjd|j|jjd|jj|jjd|j|jjd|jj|jjddS(s&
        Test the login part.
        R-s8331 Guest login ok, type your email address as password.sUSER anonymous
s2230 Anonymous login ok, access restrictions apply.sTYPE I
s200 Type set to I.N(R_R:RRCR$tclear(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
_testLogins	
	
cskfd}jjjj|}jjjdjjjjd|S(s
        Test the CDUP command.

        L{ftp.FTPClient.cdup} should return a Deferred which fires with a
        sequence of one element which is the string the server sent
        indicating that the command was executed successfully.

        (XXX - This is a bad API)
        csj|dddS(Nis&250 Requested File Action Completed OK(R_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbCdupssCDUP
s&250 Requested File Action Completed OK(	RgRCtcdupRXR_R:RRfR$(RRhR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	test_CDUPs


cCsf|j|jj}|j|tj|j|jjd|jj	|jj
d|S(s
        Test L{ftp.FTPClient.cdup}'s handling of a failed CDUP command.

        When the CDUP command fails, the returned Deferred should errback
        with L{ftp.CommandFailed}.
        sCDUP
s!550 ..: No such file or directory(RgRCRiRnRRoR_R:RRfR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedCDUPs

cs^fd}jjjj|}jjjdjjd|S(s
        Test the PWD command.

        L{ftp.FTPClient.pwd} should return a Deferred which fires with a
        sequence of one element which is a string representing the current
        working directory on the server.

        (XXX - This is a bad API)
        cs!jtj|dddS(Nis/bar/baz(R_RtparsePWDResponse(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbPwdssPWD
s257 "/bar/baz"(RgRCtpwdRXR_R:RR$(RRmR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_PWDs

cCsY|j|jj}|j|tj|j|jjd|jj	d|S(s
        Test a failure in PWD command.

        When the PWD command fails, the returned Deferred should errback
        with L{ftp.CommandFailed}.
        sPWD
s'550 /bar/baz: No such file or directory(
RgRCRnRnRRoR_R:RR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedPWDs
csafd}jjjdj|}jjjdjjd|S(s
        Test the CWD command.

        L{ftp.FTPClient.cwd} should return a Deferred which fires with a
        sequence of one element which is the string the server sent
        indicating that the command was executed successfully.

        (XXX - This is a bad API)
        csj|dddS(Nis&250 Requested File Action Completed OK(R_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbCwd)ssbar/foos
CWD bar/foo
s&250 Requested File Action Completed OK(RgRCtcwdRXR_R:RR$(RRqR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_CWDs

cCs\|j|jjd}|j|tj|j|jjd|jj	d|S(s
        Test a failure in CWD command.

        When the PWD command fails, the returned Deferred should errback
        with L{ftp.CommandFailed}.
        sbar/foos
CWD bar/foo
s&550 bar/foo: No such file or directory(
RgRCRrRnRRoR_R:RR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedCWD3s
csfd}fd}|j_jt}jjd|}|j||jjjdjj	jj
dtjddfjjjdjj	jj
d	|S(
sN
        Test the RETR command in passive mode: get a file and verify its
        content.

        L{ftp.FTPClient.retrieveFile} should return a Deferred which fires
        with the protocol instance passed to it after the download has
        completed.

        (XXX - This API should be based on producers and consumers)
        csj|jdddS(NRi(R_R.(Rtproto(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbRetrMscsj|dj|d|j||f}|jtjjjd|jdd|jt	j
tjddS(Ns	127.0.0.1i90s4150 File status okay; about to open data connection.RiR-(
R_R=R^RtStringTransportRCR$R1R4RR`RtConnectionDone(RRTRRu(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	cbConnectPs	tspamsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sRETR spam
s226 Transfer Complete.(
RCtconnectFactoryRgR,RWRXR_R:RRfR$RR(RRvRyRuR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_passiveRETRBs

	

cstj_d}fd}|j_jt}jjd|}|j||jj	j
dtjddfj	j
jjdjj	j
dj	j
jjd	|S(
s
        Test the RETR command in non-passive mode.

        Like L{test_passiveRETR} but in the configuration where the server
        establishes the data connection to the client, rather than the other
        way around.
        cSsldtjddf|_|jjtj|jjdd|jjt	j
tjddS(NsPORT %ss	127.0.0.1i&RiR-(
RRttextR
R^RRwR1R4RR`RRx(tportCmd((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytgeneratePortss
	csj|jdddS(NRi(R_R.(RRu(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRvzsRzs	PORT %s
s	127.0.0.1i&s200 PORT OKsRETR spam
s226 Transfer Complete.(RRCRVtgeneratePortCommandRgR,RWRXR_R:RRRRfR$(RRRvRuR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	test_RETRis 	
	

csfd}|j_jt}jjd|}j|tjjj	j
dj	jjjdtj
ddfjj	j
dj	jjjd|S(	s
        Try to RETR an unexisting file.

        L{ftp.FTPClient.retrieveFile} should return a Deferred which
        errbacks with L{ftp.CommandFailed} if the server indicates the file
        cannot be transferred for some reason.
        cs{j|dj|d|j||f}|jtjjjd|jtj	t
jddS(Ns	127.0.0.1i90s4150 File status okay; about to open data connection.R-(R_R=R^RRwRCR$R4RR`RRx(RRTRRu(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRys	RzsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sRETR spam
s#550 spam: No such file or directory(RCR{RgR,RWRnRRoR_R:RRfR$R(RRyRuR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedRETRs	
	

cst|j_gfd}||j_|jt}|jjd|}|j|jj	dt
jddf|jj|jj
d|j|jj	d|jdj|jj|j|t
j|S(	s
        Try a RETR, but disconnect during the transfer.
        L{ftp.FTPClient.retrieveFile} should return a Deferred which
        errbacks with L{ftp.ConnectionLost)
        csidtjddf|_tj}|jj||j|_|jjddj|dS(NsPORT %ss	127.0.0.1i&Ri(	RRR}RR]R
R^R1R"(R~Rb(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRsRzs	PORT %s
s	127.0.0.1i&s200 PORT OKsRETR spam
i(RRCRVRRgR,RWR_R:RRRRfR$tassert_R;RnRe(RRRuR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
test_lostRETRs"
	


cstjfd}fd}fd}|j_jjjd\}}|j||j|jjj	djj
jjdtj
ddfjjj	d	jj
jjd
tj||gS(s
        Test the STOR command: send a file and verify its content.

        L{ftp.FTPClient.storeFile} should return a two-tuple of Deferreds.
        The first of which should fire with a protocol instance when the
        data connection has been established and is responsible for sending
        the contents of the file.  The second of which should fire when the
        upload has completed, the data connection has been closed, and the
        server has acknowledged receipt of the file.

        (XXX - storeFile should take a producer as an argument, instead, and
        only return a Deferred which fires when the upload has succeeded or
        failed).
        csQjjd|jjdd|j|jtjtj	ddS(Ns4150 File status okay; about to open data connection.RiR-(
RCR$R:RtfinishR4RR`RRx(tsender(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbStores
	
csjjdddS(NRi(R_R(tign(RRb(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbFinishscsFj|dj|d|j||f}|jdS(Ns	127.0.0.1i90(R_R=R^(RRTRRu(RRb(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRysRzsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sSTOR spam
s226 Transfer Complete.(RRwRCR{RgRRXR_R:RRfR$RRRRY(RRRRyRAR]((RRbs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_passiveSTORs"




cs
tjfd}fd}|j_jjjd\}}|j|j|tj	j
jjdjj
jjdtjddfj
jjdjj
jjd	tj||gS(
s
        Test a failure in the STOR command.

        If the server does not acknowledge successful receipt of the
        uploaded file, the second Deferred returned by
        L{ftp.FTPClient.storeFile} should errback with L{ftp.CommandFailed}.
        csQjjd|jjdd|j|jtjtj	ddS(Ns4150 File status okay; about to open data connection.RiR-(
RCR$R:RRR4RR`RRx(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs
	
csFj|dj|d|j||f}|jdS(Ns	127.0.0.1i90(R_R=R^(RRTRRu(RRb(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRy
sRzsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sSTOR spam
s.426 Transfer aborted.  Data connection closed.(RRwRCR{RgRRXRnRRoR_R:RRfR$RRRY(RRRyRAR]((RRbs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedSTORs"



	cstjtj_fd}fd}fd}|j_jjjd\}}|j||j|t	j
||gS(s
        Test the STOR command in non-passive mode.

        Like L{test_passiveSTOR} but in the configuration where the server
        establishes the data connection to the client, rather than the other
        way around.
        cs-dtjdd|_|jjdS(NsPORT %ss	127.0.0.1i&(RRR}R
R^(R~(Rb(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR-scsjjjdtjddfjjjjdjjjdjjjjd|jjdd|j	|j
tjt
jd	jjd
dS(Ns	PORT %s
s	127.0.0.1i&s200 PORT OKsSTOR spam
s4150 File status okay; about to open data connection.RiR-s226 Transfer Complete.(R_R:RRRRfRCR$RRR4RR`RRx(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR1s

	
csjjdddS(NRi(R_R(R(RRb(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR?sRz(RRwRRCRVRRgRRXRRY(RRRRRAR]((RRbs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	test_STOR#s


csfd}fd}|j_jtj}jjd|j||}jjj	djj
jjdtjddfjjj	djjd	|S(
s{
        Test the LIST command.

        L{ftp.FTPClient.list} should return a Deferred which fires with a
        protocol instance which was passed to list after the command has
        succeeded.

        (XXX - This is a very unfortunate API; if my understanding is
        correct, the results are always at least line-oriented, so allowing
        a per-line parser function to be specified would make this simpler,
        but a default implementation should really be provided which knows
        how to deal with all the formats used in real servers, so
        application developers never have to care about this insanity.  It
        would also be nice to either get back a Deferred of a list of
        filenames or to be able to consume the files as they are received
        (which the current API does allow, but in a somewhat inconvenient
        fashion) -exarkun)
        csWg|jD]}|d^q
}dddg}|j|jj||dS(NR=RRtbaz(R2RR_(RR3R tflstexpected(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbList]s
 

csj|dj|d|j||f}|jtjjjddddg}x|D]}|j|qnW|jt	j
tjddS(Ns	127.0.0.1i90s4150 File status okay; about to open data connection.s8-rw-r--r--    0 spam      egg      100 Oct 10 2006 foo
s8-rw-r--r--    3 spam      egg      100 Oct 10 2006 bar
s8-rw-r--r--    4 spam      egg      100 Oct 10 2006 baz
R-(
R_R=R^RRwRCR$R1R4RR`RRx(RRTRRutsendingR(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRyds		
sfoo/barsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sLIST foo/bar
s226 Transfer Complete.(
RCR{RgRR/RRXR_R:RRfR$R(RRRyR3R0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_passiveLISTJs
!
cstj_fd}fd}|j_jtj}jjd|j||}j	j
jdtjddfj
j
jjdj	j
jdj
j
jjd	|S(
s
        Test the LIST command in non-passive mode.

        Like L{test_passiveLIST} but in the configuration where the server
        establishes the data connection to the client, rather than the other
        way around.
        csdtjddf|_|jjtjjjddddg}x|D]}|jj	|qXW|jj
tjt
jddS(	NsPORT %ss	127.0.0.1i&s4150 File status okay; about to open data connection.s8-rw-r--r--    0 spam      egg      100 Oct 10 2006 foo
s8-rw-r--r--    3 spam      egg      100 Oct 10 2006 bar
s8-rw-r--r--    4 spam      egg      100 Oct 10 2006 baz
R-(RRR}R
R^RRwRCR$R1R4RR`RRx(R~RR(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs		
	csWg|jD]}|d^q
}dddg}|j|jj||dS(NR=RRR(R2RR_(RR3R RR(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs
 

sfoo/bars	PORT %s
s	127.0.0.1i&s200 PORT OKsLIST foo/bar
s226 Transfer Complete.(RRCRVRRgRR/RRXR_R:RRRfR$(RRRR3R0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	test_LISTs
!

csfd}|j_jtj}jjd|}j|tjjj	j
dj	jjjdtj
ddfjj	j
djjd|S(	s
        Test a failure in LIST command.

        L{ftp.FTPClient.list} should return a Deferred which fails with
        L{ftp.CommandFailed} if the server indicates the indicated path is
        invalid for some reason.
        cs{j|dj|d|j||f}|jtjjjd|jtj	t
jddS(Ns	127.0.0.1i90s4150 File status okay; about to open data connection.R-(R_R=R^RRwRCR$R4RR`RRx(RRTRRu(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRys	sfoo/barsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sLIST foo/bar
s&550 foo/bar: No such file or directory(RCR{RgRR/RRnRoR_R:RRfR$R(RRyR3R0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedLISTs	

cstj_fd}fd}|j_jt}jjd|j||}jj	j
dtjddfj	j
jjdjj	j
djjd	|S(
s
        Test the NLST command in non-passive mode.

        L{ftp.FTPClient.nlst} should return a Deferred which fires with a
        list of filenames when the list command has completed.
        csdtjddf|_|jjtjjjd|jj	d|jj	d|jj	d|jj
tjt
jddS(	NsPORT %ss	127.0.0.1i&s4150 File status okay; about to open data connection.sfoo
sbar
sbaz
R-(RRR}R
R^RRwRCR$R1R4RR`RRx(R~(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs		csF|jj}dddg}|j|jj||dS(NRRR(R.t
splitlinesRR_(RRuRR(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs


sfoo/bars	PORT %s
s	127.0.0.1i&s200 PORT OKsNLST foo/bar
s226 Transfer Complete.(RRCRVRRgR,tnlstRXR_R:RRRRfR$(RRRtlstprotoR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	test_NLSTs
	!
csfd}fd}|j_jt}jjd|j||}jjjdjj	jj
dtjddfjjjdjj
d	|S(
s
        Test the NLST command.

        Like L{test_passiveNLST} but in the configuration where the server
        establishes the data connection to the client, rather than the other
        way around.
        csF|jj}dddg}|j|jj||dS(NRRR(R.RRR_(RRuRR(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs


csj|dj|d|j||f}|jtjjjd|jd|jd|jd|jt	j
tjddS(Ns	127.0.0.1i90s4150 File status okay; about to open data connection.sfoo
sbar
sbaz
R-(
R_R=R^RRwRCR$R1R4RR`RRx(RRTRRu(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRys	


sfoo/barsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sNLST foo/bar
s226 Transfer Complete.(
RCR{RgR,RRXR_R:RRfR$RR(RRRyRR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_passiveNLSTs
	!
cstjfd}|j_jt}jjd|}j|tj	j
jjdjj
jjdtjddfj
jjdjjd|S(	s
        Test a failure in NLST command.

        L{ftp.FTPClient.nlst} should return a Deferred which fails with
        L{ftp.CommandFailed} if the server indicates the indicated path is
        invalid for some reason.
        csuj|dj|d|j||f}|jjjd|jtjtj	ddS(Ns	127.0.0.1i90s4150 File status okay; about to open data connection.R-(
R_R=R^RCR$R4RR`RRx(RRTRRu(RRb(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRy%s
	sfoo/barsPASV
s227 Entering Passive Mode (%s).s	127.0.0.1i90sNLST foo/bar
s&550 foo/bar: No such file or directory(RRwRCR{RgR,RRnRRoR_R:RRfR$R(RRyRR0((RRbs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedNLSTs	
	
cs?jjtdtfd}jjd|S(sw
        L{ftp.FTPClient.changeDirectory} is deprecated and the direct caller of
        it is warned of this.
        s]FTPClient.changeDirectory is deprecated in Twisted 8.2 and newer.  Use FTPClient.cwd instead.csjjdS(Nt.(RCtchangeDirectory((R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRGss250 success(RgtassertWarnstDeprecationWarningt__file__RCR$(RR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_changeDirectoryDeprecated<s
csafd}jjjdj|}jjjdjjd|S(s
        Test the changeDirectory method.

        L{ftp.FTPClient.changeDirectory} should return a Deferred which fires
        with True if succeeded.
        csj|tdS(N(R_R(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbCdVssbar/foos
CWD bar/foo
s&250 Requested File Action Completed OK(RgRCRRXR_R:RR$(RRR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_changeDirectoryOs
cCs\|j|jjd}|j|tj|j|jjd|jj	d|S(sx
        Test a failure in the changeDirectory method.

        The behaviour here is the same as a failed CWD.
        sbar/foos
CWD bar/foo
s&550 bar/foo: No such file or directory(
RgRCRRnRRoR_R:RR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedChangeDirectoryas
cCs\|j|jjd}|j|tj|j|jjd|jj	d|S(s
        Test a strange failure in changeDirectory method.

        L{ftp.FTPClient.changeDirectory} is stricter than CWD as it checks
        code 250 for success.
        sbar/foos
CWD bar/foo
s252 I do what I want !(
RgRCRRnRRoR_R:RR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!test_strangeFailedChangeDirectoryps
cCs|j|jjdd}|j|jjd|jjd}|jj||j|jjdd}|jj||j|j|g|gf|S(s
        L{ftp.FTPClient.rename} issues I{RNTO} and I{RNFR} commands and returns
        a L{Deferred} which fires when a file has successfully been renamed.
        s/spams/hamsRNFR /spam
s8350 Requested file action pending further information.
sRNTO /ham
s&250 Requested File Action Completed OK(	RgRCtrenameR_R:RRfR$RX(RR0tfromResponset
toResponse((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_renameFromTos

cCsf|jd}d}|jj|||jjd|jjd|j|jjddS(s
        L{ftp.FTPClient.rename} issues I{RNTO} and I{RNFR} commands with paths
        escaped according to U{http://cr.yp.to/ftp/filesystem.html}.
        s
/foo/ba
r/bazs/qu
uxs350 s250 s!RNFR /foo/bar/baz
RNTO /quux
N(RgRCRR$R_R:R(RtfromFilettoFile((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_renameFromToEscapesPathss
cCs|j|jjdd}|j|jjd|jj|jjd|j|jjd|j|t	j
S(s
        The L{Deferred} returned by L{ftp.FTPClient.rename} is errbacked with
        L{CommandFailed} if the I{RNFR} command receives an error response code
        (for example, because the file does not exist).
        s/spams/hamsRNFR /spam
s!550 Requested file unavailable.
R-(RgRCRR_R:RRfR$RnRRo(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt$test_renameFromToFailingOnFirstErrors

cCs|j|jjdd}|j|jjd|jj|jjd|j|jjd|jjd|j|t	j
S(s
        The L{Deferred} returned by L{ftp.FTPClient.rename} is errbacked with
        L{CommandFailed} if the I{RNTO} command receives an error response code
        (for example, because the destination directory does not exist).
        s/spams/hamsRNFR /spam
s8350 Requested file action pending further information.
sRNTO /ham
s!550 Requested file unavailable.
(RgRCRR_R:RRfR$RnRRo(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt"test_renameFromToFailingOnRenameTos

cCs[|j|jjd}|j|jjd|jjd|j|jdgS(s
        L{ftp.FTPClient.makeDirectory} issues a I{MKD} command and returns a
        L{Deferred} which is called back with the server's response if the
        directory is created.
        s/spamsMKD /spam
s257 "/spam" created.(RgRCt
makeDirectoryR_R:RR$RX(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_makeDirectorys

cCsI|j|jjd}|j|jjd|jjd|S(s
        L{ftp.FTPClient.makeDirectory} escapes the path name it sends according
        to U{http://cr.yp.to/ftp/filesystem.html}.
        s/sp
amsMKD /spam
s257 win(RgRCRR_R:RR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_makeDirectoryPathEscapes

cCsX|j|jjd}|j|jjd|jjd|j|tj	S(s
        L{ftp.FTPClient.makeDirectory} returns a L{Deferred} which is errbacked
        with L{CommandFailed} if the server returns an error response code.
        s/spamsMKD /spam
s550 PERMISSION DENIED(
RgRCRR_R:RR$RnRRo(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedMakeDirectorys

cs^fd}jjjj|}jjjdjjd|S(s
        Test the getDirectory method.

        L{ftp.FTPClient.getDirectory} should return a Deferred which fires with
        the current directory on the server. It wraps PWD command.
        csj|ddS(Ns/bar/baz(R_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbGetssPWD
s257 "/bar/baz"(RgRCtgetDirectoryRXR_R:RR$(RRR0((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_getDirectorys
cCsY|j|jj}|j|tj|j|jjd|jj	d|S(sj
        Test a failure in getDirectory method.

        The behaviour should be the same as PWD.
        sPWD
s'550 /bar/baz: No such file or directory(
RgRCRRnRRoR_R:RR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedGetDirectory	s
cCsY|j|jj}|j|tj|j|jjd|jj	d|S(s
        Test a different failure in getDirectory method.

        The response should be quoted to be parsed, so it returns an error
        otherwise.
        sPWD
s257 /bar/baz(
RgRCRRnRRoR_R:RR$(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_anotherFailedGetDirectorys
cCsa|j|jjd}|j|jjdd}|jj||j|j|gS(s
        L{ftp.FTPClient.removeFile} sends a I{DELE} command to the server for
        the indicated file and returns a Deferred which fires after the server
        sends a 250 response code.
        s	/tmp/testsDELE /tmp/test
s*250 Requested file action okay, completed.(RgRCt
removeFileR_R:RR$RX(RR0tresponse((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_removeFile&s
cs}jjjd}jjjddjjj|tj	}|j
fd|S(s
        If the server returns a response code other than 250 in response to a
        I{DELE} sent by L{ftp.FTPClient.removeFile}, the L{Deferred} returned
        by C{removeFile} is errbacked with a L{Failure} wrapping a
        L{CommandFailed}.
        s	/tmp/testsDELE /tmp/test
s,501 Syntax error in parameters or arguments.csj|jgfS(N(R_Rj(texc(RR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRAs(RgRCRR_R:RR$RnRRoRX(RR0((RRs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedRemoveFile4s
csdjjjd}djjj|tj}|jfd|S(s
        If the server returns a response line which cannot be parsed, the
        L{Deferred} returned by L{ftp.FTPClient.removeFile} is errbacked with a
        L{BadResponse} containing the response.
        s	/tmp/tests765 blah blah blahcsj|jgfS(N(R_Rj(R(RR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRPs(RgRCRR$RnRtBadResponseRX(RR0((RRs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!test_unparsableRemoveFileResponseEs
cCsK|j|jjd}ddg}t|jj||j|jS(s
        If the server returns multiple response lines, the L{Deferred} returned
        by L{ftp.FTPClient.removeFile} is still fired with a true value if the
        ultimate response code is 250.
        s	/tmp/tests250-perhaps a progress reports250 okay(RgRCRRR$RXR(RR0R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt test_multilineRemoveFileResponseTs
	cCsa|j|jjd}|j|jjdd}|jj||j|j|gS(s
        L{ftp.FTPClient.removeDirectory} sends a I{RMD} command to the server
        for the indicated directory and returns a Deferred which fires after
        the server sends a 250 response code.
        s	/tmp/testsRMD /tmp/test
s*250 Requested file action okay, completed.(RgRCtremoveDirectoryR_R:RR$RX(RR0R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_removeDirectorybs
cs}jjjd}jjjddjjj|tj	}|j
fd|S(s
        If the server returns a response code other than 250 in response to a
        I{RMD} sent by L{ftp.FTPClient.removeDirectory}, the L{Deferred}
        returned by C{removeDirectory} is errbacked with a L{Failure} wrapping
        a L{CommandFailed}.
        s	/tmp/testsRMD /tmp/test
s,501 Syntax error in parameters or arguments.csj|jgfS(N(R_Rj(R(RR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR}s(RgRCRR_R:RR$RnRRoRX(RR0((RRs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_failedRemoveDirectoryps
csdjjjd}djjj|tj}|jfd|S(s
        If the server returns a response line which cannot be parsed, the
        L{Deferred} returned by L{ftp.FTPClient.removeDirectory} is errbacked
        with a L{BadResponse} containing the response.
        s	/tmp/tests765 blah blah blahcsj|jgfS(N(R_Rj(R(RR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs(RgRCRR$RnRRRX(RR0((RRs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt&test_unparsableRemoveDirectoryResponses
cCsK|j|jjd}ddg}t|jj||j|jS(s
        If the server returns multiple response lines, the L{Deferred} returned
        by L{ftp.FTPClient.removeDirectory} is still fired with a true value
         if the ultimate response code is 250.
        s	/tmp/tests250-perhaps a progress reports250 okay(RgRCRRR$RXR(RR0R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt%test_multilineRemoveDirectoryResponses
	(1R(R)RrR^RRgRjRkRoRpRsRtR|RRRRRRRRRRRRRRt_changeDirectorySuppressiontsuppressRRRRRRRRRRRRRRRRRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRds`	
									'	#	 	"	/	&	'	7	-		'	(	 				
							
										tFTPClientBasicTestscBs5eZdZdZdZdZdZRS(cCs3tj}|jd|jdg|jdS(Ns220 Imaginary FTP.(RRsR$R_tgreeting(RRa((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestGreetings
cCs3tj}|jd|jdg|jdS(Ns220 (RRsR$R_R(RRa((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestResponseWithNoMessages
cCsEtj}tj|_|jd|jd}g}|j|j|j	|j
|jd|jg||jd|jg||jd|jg||jd|jg||jd|jg||jd|jg||jd	|jddddddd	g|d
dS(Ns220 Imaginary FTP.tBLAHs210-First line.s123-Second line.sJust some text.tHiR-t321s	210 Done.i(RRsRRwR:R$RcRXR"RRR_(RRaRR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestMultilineResponses8







cCstj}tj|_|jd|jdd|jd|jj	|jj
|jd|jd|jj	dS(sO
        Passing None as the password avoids sending the PASS command.
        s220 Welcome to Imaginary FTP.tbobs
USER bob
s200 Hello bob.R-N(RRsRRwR:R$t
queueLoginR*R_RRf(RRa((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_noPasswordGivens


cCstj}tj|_|jd|jdd|jd|jj|jj	|jd|jd|jjdS(sQ
        Receiving a 230 response to USER prevents PASS from being sent.
        s220 Welcome to Imaginary FTP.Rtsecrets
USER bob
s#230 Hello bob.  No password needed.R-N(
RRsRRwR:R$RR_RRf(RRa((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_noPasswordNeededs


(R(R)RRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs
			0	tPathHandlingcBseZdZRS(c
Cs@xddgfddgfdgfddddgfddddgfddgfd	dgfgD](\}}|jtjg||qdWxdddgfd
ddgfddgfddgfd
dddgfddddgfdddgfdddgfgD]+\}}|jtjdg||qWx`dgfddgfddgfdddgfgD](\}}|jtjg||quWxZdgfddgfddddgfgD]+\}}|jtjdg||qWxdgfdgfddgfdgfddgfddgfdddgfdddgfd dgfd!dgfd"gfd#gfgD]+\}}|jtjdg||qWxEddd$d%d&d'd(d)d*g	D]"}|jtjtjg|qWx6d+d,d-gD]%}|jtjtjdg|qWdS(.NRs/at/sa/b/cRtcs/a/b/cs/a/sa/sb/s/bs/b/sb/csb/c/s/b/cs/b/c/s//s//asa//sa//bs//bsb//cs..s../sa/..Rs/a/..s/a/b/..s/a/b/../s	/a/b/../cs
/a/b/../c/s/a/b/../../cs
/a/b/../../c/s/a/b/../../c/..s/a/b/../../c/../sa/../..sa/../../s/..s/../s/a/../..s	/a/../../s
/a/b/../../..s../..s../../s
../a/../..(R_Rt
toSegmentsRtInvalidPath(Rtinptoutp((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttestNormalizer
sZ	 # "#			#
 (R(R)R(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRstBaseFTPRealmTestscBs2eZdZdZdZdZdZRS(s
    Tests for L{ftp.BaseFTPRealm}, a base class to help define L{IFTPShell}
    realms with different user home directory policies.
    cCs|jtttjdS(s;
        L{ftp.BaseFTPRealm} implements L{IRealm}.
        N(RRRRtBaseFTPRealm(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_interfaceHscstj|jgdtjffdY}||j}|jddtj\}}}|j|tj	|j
|jdS(s
        L{ftp.BaseFTPRealm} calls its C{getHomeDirectory} method with the
        avatarId being requested to determine the home directory for that
        avatar.
        t	TestRealmcseZfdZRS(csj|S(N(R"(RtavatarId(tavatarsR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytgetHomeDirectoryXs
(R(R)R((RR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRWssalice@example.comN(RRIRERRt
requestAvatarR*t	IFTPShellR!tFTPShellR_tfilesystemRoot(RRtrealmtifacetavatartlogout((RRs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_getHomeDirectoryOs"cCsr|j}tj|}|jtjdtj\}}}|j|tj	|j
|jtj
|dS(sy
        L{ftp.BaseFTPRealm} returns an L{ftp.FTPAnonymousShell} instance for
        anonymous avatar requests.
        N(RERRRRt	ANONYMOUSR*RR!RR_RRRI(RR6RRRR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_anonymouscscCs2tj|j}|jt|jtdS(s
        L{ftp.BaseFTPRealm.getHomeDirectory} should be overridden by a subclass
        and raises L{NotImplementedError} if it is not.
        N(RRRERtNotImplementedErrorRR(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_notImplementedps(R(R)RrRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRCs
			
tFTPRealmTestCasecBs eZdZdZdZRS(s$
    Tests for L{ftp.FTPRealm}.
    cCsSd}tj|j|}|jd}|jtj|jd|dS(s
        L{ftp.FTPRealm} accepts an extra directory to its initializer and treats
        the avatarId passed to L{ftp.FTPRealm.getHomeDirectory} as a single path
        segment to construct a child of that directory.
        s
/path/to/homesalice@example.comN(RRLRERR_RRIR(RtbaseRthome((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR~s
cCsAtj|j}|jd}|jtjd|dS(s
        If no extra directory is passed to L{ftp.FTPRealm}, it uses C{"/home"}
        as the base directory containing all user home directories.
        salice@example.coms/home/alice@example.comN(RRLRERR_RRI(RRR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_defaultHomeDirectorys(R(R)RrRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRzs	
tSystemFTPRealmTestscBs&eZdZeZdZdZRS(s*
    Tests for L{ftp.SystemFTPRealm}.
    cCsktj}ddl}|j|j}tj|j}|j|}|j	|t
j|dS(s
        L{ftp.SystemFTPRealm.getHomeDirectory} treats the avatarId passed to it
        as a username in the underlying platform and returns that account's home
        directory.
        iN(tgetpasstgetuserRntgetpwnamtpw_dirRtSystemFTPRealmRERR_RRI(RtuserRnRRR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRscCsDtdjd}tj|j}|jt|j|dS(s
        L{ftp.SystemFTPRealm.getHomeDirectory} raises L{UnauthorizedLogin} when
        passed a username which has no corresponding home directory in the
        system's accounts database.
        ithexN(RtencodeRRRERRR(RRR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_noSuchUsers(R(R)RrtnonPOSIXSkiptskipRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs	tErrnoToFailureTestCasecBsMeZdZdZdZdZdZdZdZdZ	RS(s9
    Tests for L{ftp.errnoToFailure} errno checking.
    cCs(tjtjd}|j|tjS(sS
        C{errno.ENOENT} should be translated to L{ftp.FileNotFoundError}.
        R(RterrnoToFailureterrnotENOENTRntFileNotFoundError(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
test_notFoundscCs(tjtjd}|j|tjS(sV
        C{errno.EPERM} should be translated to L{ftp.PermissionDeniedError}.
        R(RRRtEPERMRntPermissionDeniedError(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_permissionDeniedscCs(tjtjd}|j|tjS(sW
        C{errno.EACCES} should be translated to L{ftp.PermissionDeniedError}.
        R(RRRtEACCESRnR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_accessDeniedscCs(tjtjd}|j|tjS(sW
        C{errno.ENOTDIR} should be translated to L{ftp.IsNotADirectoryError}.
        R(RRRtENOTDIRRnR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_notDirectoryscCs(tjtjd}|j|tjS(sQ
        C{errno.EEXIST} should be translated to L{ftp.FileExistsError}.
        R(RRRtEEXISTRntFileExistsError(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_fileExistsscCs(tjtjd}|j|tjS(sS
        C{errno.EISDIR} should be translated to L{ftp.IsADirectoryError}.
        R(RRRtEISDIRRntIsADirectoryError(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_isDirectoryscCs=ytdWn&tjdd}|j|tSXdS(s
        If an unknown errno is passed to L{ftp.errnoToFailure}, it should let
        the originating exception pass through.
        RiRN(RRRRn(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_passThroughs
(
R(R)RrRRR	RRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRs						tAnonymousFTPShellTestCasecBseZdZdZRS(s*
    Test anynomous shell properties.
    cCs5tjd}|jd}|j|tj|S(st
        Check that L{ftp.FTPAnonymousShell} returns an error when trying to
        open it in write mode.
        R-R(sfoo(RRRRnR(RtshellR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_anonymousWrite	s(R(R)RrR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRstIFTPShellTestsMixincBsCeZdZdZdZdZddZdZdZdZ	d	Z
d
ZdZdZ
d
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ d Z!d!Z"d"Z#d#Z$RS($s7
    Generic tests for the C{IFTPShell} interface.
    cCs
tdS(s

        Test if the directory exists at C{path}.

        @param path: the relative path to check.
        @type path: C{str}.

        @return: C{True} if C{path} exists and is a directory, C{False} if
            it's not the case
        @rtype: C{bool}
        N(R(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytdirectoryExists	scCs
tdS(s
        Create a directory in C{path}.

        @param path: the relative path of the directory to create, with one
            segment.
        @type path: C{str}
        N(R(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR"	scCs
tdS(s
        Test if the file exists at C{path}.

        @param path: the relative path to check.
        @type path: C{str}.

        @return: C{True} if C{path} exists and is a file, C{False} if it's not
            the case.
        @rtype: C{bool}
        N(R(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
fileExists-	sR-cCs
tdS(s
        Create a file named C{path} with some content.

        @param path: the relative path of the file to create, without
            directory.
        @type path: C{str}

        @param fileContent: the content of the file.
        @type fileContent: C{str}
        N(R(RRtfileContent((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
createFile;	scCs=|j|jd|jd|j|jddS(s
        C{directoryExists} should report correctly about directory existence,
        and C{createDirectory} should create a directory detectable by
        C{directoryExists}.
        RN(RRRR(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_createDirectoryI	s
cCs=|j|jd|jd|j|jddS(s
        C{fileExists} should report correctly about file existence, and
        C{createFile} should create a file detectable by C{fileExists}.
        sfile.txtN(RRRR(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_createFileT	s
cs.jjd}fd}|j|S(sI
        Create a directory and check it ends in the filesystem.
        RcsjjddS(NR(RR(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcbc	s(sfoo(RRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^	scCs2|jd|jjd}|j|tjS(sm
        Creating a directory that already exists should fail with a
        C{ftp.FileExistsError}.
        R(sfoo(RRRRnRR
(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_makeDirectoryErrorh	s
cs;jdjjd}fd}|j|S(sW
        Try to remove a directory and check it's removed from the filesystem.
        RcsjjddS(NR(RR(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRx	s(sbar(RRRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRr	s
cCs2|jd|jjd}|j|tjS(sn
        removeDirectory should not work in file and fail with a
        C{ftp.IsNotADirectoryError}.
        sfile.txt(sfile.txt(RRRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_removeDirectoryOnFile}	s
cCs%|jjd}|j|tjS(sl
        Removing directory that doesn't exist should fail with a
        C{ftp.FileNotFoundError}.
        R(sbar(RRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_removeNotExistingDirectory	scs?jdjjd}fd}|j||S(sR
        Try to remove a file and check it's removed from the filesystem.
        sfile.txtcsjjddS(Nsfile.txt(RR(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR	s(sfile.txt(RRRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR	s


cCs2|jd|jjd}|j|tjS(s:
        removeFile should not work on directory.
        tned(R!(RRRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_removeFileOnDirectory	s
cCs%|jjd}|j|tjS(sl
        Try to remove a non existent file, and check it raises a
        L{ftp.FileNotFoundError}.
        R(sfoo(RRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_removeNotExistingFile	scsHjdjdjjd}fd}|j|S(s6
        Check the output of the list method.
        R!sfile.txtRcs0|jj|dgfdgfgdS(Nsfile.txtR!(RR_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR	s
	(R(RRRRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	test_list	s


csKjdjdjjdd}fd}|j|S(	s<
        Check the output of list with asked stats.
        R!sfile.txtRRtpermissionscs|jjt|dj|dddj|dddjt|dddjt|ddddS(Niisfile.txtiR!(RR_R(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR	s
(R(ssizeR%(RRRRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_listWithStat	s


	cCs2|jd|jjdd}|j|tS(sP
        Querying an invalid stat should result to a C{AttributeError}.
        R!RRtwhateverstat(R(ssizeR'(RRRRntAttributeError(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_listWithInvalidStat	s
cs;jdjjd}fd}|j|S(s@
        Check the output of the list method on a file.
        sfile.txtcs'|jj|dgfgdS(Nsfile.txt(RR_(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR	s
	(sfile.txt(RRRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
test_listFile	s
cCs%|jjd}|j|tjS(sm
        list on a directory that doesn't exist should fail with a
        L{ftp.FileNotFoundError}.
        R(sfoo(RRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_listNotExistingDirectory	scCs#|jd|jjd}|S(s+
        Try to access a resource.
        R!(sned(RRtaccess(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_access	s
cCs%|jjd}|j|tjS(sF
        access should fail on a resource that doesn't exist.
        R(sfoo(RR,RnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_accessNotFound	scs?jdjjd}fd}|j||S(sY
        Check that openForReading returns an object providing C{ftp.IReadFile}.
        sfile.txtcsjtjj|dS(N(RRt	IReadFilet
providedBy(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR
s(sfile.txt(RRtopenForReadingRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_openForReading	s


cCs%|jjd}|j|tjS(sr
        openForReading should fail with a C{ftp.FileNotFoundError} on a file
        that doesn't exist.
        R!(sned(RR1RnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_openForReadingNotFound
scCs2|jd|jjd}|j|tjS(s>
        openForReading should not work on directory.
        R!(sned(RRR1RnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_openForReadingOnDirectory
s
csDjjd}fd}fd|j||S(sZ
        Check that openForWriting returns an object providing C{ftp.IWriteFile}.
        Rcs,jtjj||jjS(N(RRt
IWriteFileR0RRX(R(tcb2R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytcb1"
scsjtj|dS(N(RR
R0(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR6%
s(sfoo(RRRX(RR0R7((R6Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_openForWriting
s

cCs2|jd|jjd}|j|tjS(sd
        openForWriting should not be able to open a directory that already
        exists.
        R!(sned(RRRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt$test_openForWritingExistingDirectory+
s
cCs2|jd|jjd}|j|tjS(s
        openForWring should fail with a L{ftp.FileNotFoundError} if you specify
        a file in a directory that doesn't exist.
        R!tidonotexistR(snedR:sfoo(RRRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt)test_openForWritingInNotExistingDirectory5
s
csNdjdjjdd}fd}|j||S(s@
        Check the output of the stat method on a file.
        swobble
sfile.txtRRFcs/j|dtj|ddS(Nii(R_RR(R(RR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRF
s(sfile.txt(ssizes	directory(RRtstatRX(RR0R((RRs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
test_statFile?
s
csBjdjjdd}fd}|j||S(sE
        Check the output of the stat method on a directory.
        R!RRFcsj|ddS(Ni(R(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRS
s(sned(ssizes	directory(RRR<RX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_statDirectoryM
s


csBjdjjdd}fd}|j||S(s3
        Check the owner and groups stats.
        R!R9R;csjt|ddS(Ni(R_R(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR_
s(sned(sownersgroup(RRR<RX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_statOwnerGroupY
s


cCs(|jjdd}|j|tjS(sf
        stat should fail with L{ftp.FileNotFoundError} on a file that doesn't
        exist.
        RRRF(sfoo(ssizes	directory(RR<RnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_statNotExistinge
scCs2|jd|jjdd}|j|tS(sP
        Querying an invalid stat should result to a C{AttributeError}.
        R!RR'(sned(ssizeswhateverstat(RRR<RnR((RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_invalidStatn
s
cs>jdjjdd}fd}|j|S(s,
        Try to rename a directory.
        R!Rcs0jjdjjddS(NRR!(RRR(R(R(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR}
s(sned(sfoo(RRRRX(RR0R((Rs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_renamew
s
cCs(|jjdd}|j|tjS(sl
        Renaming a directory that doesn't exist should fail with
        L{ftp.FileNotFoundError}.
        RR(sfoo(sbar(RRRnRR(RR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_renameNotExisting
s(%R(R)RrRRRRRRRRRRR RR"R#R$R&R)R*R+R-R.R2R3R4R8R9R;R=R>R?R@RARBRC(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR	sF					
	
	
		
												
												
	
								tFTPShellTestCasecBs>eZdZdZdZdZdZddZRS(s/
    Tests for the C{ftp.FTPShell} object.
    cCs>tj|j|_|jjtj|j|_dS(sB
        Create a root directory and instantiate a shell.
        N(RRIRER:RRRR(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^
s
cCs|jj|jS(s:
        Test if the directory exists at C{path}.
        (R:Rtisdir(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR
scCs|jj|jS(s0
        Create a directory in C{path}.
        (R:RR(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR
scCs|jj|jS(s5
        Test if the file exists at C{path}.
        (R:Rtisfile(RR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR
sR-cCs|jj|j|S(s@
        Create a file named C{path} with some content.
        (R:Rt
setContent(RRR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR
s(R(R)RrR^RRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRD
s					tTestConsumercBs9eZdZeedZdZdZdZ	RS(s
    A simple consumer for tests. It only works with non-streaming producers.

    @ivar producer: an object providing
        L{twisted.internet.interfaces.IPullProducer}.
    cCs8|jdkstg|_||_|jjdS(sc
        Simple register of producer, checks that no register has happened
        before.
        N(tproducerR*tAssertionErrorR.tresumeProducing(RRIt	streaming((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytregisterProducer
s		cCs"|jdk	std|_dS(sN
        Unregister the producer, it should be done after a register.
        N(RIR*RJ(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytunregisterProducer
scCs!|jj||jjdS(s)
        Save the data received.
        N(R.R"RIRK(RR%((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR
sN(
R(R)RrRR
R*RIRMRNR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRH
s
		tTestProducercBs eZdZdZdZRS(s
    A dumb producer.
    cCs||_||_dS(s
        @param toProduce: data to write
        @type toProduce: C{str}
        @param consumer: the consumer of data.
        @type consumer: C{IConsumer}
        N(t	toProducetconsumer(RRPRQ((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR
s	cCs|jj|jdS(s+
        Send the data to consume.
        N(RQRRP(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytstart
s(R(R)RrRRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRO
s	tIReadWriteTestsMixincBs;eZdZdZdZdZdZdZRS(sJ
    Generic tests for the C{IReadFile} and C{IWriteFile} interfaces.
    cCs
tdS(sY
        Return an object providing C{IReadFile}, ready to send data C{content}.
        N(R(Rtcontent((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
getFileReader
scCs
tdS(sR
        Return an object providing C{IWriteFile}, ready to receive data.
        N(R(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
getFileWriterscCs
tdS(s6
        Return the content of the file used.
        N(R(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pytgetFileContent
scsLdtfd}fdjj|S(s
        Test L{ftp.IReadFile}: the implementation should have a send method
        returning a C{Deferred} which fires when all the data has been sent
        to the consumer, and the data should be correctly send to the consumer.
        swobble
cs|jjS(N(tsendRX(treader(tcbSendRQ(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRscs jdjjdS(NR-(R_RR.(R(RTRRQ(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRZs(RHRURX(RR((RZRRTRQs9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	test_reads
	csLdfd}fdfdjj|S(s
        Test L{ftp.IWriteFile}: the implementation should have a receive
        method returning a C{Deferred} which fires with a consumer ready to
        receive data to be written. It should also have a close() method that
        returns a Deferred.
        selbbow
cs|jj|S(N(RRX(twriter(t	cbReceive(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR(scsFt|}|jdt|j|j|jjS(N(RORMR*RRRRNRRX(RQR\RI(tcbCloseRT(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR]*s


csjjdS(N(R_RW(Rd(RTR(s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^0s(RVRX(RR((RTRR]R^s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
test_write s
(R(R)RrRURVRWR[R_(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRS
s				tFTPReadWriteTestCasecBs2eZdZdZdZdZdZRS(s
    Tests for C{ftp._FileReader} and C{ftp._FileWriter}, the objects returned
    by the shell in C{openForReading}/C{openForWriting}.
    cCsGtj|j|_|jjtj|j|_d|_dS(s5
        Create a temporary file used later.
        sfile.txtN(	RRIRER:RRRRR=(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^<s
cCs2|jj|jj||jj|jfS(sV
        Return a C{ftp._FileReader} instance with a file opened for reading.
        (R:RR=RGRR1(RRT((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRUFscCs|jj|jfS(sV
        Return a C{ftp._FileWriter} instance with a file opened for writing.
        (RRR=(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRVNscCs|jj|jjS(s;
        Return the content of the temporary file.
        (R:RR=t
getContent(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRWUs(R(R)RrR^RURVRW(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR`6s
	
		tCloseTestWritercBs-eZeejeZdZdZRS(cCs+t|_tj|j}tj|S(N(RRRtFileConsumerRRg(Rtfc((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR_scCst|_|jS(N(RtcloseStartedR0(R((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRcs	(	R(R)RRR5RReRR(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRb\s
	tCloseTestShellcBseZdZRS(cCstj|jS(N(RRgR\(Rtsegs((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRhs(R(R)R(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRfgstFTPCloseTestcBseZdZdZRS(s.Tests that the server invokes IWriteFile.closecCsetj}dg|_t|_t|j_tj|jj_	tj
|_d|j_
|jttj}tj||_||_|jdg}|jd}|j|j|j|jjjd|jd|j|jjjd|jd|j|jjjd|j||jjj	jd|j||S(	stConfirm that FTP uploads (i.e. ftp_STOR) correctly call and wait
        upon the IWriteFile object's close() methodR:Rsclose() called earlyssome data heresreason is ignoredsclose() not calledsallow close() to finishN(RtFTPtworkingDirectoryRfRRbR\RR/R0RPRR*ttimeOutR^RR"RRtftp_STORRXR"RReR1R4RR2(RR tdit	stor_doneR0((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR_ns0	




(R(R)RrR_(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRhkstFTPResponseCodeTestscBseZdZdZRS(s4
    Tests relating directly to response codes.
    cCsttj}t}xttjD]q\}}t|tr+|jr+|j||d||f|j	||d||f|j
|q+q+WdS(s
        All of the response code globals (for example C{RESTART_MARKER_REPLY} or
        C{USR_NAME_OK_NEED_PASS}) have unique values and are present in the
        C{RESPONSE} dictionary.
        s0Code %r with value %r missing from RESPONSE dictsDuplicate code %r with value %rN(tsetRtRESPONSEtvarstitemst
isinstanceRtisuppertassertIntassertNotIntadd(Rt	allValuest
seenValuestkeyR((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyttest_uniques	(R(R)RrR|(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRos(SRrRGRRRtzope.interfaceRtzope.interface.verifyRt
twisted.trialRRttwisted.python.randbytesRttwisted.cred.portalRttwisted.protocolsRttwisted.internetRR	R
RRttwisted.internet.interfacesR
ttwisted.cred.errorRttwisted.credRRRttwisted.pythonRRRttwisted.testRRRRRRtplatformt	isWindowsRR*tLineReceiverRRRR,tTestCaseR5RtRwRRRRR+R/R-R1RTRdRRRRRRRRRDRRHRORSR`RbRfRhRo(((s9/usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt<module>st(			`15	N6m77&B+'?&&