
>Mc           @   sG  d  Z  d d l Z d d l Z d d l m Z d d l Z d d l m Z d d l m Z d d l	 m
 Z
 m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z m Z m Z m Z m Z d d l m Z d d l m Z d d l m Z m Z m Z d d l  m! Z! m" Z" m# Z# d d l$ m% Z% d d l m& Z& m' Z' e j( d e) d d  Z* e# j+ j,   rvd Z- n e. Z- d e j/ f d     YZ0 d e j1 f d     YZ2 d e
 j3 f d     YZ4 d e4 f d     YZ5 d e4 f d     YZ6 d e4 f d      YZ7 d! e4 f d"     YZ8 d# e8 f d$     YZ9 d% e
 j3 f d&     YZ: d' e j1 f d(     YZ; d) e& j< f d*     YZ= d+ e
 j3 f d,     YZ> d- e
 j3 f d.     YZ? d/ e
 j3 f d0     YZ@ d1 e
 j3 f d2     YZA d3 e
 j3 f d4     YZB d5 e
 j3 f d6     YZC d7 e
 j3 f d8     YZD d9 e
 j3 f d:     YZE d; e
 j3 f d<     YZF d= e
 j3 f d>     YZG d? f  d@     YZH dA e
 j3 eH f dB     YZI dC eJ f dD     YZK dE eJ f dF     YZL dG f  dH     YZM dI e
 j3 eM f dJ     YZN dK f  dL     YZO dM f  dN     YZP dO e
 j3 f dP     YZQ d S(Q   s)   
FTP tests.

Maintainer: Andrew Bennetts
iN(   t   StringIO(   t
   implements(   t   verifyClass(   t   unittestt   util(   t   insecureRandom(   t   IRealm(   t   basic(   t   reactort   taskt   protocolt   defert   error(   t	   IConsumer(   t   UnauthorizedLogin(   t   portalt   checkerst   credentials(   t   failuret   filepatht   runtime(   t   proto_helpers(   t   ftpt   loopbackt   categoryt   messagesb   FTPClient\.changeDirectory is deprecated in Twisted 8\.2 and newer\.  Use FTPClient\.cwd instead\.s   Cannot run on Windowst   Dummyc           B   s;   e  Z d Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s   g  |  _  g  |  _ d  S(   N(   t   linest   rawData(   t   self(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   __init__.   s    	c         C   s   |  j  |  _ d  S(   N(   t   factoryt   f(   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   connectionMade1   s    c         C   s   |  j  j |  d  S(   N(   R   t   append(   R   t   line(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   lineReceived3   s    c         C   s   |  j  j |  d  S(   N(   R   R"   (   R   t   data(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   rawDataReceived5   s    c         C   s   d  S(   N(    (   R   R#   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   lineLengthExceeded7   s    N(	   t   __name__t
   __module__t   Nonet   lognameR   R!   R$   R&   R'   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   ,   s   				t   _BufferingProtocolc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   d |  _  t j   |  _ d  S(   Nt    (   t   bufferR   t   Deferredt   d(   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR!   <   s    	c         C   s   |  j  | 7_  d  S(   N(   R.   (   R   R%   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   dataReceived?   s    c         C   s   |  j  j |   d  S(   N(   R0   t   callback(   R   t   reason(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   connectionLostA   s    (   R(   R)   R!   R1   R4   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR,   ;   s   		t   FTPServerTestCasec           B   sJ   e  Z d  Z e j Z d Z d   Z d d  Z	 d d d  Z
 d   Z RS(   sw   
    Simple tests for an FTP server with the default settings.

    @ivar clientFactory: class used as ftp client.
    t	   anonymousc            sO    j      _ t j   j  t j   j    _ t j t	 j
   j   } | j t j   t j  t	 j d | d   j    _ t j d   j d d }   j | j    j j  t j        f d   } |   j _ | j   j } t j t   j  } | j d |  }   f d   } | j  |  t j!  | g  S(   NR   t   userAnonymousi    t	   interfaces	   127.0.0.1c            sN     j  `  |   } | j   _   f d   }   j |   j d   | S(   Nc              s)     j  j d  k	 r%   j  j j   n  d  S(   N(   t   serverProtocolt	   transportR*   t   loseConnection(    (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cleanupServerh   s    (   R   t   buildProtocolt   wrappedProtocolR9   t
   addCleanupR2   R*   (   t   addrR
   R<   (   R   R=   t   d1(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   _rememberProtocolInstanceb   s    	c            s#   |    _    j   j  j j  d  S(   N(   t   clientR?   R:   R;   (   RC   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   gotClientt   s    	("   t   mktempt	   directoryt   ost   mkdirR   t   FilePatht   dirPathR   t   PortalR   t   FTPRealmt   registerCheckerR   t   AllowAnonymousAccessR   t
   IAnonymoust
   FTPFactoryR7   R   R   t	   listenTCPR?   t   stopListeningR=   R   R/   t   getHostt   portR
   t   ClientCreatort   clientFactoryt
   connectTCPt   addCallbackt   gatherResults(   R   t   pRT   RB   t   portNumt   clientCreatort   d2RD   (    (   R   R=   RA   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   setUpO   s(    
c            s@   | d k r t j d  } n      f d   } | j |  S(   s   Asserts that a sending an FTP command receives the expected
        response.

        Returns a Deferred.  Optionally accepts a deferred to chain its actions
        to.
        c            s1     j  j   }    f d   } | j |  S(   Nc            s     j   |   d  S(   N(   t   assertEquals(   t   responseLines(   R   t   expectedResponseLines(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   gotResponse   s    (   RC   t   queueStringCommandRX   (   t   ignoredR0   Rb   (   R   Ra   t   command(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   queueCommand   s    N(   R*   R   t   succeedRX   (   R   Re   Ra   t   chainDeferredRf   (    (   R   Ra   Re   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   assertCommandResponsez   s    c            so   | d  k r t j d   } n     f d   } | j |    j | t j     f d   } | j |  S(   Nc            s     j  j   S(   N(   RC   Rc   (   Rd   (   R   Re   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRf      s    c            s*     d  k	 r&  j   |  j d  n  d  S(   Ni    (   R*   t   failUnlessEqualt   args(   t	   exception(   t   expectedResponseR   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   failed   s    (   R*   R   Rg   RX   t   assertFailureR   t   CommandFailed(   R   Re   Rm   Rh   Rf   Rn   (    (   R   Re   Rm   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   assertCommandFailed   s    c         C   s.   |  j  d d g  } |  j  d d g d | S(   Ns   USER anonymouss8   331 Guest login ok, type your email address as password.s   PASS test@twistedmatrix.coms2   230 Anonymous login ok, access restrictions apply.Rh   (   Ri   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   _anonymousLogin   s    	N(   R(   R)   t   __doc__R   t   FTPClientBasicRV   R7   R^   R*   Ri   Rq   Rr   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR5   F   s   		,t   FTPAnonymousTestCasec           B   s   e  Z d  Z d Z d   Z RS(   s   
    Simple tests for an FTP server with different anonymous username.
    The new anonymous username used in this test case is "guest"
    t   guestc         C   s.   |  j  d d g  } |  j  d d g d | 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 guests8   331 Guest login ok, type your email address as password.s   PASS test@twistedmatrix.coms2   230 Anonymous login ok, access restrictions apply.Rh   (   Ri   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_anonymousLogin   s    	(   R(   R)   Rs   R7   Rw   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRu      s   t   BasicFTPServerTestCasec           B   s   e  Z 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   Z d   Z e j e  Z d   Z d   Z d   Z d   Z RS(   c      
      s   d d d d d d d d d	 d
 g
 }   f d   } g  } xM | D]E }   j  j |  }   j | t j  | j |  | j |  q@ Wt j | d t	 S(   sk   When not logged in, all commands other than USER and PASS should
        get NOT_LOGGED_IN errors.
        t   CDUPt   CWDt   LISTt   MODEt   PASVt   PWDt   RETRt   STRUt   SYSTt   TYPEc            s9   |  j  d }   j | d j d  d | d f  d  S(   Ni    it   530s"   Response didn't start with 530: %r(   Rk   t
   failUnlesst
   startswith(   Rl   t   failureResponseLines(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   checkResponse   s    t   fireOnOneErrback(
   RC   Rc   Ro   R   Rp   RX   R"   R   t   DeferredListt   True(   R   t   commandListR   t	   deferredsRe   t   deferred(    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testNotLoggedInReply   s    c         C   s   |  j  d d g  S(   s.   Issuing PASS before USER should give an error.s   PASS foos=   503 Incorrect sequence of commands: USER required before PASS(   Rq   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testPASSBeforeUSER   s    c         C   s   |  j  d d g  S(   s2   Issuing USER without a username is a syntax error.t   USERs,   500 Syntax error: USER requires an argument.(   Rq   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testNoParamsForUSER   s    c         C   s+   |  j  j d  } |  j d d g d | S(   s2   Issuing PASS without a password is a syntax error.s   USER foot   PASSs,   500 Syntax error: PASS requires an argument.Rh   (   RC   Rc   Rq   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testNoParamsForPASS   s
    	c         C   s
   |  j    S(   N(   Rr   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testAnonymousLogin   s    c         C   s%   |  j    } |  j d d g d | S(   s)   Issuing QUIT should return a 221 message.t   QUITs   221 Goodbye.Rh   (   Rr   Ri   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testQuit   s
    	c         C   s   t  |  j _ t j   } |  j j j | t j  |  j	 d d g  } |  j
 d d g d | } |  j
 d d g d | } | S(   Ns   USER anonymouss$   331 Password required for anonymous.s   PASS test@twistedmatrix.coms!   530 Sorry, Authentication failed.Rh   R~   s$   530 Please login with USER and PASS.(   t   FalseR   t   allowAnonymousR   t'   InMemoryUsernamePasswordDatabaseDontUseR   RM   R   t   IUsernamePasswordRi   Rq   (   R   t   denyAlwaysCheckerR0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testAnonymousLoginDenied   s     
				c         C   s%   |  j    } |  j d d g d | 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   (   Rr   Rq   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_anonymousWriteDenied  s
    	c         C   s%   |  j    } |  j d d g d | S(   Nt	   GIBBERISHs'   502 Command 'GIBBERISH' not implementedRh   (   Rr   Rq   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testUnknownCommand  s
    	c         C   s%   |  j    } |  j d d g d | S(   Ns   RETR foosE   503 Incorrect sequence of commands: PORT or PASV required before RETRRh   (   Rr   Rq   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testRETRBeforePORT"  s
    	c         C   s%   |  j    } |  j d d g d | S(   Ns   STOR foosE   503 Incorrect sequence of commands: PORT or PASV required before STORRh   (   Rr   Rq   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testSTORBeforePORT*  s
    	c         C   sB   |  j    } |  j d d g d | |  j d d g d | | S(   Ns   MODE zs&   504 Not implemented for parameter 'z'.Rh   s   STRU Is&   504 Not implemented for parameter 'I'.(   Rr   Rq   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testBadCommandArgs2  s    		c         C   s   |  j  t j d  d  t d  } xX t d  D]J } t |  } d | | <d j t t |   } |  j t	 t j |  q2 Wd  S(   Ns   25,234,129,22,100,23s   25.234.129.22id  i   i   t   ,(   s   25.234.129.22id  (
   R_   R   t   decodeHostPortt   ranget   listt   joint   mapt   strt   assertRaisest
   ValueError(   R   t   numst   it   badValuet   s(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testDecodeHostPort>  s    
c         c   s   t  j |  j    } | V| j   t  j |  j j d   } | V| j   } t j | d d  \ } } |  j | |  j	 j
 j   j  |  j	 j j   d  S(   NR}   ii   (   R   t   waitForDeferredRr   t	   getResultRC   Rc   R   R   t   assertEqualR9   t   dtpPortRS   RT   R:   R;   (   R   t   wfdt   pasvCmdR`   t   hostRT   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testPASVH  s    
c         C   s)   |  j    } |  j d d g d | | S(   NR   s   215 UNIX Type: L8Rh   (   Rr   Ri   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testSYST[  s    c         C   s8   d   } | |  j  _ |  j t |  j  j t j    d S(   s   
        Exceptions other than L{error.CannotListenError} which are raised by
        C{listenFactory} should be raised to the caller of L{FTP.getDTPPort}.
        c         S   s   t     d  S(   N(   t   RuntimeError(   t
   portNumberR   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   listenFactoryg  s    N(   R9   R   R   R   t
   getDTPPortR
   t   Factory(   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_portRangeForwardErrorb  s    	c         C   s   d   } | |  j  _ |  j  j t j    } |  j | d  t d d  |  j  _ |  j  j t j    } |  j | d  t d d  |  j  _ |  j t	 j
 |  j  j t j    d S(   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.
        c         S   s(   |  d k r$ t  j d |  d   n  |  S(   NiV  iV  iV  t	   localhostR   (   iV  iV  iV  (   R   t   CannotListenError(   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   v  s    i    iV  i   iV  N(   R9   R   R   R
   R   R_   t   xranget   passivePortRangeR   R   R   (   R   R   RT   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_portRangeo  s    		c         C   sG   t  d d  } | |  j _ |  j j d  } |  j | | j j  d S(   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.
        i  i  N(   R   R   R   R=   R*   R   R>   (   R   t	   portRangeR
   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt"   test_portRangeInheritedFromFactory  s    (   R(   R)   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   deferredGeneratorR   R   R   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRx      s&   													
				t   FTPServerTestCaseAdvancedClientc           B   s)   e  Z d  Z e j Z d   Z d   Z RS(   s:   
    Test FTP server with the L{ftp.FTPClient} class.
    c            sG     f d   }   j  j d  \ } } | j |  t j | | g  S(   sl   
        Try to make an STOR as anonymous, and check that we got a permission
        denied error.
        c            s2   |  j  t j    j |  j j d d d  d  S(   Ni    s   550 foo: Permission denied.(   t   trapR   Rp   R_   t   valueRk   (   t   res(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   eb  s    t   foo(   RC   t	   storeFilet
   addErrbackR   RY   (   R   R   RA   R]   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_anonymousSTOR  s    c            s   d t  j f d     Y  f d   }   j t  j d |    f d   }   j j d  \ } } | j |  t j | | g  S(   sj   
        Any errors during writing a file inside a STOR should be returned to
        the client.
        t   FailingFileWriterc           B   s   e  Z d    Z RS(   c         S   s   t  j t j d   S(   Nt   blah(   R   t   failR   t   IsNotADirectoryError(   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   receive  s    (   R(   R)   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s   c            s   t  j   d    S(   N(   R   Rg   R*   (   t   at   b(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   failingSTOR  s    t   openForWritingc            s<     j    |  j t j    j |  j j d d d  d  S(   Ni    s'   550 Cannot rmd, blah is not a directory(   t   flushLoggedErrorsR   R   Rp   R_   R   Rk   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s
    
t   failing_file(	   R   t   _FileWritert   patcht   FTPAnonymousShellRC   R   R   R   RY   (   R   R   R   RA   R]   (    (   R   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_STORwriteError  s    (   R(   R)   Rs   R   t	   FTPClientRV   R   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s   		t#   FTPServerPasvDataConnectionTestCasec           B   sV   e  Z d d   Z d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C   s(   |  j  j d  } d   } | j |  S(   NR}   c         S   s?   t  j |  d d  \ } } t j t t  } | j d |  S(   Nii   s	   127.0.0.1(   R   R   R
   RU   R   R,   RW   (   R`   R   RT   t   cc(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   gotPASV  s    (   RC   Rc   RX   (   R   Rd   R0   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   _makeDataConnection  s    	c            sc   | d  k r t j d   } n  | j   j     f d   } | j |  d   } | j |  S(   Nc            s.     j  j   } |  j } t j | | g  S(   N(   RC   Rc   R0   R   RY   (   t
   downloaderRA   R]   (   R   Re   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRf     s    	c         S   s   |  \ } } | j  S(   N(   R.   (   t   .0Rd   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   downloadDone  s    	(   R*   R   Rg   RX   R   (   R   Re   Rh   Rf   R   (    (   R   Re   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   _download  s    	c            s;     j    }   j d d |   f d   } | j |  S(   NR{   Rh   c            s     j  d |   d  S(   NR-   (   R   (   t   result(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
   checkEmpty  s    (   Rr   R   RX   (   R   R0   R   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testEmptyLIST  s    c            s"  t  j t  j j   j d   t  j t  j j   j d     j   }   j d d |   f d   } | j |    j d d |   f d   } | j |    j d d |   f d	   } | j |    f d
   } | j |    j d d |   f d   } | j |  S(   NR   t   barR{   Rh   c            s'     j  d t |  d  j d    d  S(   Ni   is   
(   R   t   lent   split(   t   download(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   checkDownload  s    s   NLST c            s7   |  d  j  d  } | j     j d d g |  d  S(   Nis   
R   R   (   R   t   sortR   (   R   t	   filenames(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s    
s   LIST fooc            s     j  d |   d  S(   NR-   (   R   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s    c            s     j  j d  S(   Ns   CWD foo(   RC   Rc   (   Rd   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   chdir  s    c            s     j  d |   d  S(   NR-   (   R   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s    (   RG   RH   t   pathR   RF   Rr   R   RX   (   R   R0   R   R   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testTwoDirLIST  s"    c            s     j    } x t d d d  D] } t t j j   j d | f  d  } | j d |  | j     j	 d | f d | |   f d	  } | j
 |  q W| S(
   Ni i i  s   %d.txtt   wbt   xs   RETR %d.txtRh   c            s     j  | t |    d  S(   N(   R   R   (   R   t   size(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   !  s    (   Rr   R   t   fileRG   R   R   RF   t   writet   closeR   RX   (   R   R0   R   t   fObjR   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testManyLargeDownloads  s    (
c            sg     j    }   j j d  j     j j d  j     j d d |   f d   } | j |  S(   sp   
        NLST with no argument returns the directory listing for the current
        working directory.
        s   test.txtR   s   NLST Rh   c            s7   |  d  j  d  } | j     j d d g |  d  S(   Nis   
R   s   test.txt(   R   R   R_   (   R   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   5  s    
(   Rr   RJ   t   childt   toucht   createDirectoryR   RX   (   R   R0   R   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_NLSTEmpty'  s    c            s;     j    }   j d d |   f d   } | j |  S(   sH   
        NLST on a non-existent file/directory returns nothing.
        s   NLST nonexistent.txtRh   c            s     j  d |   d  S(   NR-   (   R_   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   D  s    (   Rr   R   RX   (   R   R0   R   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_NLSTNonexistent<  s    c            sQ     j    }   j j d  j     j d d |   f d   } | j |  S(   sN   
        NLST on an existent file returns only the path to that file.
        s   test.txts   NLST test.txtRh   c            s*   |  d  j  d  }   j d g |  d  S(   Nis   
s   test.txt(   R   R_   (   R   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   T  s    (   Rr   RJ   R   R   R   RX   (   R   R0   R   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_NLSTOnPathToFileI  s
    N(   R(   R)   R*   R   R   R   R   R   R  R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s   
	
	)			t#   FTPServerPortDataConnectionTestCasec           B   s/   e  Z d    Z d d  Z d   Z d   Z RS(   c         C   s   g  |  _  t j |   S(   N(   t	   dataPortsR   R^   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^   \  s    	c            s   t  j     d t j f   f d     Y} t j d |   d d } |  j j |  d t j	 d | j
   j  } |  j j |    S(   Nt   DataFactoryc              s   e  Z e Z   f d    Z RS(   c            s/   t  j j |  |  } t j d   j |  | S(   Ni    (   R
   t   ServerFactoryR=   R   t	   callLaterR2   (   R   R@   RZ   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR=   f  s    (   R(   R)   R,   R
   R=   (    (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  d  s   i    R8   s	   127.0.0.1s   PORT (   R   R/   R
   R  R   RQ   R  R"   R   t   encodeHostPortRS   RT   RC   Rc   (   R   Rd   R  t   dataPortt   cmd(    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   `  s    c         C   s]   g  |  j  D] } t j | j  ^ q
 } t j t j |   } | j |  t j | d t S(   NR   (	   R  R   t   maybeDeferredRR   R   t   tearDownR"   R   R   (   R   RT   t   lR0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  p  s
    (c            s>     j    } d   } | j |    f d   } | j |  S(   Nc            sS   t  j d t j   d d } | j   j   | j   } | j   f d    | S(   Ni    R8   s	   127.0.0.1c            s     S(   N(    (   t   _(   R[   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   <lambda>  s    (   R   RQ   R
   R   RS   RT   RR   RX   (   Rd   RT   R0   (    (   R[   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   loggedIn}  s    	c            s#     j  d t j d |   d g  S(   Ns   PORT s	   127.0.0.1s   425 Can't open data connection.(   Rq   R   R	  (   R[   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
   gotPortNum  s    (   Rr   RX   (   R   R0   R  R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testPORTCannotConnectw  s
    	N(   R(   R)   R^   R*   R   R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  [  s   		t   DTPFactoryTestsc           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s&   
    Tests for L{ftp.DTPFactory}.
    c         C   sS   t  j   |  _ d t f d     Y} |   |  _ t j |  j d |  j  |  _ d S(   sf   
        Create a fake protocol interpreter and a L{ftp.DTPFactory} instance to
        test.
        t   ProtocolInterpreterc           B   s   e  Z d  Z RS(   N(   R(   R)   R*   t   dtpInstance(    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s   N(	   R	   t   ClockR   t   objectt   protocolInterpreterR   t
   DTPFactoryR*   R   (   R   R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^     s
    c         C   s   g  } |  j  |  j j t j  } | j | j  |  j j d  |  j j	 d  |  j
 |  |  j j	 d  |  j |  |  j
 |  j j  d S(   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.
        i   i   i   N(   Ro   R   R   R   t   PortConnectionErrorRX   R"   t
   setTimeoutR   t   advancet   assertFalset
   assertTruet   calls(   R   t   finishedR0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_setTimeout  s    c         C   sE   |  j  j d  } |  j | t j  |  j |  j  j d  d  d S(   s   
        A L{ftp.DTPFactory} instance's C{buildProtocol} method can be used once
        to create a L{ftp.DTP} instance.
        N(   R   R=   R*   t   assertIsInstanceR   t   DTPt   assertIdentical(   R   R
   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_buildProtocolOnce  s    c         C   s9   |  j  j d  |  j  j d  } |  j |  j j  d S(   s   
        If a timeout has been set up using L{ftp.DTPFactory.setTimeout}, it is
        cancelled by L{ftp.DTPFactory.buildProtocol}.
        i
   N(   R   R  R=   R*   R  R   R   (   R   R
   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_timeoutAfterConnection  s    c         C   s[   |  j  |  j j t j  } |  j j d  |  j j d  |  j |  j j	 d  d  | 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(   Ro   R   R   R   R  R  R   R  R%  R=   R*   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_connectionAfterTimeout  s
    c         C   s   g  } |  j  |  j j t j  } | j | j  |  j j d  |  j |  |  j j	 d d  |  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(   Ro   R   R   R   R  RX   R"   R  R  t   clientConnectionFailedR*   R  R   R  (   R   R!  R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!   test_timeoutAfterConnectionFailed  s    c         C   s[   |  j  |  j j t j  } |  j j d  |  j j d  |  j j d t
 j d   | 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
   R   N(   Ro   R   R   R   R  R  R   R  R)  R*   R   t   TimeoutError(   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!   test_connectionFailedAfterTimeout   s
    (
   R(   R)   Rs   R^   R"  R&  R'  R(  R*  R,  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s   						t
   PrintLinesc           B   s    e  Z d  Z d   Z d   Z RS(   s)   Helper class used by FTPFileListingTests.c         C   s   | |  _  d  S(   N(   t   _lines(   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s    c         C   s9   x% |  j  D] } |  j j | d  q
 W|  j j   d  S(   Ns   
(   R.  R:   R   R;   (   R   R#   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR!      s    (   R(   R)   Rs   R   R!   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR-    s   	t   MyFTPFileListProtocolc           B   s   e  Z d    Z d   Z RS(   c         C   s   g  |  _  t j j |   d  S(   N(   t   otherR   t   FTPFileListProtocolR   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   '  s    	c         C   s   |  j  j |  d  S(   N(   R0  R"   (   R   R#   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   unknownLine+  s    (   R(   R)   R   R2  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR/  &  s   	t   FTPFileListingTestsc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c            s;   t      t j t |     } | j   f d    | S(   Nc            s     j    j f S(   N(   t   filesR0  (   R  (   t   fileList(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  3  s    (   R/  R   t   loopbackAsyncR-  RX   (   R   R   R0   (    (   R5  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   getFilesForLines0  s    	c            s.   d }   f d   }   j  | g  j |  S(   Ns<   -rw-r--r--   1 root     other        531 Jan 29 03:26 READMEc            s  |  \ \ } }   j  | d t |     j | d d k d    j | d d k d    j | d d	 k d    j | d
 d k d    j | d d k d    j | d d k d    j | d d k d    j | d d k d    j  | d d  d  S(   Ns   unexpect unparsable lines: %st   filetypet   -s   misparsed fileitemt   permss	   rw-r--r--s   misparsed permst   ownert   roott   groupR0  R   i  t   dates   Jan 29 03:26t   filenamet   READMEt   nlinksi   s   misparsed nlinkst
   linktargets   misparsed linktarget(   t   failIft   reprR   (   R   R0  R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   check9  s    (   R7  RX   (   R   R#   RE  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testOneLine6  s    c            s@   d } d } d }   f d   }   j  | | | g  j |  S(   Ns7   drw-r--r--   2 root     other        531 Jan  9  2003 As<   lrw-r--r--   1 root     other          1 Jan 29 03:26 B -> As   woohoo! c            s  |  \ \ } } \ }   j  | d k d    j  | d d k d    j  | d d k d    j  | d	 d
 k d    j  | d d k d    j  | d d k d    j  | d d k d    j  | d d k d    j  | d d k d    j | d d    j  | d d k d    j  | d d k d    j  | d	 d
 k d    j  | d d k d    j  | d d k d    j  | d d k d    j  | d d  k d    j  | d d k d    j  | d d k d  d  S(!   Ns	   woohoo! s   incorrect other lineR8  R0   s   misparsed fileitemR:  s	   rw-r--r--s   misparsed permsR;  R<  s   misparsed ownerR=  R0  s   misparsed groupR   i  s   misparsed sizeR>  s   Jan  9  2003s   misparsed dateR?  t   As   misparsed filenameRA  i   s   misparsed nlinksRB  s   misparsed linktargetR  i   s   Jan 29 03:26t   B(   R   RC  (   R   t   file1t   file2R0  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRE  J  s(    (   R7  RX   (   R   t   line1t   line2t   line3RE  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testVariantLinesF  s
    c            s+     f d   }   j  d d g  j |  S(   Nc            sF   |  \ } }   j  | d    j | d d g k d t |   d  S(   Ns   unexpected file entriess   ABCs   not a files   incorrect unparsable lines: %s(   RC  R   RD  (   R   R4  t   others(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRE  c  s    	t   ABCs
   not a file(   R7  RX   (   R   RE  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testUnknownLineb  s    c            se   t  j    d   d t j f   f d     Y}   f d   } t j |     } | j |  S(   Ns<   -rw-r--r--   1 root     other        531 Jan 29 2003 README
t	   PrintLinec              s   e  Z   f d    Z RS(   c            s!   |  j  j    |  j  j   d  S(   N(   R:   R   R;   (   R   (   t   exampleLine(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR!   o  s    (   R(   R)   R!   (    (   RS  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRR  n  s   c            s_    j  d }   j | d d k d    j | d d k d    j | d d k d  d  S(	   Ni    R   i  s   misparsed fileitemR>  s   Jan 29 2003R?  R@  (   R4  R   (   Rd   R   (   R   R5  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRE  s  s    (   R   R1  R
   t   ProtocolR   R6  RX   (   R   RR  RE  R0   (    (   RS  R   R5  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testYeari  s    (   R(   R)   R7  RF  RN  RQ  RU  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR3  /  s
   				t   FTPClientTestsc           B   s   e  Z d    Z d   Z RS(   c            s   t  j   } d | _ t j d | d d } |  j | j  | j   j } d d d d d | d	 ?| d
 @f d g     f d   | _	 t
 j d d  } t  j t t
 j d d } | j d |  } d   } | j |  |  j | t
 j  S(   Ni    R8   s	   127.0.0.1s1   220 ready, dude (vsFTPd 1.0.0: beat me, break me)s    331 Please specify the password.s   230 Login successful. Have fun.s   200 Binary it is, then.s+   227 Entering Passive Mode (127,0,0,1,%d,%d)i   i   s   550 Failed to open file.c            s
   t     S(   N(   R-  (   R@   (   t	   responses(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s    t   passivei   c         S   s   t  j   } |  j d |  S(   Ns   /file/that/doesnt/exist(   R
   RT  t   retrieveFile(   RC   RZ   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRD     s    (   R
   R   t   noisyR   RQ   R?   RR   RS   RT   R=   R   R   RU   RW   RX   Ro   Rp   (   R   R    RT   R[   RC   R   R0   RD   (    (   RW  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testFailedRETR  s&    			c            s   t  j   } t j   } | j |  | | _ | j d t    } g      f d   } | j |  d d l	 m
 } | j t j |   |  j      | S(   sl   
        Test the ftp command errbacks when a connection lost happens during
        the operation.
        s	   some pathc            s     j  |   d  S(   N(   R"   R*   (   R   (   t   m(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   _eb  s    i(   t   CONNECTION_LOST(   R   R   R   t    StringTransportWithDisconnectiont   makeConnectionR
   R   R   R   t   twisted.internet.mainR^  R4   R   t   FailureR   (   R   t	   ftpClientt   trR0   R]  R^  (    (   R\  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_errbacksUponDisconnect  s    	(   R(   R)   R[  Re  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRV  }  s   	t   FTPClientTestCasec           B   s  e  Z 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   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e g e _ d   Z e g e _ d   Z e g e _ 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'   Z+ d(   Z, RS()   s,   
    Test advanced FTP client commands.
    c         C   sD   t  j   |  _ t j   |  _ |  j j |  j  |  j |  j _ d S(   sG   
        Create a FTP client and connect it to fake transport.
        N(   R   R   RC   R   R_  R:   R`  R
   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^     s    c         C   s   |  j  j t j    d S(   s   
        Deliver disconnection notification to the client so that it can
        perform any cleanup which may be required.
        N(   RC   R4   R   t   ConnectionLost(   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s    c         C   s   |  j  |  j j   d  |  j j d  |  j  |  j j   d  |  j j   |  j j d  |  j  |  j j   d  |  j j   |  j j d  d S(   s&   
        Test the login part.
        R-   s8   331 Guest login ok, type your email address as password.s   USER anonymous
s2   230 Anonymous login ok, access restrictions apply.s   TYPE I
s   200 Type set to I.N(   R_   R:   R   RC   R$   t   clear(   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
   _testLogin  s    		c            sk     f d   }   j      j j   j |  }   j   j j   d    j j     j j d  | 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)
        c            s     j  |  d d  d  S(   Ni    s&   250 Requested File Action Completed OK(   R_   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbCdup  s    s   CDUP
s&   250 Requested File Action Completed OK(	   Ri  RC   t   cdupRX   R_   R:   R   Rh  R$   (   R   Rj  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   test_CDUP  s    

c         C   sf   |  j    |  j j   } |  j | t j  |  j |  j j   d  |  j j	   |  j j
 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}.
        s   CDUP
s!   550 ..: No such file or directory(   Ri  RC   Rk  Ro   R   Rp   R_   R:   R   Rh  R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedCDUP  s    
c            s^     f d   }   j      j j   j |  }   j   j j   d    j j d  | 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)
        c            s!     j  t j |  d  d  d  S(   Ni    s   /bar/baz(   R_   R   t   parsePWDResponse(   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbPwd  s    s   PWD
s   257 "/bar/baz"(   Ri  RC   t   pwdRX   R_   R:   R   R$   (   R   Ro  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_PWD  s    

c         C   sY   |  j    |  j j   } |  j | t j  |  j |  j j   d  |  j j	 d  | S(   s   
        Test a failure in PWD command.

        When the PWD command fails, the returned Deferred should errback
        with L{ftp.CommandFailed}.
        s   PWD
s'   550 /bar/baz: No such file or directory(
   Ri  RC   Rp  Ro   R   Rp   R_   R:   R   R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedPWD  s    
c            sa     f d   }   j      j j d  j |  }   j   j j   d    j j d  | 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)
        c            s     j  |  d d  d  S(   Ni    s&   250 Requested File Action Completed OK(   R_   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbCwd+  s    s   bar/foos   CWD bar/foo
s&   250 Requested File Action Completed OK(   Ri  RC   t   cwdRX   R_   R:   R   R$   (   R   Rs  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_CWD!  s    

c         C   s\   |  j    |  j j d  } |  j | t j  |  j |  j j   d  |  j j	 d  | S(   s   
        Test a failure in CWD command.

        When the PWD command fails, the returned Deferred should errback
        with L{ftp.CommandFailed}.
        s   bar/foos   CWD bar/foo
s&   550 bar/foo: No such file or directory(
   Ri  RC   Rt  Ro   R   Rp   R_   R:   R   R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedCWD5  s    
c            s     f d   }   f d   } |   j  _   j   t   }   j  j d |  } | j | |    j   j j   d    j j	     j  j
 d t j d d  f    j   j j   d    j j	     j  j
 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)
        c            s     j  | j d d  d  S(   NR   i  (   R_   R.   (   R   t   proto(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbRetrO  s    c            s     j  |  d    j  | d  | j |  | f  } | j t j      j j d  | j d d  | j t	 j
 t j d    d  S(   Ns	   127.0.0.1i90  s4   150 File status okay; about to open data connection.R   i  R-   (   R_   R=   R`  R   t   StringTransportRC   R$   R1   R4   R   Rb  R   t   ConnectionDone(   R   RT   R   Rw  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   cbConnectR  s    	t   spams   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   RETR spam
s   226 Transfer Complete.(   RC   t   connectFactoryRi  R,   RY  RX   R_   R:   R   Rh  R$   R   R	  (   R   Rx  R{  Rw  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_passiveRETRD  s    

	c            s   t    j _ d   }   f d   } |   j _   j   t   }   j j d |  } | j | |    j   j	 j
   d t j d d  f    j	 j     j j d    j   j	 j
   d    j	 j     j j d	  | 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.
        c         S   sl   d t  j d d  f |  _ |  j j t j    |  j j d d  |  j j t	 j
 t j d    d  S(   Ns   PORT %ss	   127.0.0.1i&  R   i  R-   (   R   R	  t   textR
   R`  R   Ry  R1   R4   R   Rb  R   Rz  (   t   portCmd(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   generatePortu  s
    	c            s     j  | j d d  d  S(   NR   i  (   R_   R.   (   R   Rw  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRx  |  s    R|  s	   PORT %s
s	   127.0.0.1i&  s   200 PORT OKs   RETR spam
s   226 Transfer Complete.(   R   RC   RX  t   generatePortCommandRi  R,   RY  RX   R_   R:   R   R   R	  Rh  R$   (   R   R  Rx  Rw  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   test_RETRk  s     	
	c            s     f d   } |   j  _   j   t   }   j  j d |  }   j | t j    j   j	 j
   d    j	 j     j  j d t j d d  f    j   j	 j
   d    j	 j     j  j 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.
        c            s{     j  |  d    j  | d  | j |  | f  } | j t j      j j d  | j t j	 t
 j d    d  S(   Ns	   127.0.0.1i90  s4   150 File status okay; about to open data connection.R-   (   R_   R=   R`  R   Ry  RC   R$   R4   R   Rb  R   Rz  (   R   RT   R   Rw  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR{    s    	R|  s   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   RETR spam
s#   550 spam: No such file or directory(   RC   R}  Ri  R,   RY  Ro   R   Rp   R_   R:   R   Rh  R$   R	  (   R   R{  Rw  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedRETR  s    	
	c            s   t  |  j _ g      f d   } | |  j _ |  j   t   } |  j j d |  } |  j |  j j	   d t
 j d d  f  |  j j   |  j j d  |  j |  j j	   d  |  j      d j   |  j j   |  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)
        c            si   d t  j d d  f |  _ t j   } |  j j |  |  j | _ |  j j d d    j |  d  S(   Ns   PORT %ss	   127.0.0.1i&  R   i  (	   R   R	  R  R   R_  R
   R`  R1   R"   (   R  Rd  (   R  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s    R|  s	   PORT %s
s	   127.0.0.1i&  s   200 PORT OKs   RETR spam
i    (   R   RC   RX  R  Ri  R,   RY  R_   R:   R   R   R	  Rh  R$   t   assert_R;   Ro   Rg  (   R   R  Rw  R0   (    (   R  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_lostRETR  s"    
	c            s  t  j      f d   }    f d   }    f d   } |   j _   j     j j d  \ } } | j |  | j |    j   j j	   d    j j
     j j d t j d d  f    j   j j	   d	    j j
     j j d
  t j | | g  S(   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).
        c            sQ     j  j d  |  j j d d  |  j   |  j t j t j	 d    d  S(   Ns4   150 File status okay; about to open data connection.R   i  R-   (
   RC   R$   R:   R   t   finishR4   R   Rb  R   Rz  (   t   sender(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbStore  s
    	
c            s     j   j   d d  d  S(   NR   i  (   R_   R   (   t   ign(   R   Rd  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbFinish  s    c            sF     j  |  d    j  | d  | j |  | f  } | j   d  S(   Ns	   127.0.0.1i90  (   R_   R=   R`  (   R   RT   R   Rw  (   R   Rd  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR{    s    R|  s   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   STOR spam
s   226 Transfer Complete.(   R   Ry  RC   R}  Ri  R   RX   R_   R:   R   Rh  R$   R   R	  R   RY   (   R   R  R  R{  RA   R]   (    (   R   Rd  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_passiveSTOR  s"    
c            s  t  j      f d   }    f d   } |   j _   j     j j d  \ } } | j |    j | t j	    j
   j j   d    j j     j j d t j d d  f    j
   j j   d    j j     j j d	  t j | | g  S(
   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}.
        c            sQ     j  j d  |  j j d d  |  j   |  j t j t j	 d    d  S(   Ns4   150 File status okay; about to open data connection.R   i  R-   (
   RC   R$   R:   R   R  R4   R   Rb  R   Rz  (   R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s
    	
c            sF     j  |  d    j  | d  | j |  | f  } | j   d  S(   Ns	   127.0.0.1i90  (   R_   R=   R`  (   R   RT   R   Rw  (   R   Rd  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR{    s    R|  s   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   STOR spam
s.   426 Transfer aborted.  Data connection closed.(   R   Ry  RC   R}  Ri  R   RX   Ro   R   Rp   R_   R:   R   Rh  R$   R	  R   RY   (   R   R  R{  RA   R]   (    (   R   Rd  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedSTOR  s"    
	c            s   t  j    t   j _  f d   }   f d   }    f d   } |   j _   j     j j d  \ } } | j |  | j |  t	 j
 | | g  S(   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.
        c            s-   d t  j d d  |  _ |  j j    d  S(   Ns   PORT %ss	   127.0.0.1i&  (   R   R	  R  R
   R`  (   R  (   Rd  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  /  s    c            s     j    j j   d t j d d  f    j j     j j d    j    j j   d    j j     j j d  |  j j d d  |  j	   |  j
 t j t j d	      j j d
  d  S(   Ns	   PORT %s
s	   127.0.0.1i&  s   200 PORT OKs   STOR spam
s4   150 File status okay; about to open data connection.R   i  R-   s   226 Transfer Complete.(   R_   R:   R   R   R	  Rh  RC   R$   R   R  R4   R   Rb  R   Rz  (   R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  3  s    	
c            s     j   j   d d  d  S(   NR   i  (   R_   R   (   R  (   R   Rd  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  A  s    R|  (   R   Ry  R   RC   RX  R  Ri  R   RX   R   RY   (   R   R  R  R  RA   R]   (    (   R   Rd  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   test_STOR%  s    
c            s     f d   }   f d   } |   j  _   j   t j   }   j  j d |  j | |  }   j   j j	   d    j j
     j  j d t j d d  f    j   j j	   d    j  j d	  | 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)
        c            sW   g  | j  D] } | d ^ q
 } d d d g } | j   | j     j | |  d  S(   NR?  R   R   t   baz(   R4  R   R_   (   R   R5  R    t   flst   expected(   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbList_  s
     

c            s     j  |  d    j  | d  | j |  | f  } | j t j      j j d  d d d g } x | D] } | j |  qn W| j t	 j
 t j d    d  S(   Ns	   127.0.0.1i90  s4   150 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`  R   Ry  RC   R$   R1   R4   R   Rb  R   Rz  (   R   RT   R   Rw  t   sendingR   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR{  f  s    		s   foo/bars   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   LIST foo/bar
s   226 Transfer Complete.(   RC   R}  Ri  R   R1  R   RX   R_   R:   R   Rh  R$   R	  (   R   R  R{  R5  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_passiveLISTL  s    
!c            s   t    j _   f d   }   f d   } |   j _   j   t j   }   j j d |  j | |  }   j	   j
 j   d t j d d  f    j
 j     j j d    j	   j
 j   d    j
 j     j j d	  | 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.
        c            s   d t  j d d  f |  _ |  j j t j      j j d  d d d g } x | D] } |  j j	 |  qX W|  j j
 t j t j d    d  S(	   Ns   PORT %ss	   127.0.0.1i&  s4   150 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  R
   R`  R   Ry  RC   R$   R1   R4   R   Rb  R   Rz  (   R  R  R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s    			c            sW   g  | j  D] } | d ^ q
 } d d d g } | j   | j     j | |  d  S(   NR?  R   R   R  (   R4  R   R_   (   R   R5  R    R  R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s
     

s   foo/bars	   PORT %s
s	   127.0.0.1i&  s   200 PORT OKs   LIST foo/bar
s   226 Transfer Complete.(   R   RC   RX  R  Ri  R   R1  R   RX   R_   R:   R   R	  Rh  R$   (   R   R  R  R5  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   test_LIST  s    
!c            s     f d   } |   j  _   j   t j   }   j  j d |  }   j | t j    j   j	 j
   d    j	 j     j  j d t j d d  f    j   j	 j
   d    j  j 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.
        c            s{     j  |  d    j  | d  | j |  | f  } | j t j      j j d  | j t j	 t
 j d    d  S(   Ns	   127.0.0.1i90  s4   150 File status okay; about to open data connection.R-   (   R_   R=   R`  R   Ry  RC   R$   R4   R   Rb  R   Rz  (   R   RT   R   Rw  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR{    s    	s   foo/bars   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   LIST foo/bar
s&   550 foo/bar: No such file or directory(   RC   R}  Ri  R   R1  R   Ro   Rp   R_   R:   R   Rh  R$   R	  (   R   R{  R5  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedLIST  s    	
c            s   t    j _   f d   }   f d   } |   j _   j   t   }   j j d |  j | |  }   j   j	 j
   d t j d d  f    j	 j     j j d    j   j	 j
   d    j j d	  | 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.
        c            s   d t  j d d  f |  _ |  j j t j      j j d  |  j j	 d  |  j j	 d  |  j j	 d  |  j j
 t j t j d    d  S(	   Ns   PORT %ss	   127.0.0.1i&  s4   150 File status okay; about to open data connection.s   foo
s   bar
s   baz
R-   (   R   R	  R  R
   R`  R   Ry  RC   R$   R1   R4   R   Rb  R   Rz  (   R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s    		c            sF   | j  j   } d d d g } | j   | j     j | |  d  S(   NR   R   R  (   R.   t
   splitlinesR   R_   (   R   Rw  R  R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s
    

s   foo/bars	   PORT %s
s	   127.0.0.1i&  s   200 PORT OKs   NLST foo/bar
s   226 Transfer Complete.(   R   RC   RX  R  Ri  R,   t   nlstRX   R_   R:   R   R   R	  Rh  R$   (   R   R  R  t   lstprotoR0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   test_NLST  s    
	!c            s     f d   }   f d   } |   j  _   j   t   }   j  j d |  j | |  }   j   j j   d    j j	     j  j
 d t j d d  f    j   j j   d    j  j
 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.
        c            sF   | j  j   } d d d g } | j   | j     j | |  d  S(   NR   R   R  (   R.   R  R   R_   (   R   Rw  R  R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s
    

c            s     j  |  d    j  | d  | j |  | f  } | j t j      j j d  | j d  | j d  | j d  | j t	 j
 t j d    d  S(   Ns	   127.0.0.1i90  s4   150 File status okay; about to open data connection.s   foo
s   bar
s   baz
R-   (   R_   R=   R`  R   Ry  RC   R$   R1   R4   R   Rb  R   Rz  (   R   RT   R   Rw  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR{    s    	s   foo/bars   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   NLST foo/bar
s   226 Transfer Complete.(   RC   R}  Ri  R,   R  RX   R_   R:   R   Rh  R$   R   R	  (   R   R  R{  R  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_passiveNLST  s    
	!c            s   t  j       f d   } |   j _   j   t   }   j j d |  }   j | t j	    j
   j j   d    j j     j j d t j d d  f    j
   j j   d    j j d  | 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.
        c            su     j  |  d    j  | d  | j |  | f  } | j     j j d  | j t j t j	 d    d  S(   Ns	   127.0.0.1i90  s4   150 File status okay; about to open data connection.R-   (
   R_   R=   R`  RC   R$   R4   R   Rb  R   Rz  (   R   RT   R   Rw  (   R   Rd  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR{  '  s    	s   foo/bars   PASV
s   227 Entering Passive Mode (%s).s	   127.0.0.1i90  s   NLST foo/bar
s&   550 foo/bar: No such file or directory(   R   Ry  RC   R}  Ri  R,   R  Ro   R   Rp   R_   R:   R   Rh  R$   R	  (   R   R{  R  R0   (    (   R   Rd  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedNLST  s    	
	c            s?     j      j t d t   f d    }   j j d  | 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.c              s     j  j d  S(   Nt   .(   RC   t   changeDirectory(    (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  I  s    s   250 success(   Ri  t   assertWarnst   DeprecationWarningt   __file__RC   R$   (   R   R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_changeDirectoryDeprecated>  s    
c            sa     f d   }   j      j j d  j |  }   j   j j   d    j j d  | S(   s   
        Test the changeDirectory method.

        L{ftp.FTPClient.changeDirectory} should return a Deferred which fires
        with True if succeeded.
        c            s     j  |  t  d  S(   N(   R_   R   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbCdX  s    s   bar/foos   CWD bar/foo
s&   250 Requested File Action Completed OK(   Ri  RC   R  RX   R_   R:   R   R$   (   R   R  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_changeDirectoryQ  s    
c         C   s\   |  j    |  j j d  } |  j | t j  |  j |  j j   d  |  j j	 d  | S(   sx   
        Test a failure in the changeDirectory method.

        The behaviour here is the same as a failed CWD.
        s   bar/foos   CWD bar/foo
s&   550 bar/foo: No such file or directory(
   Ri  RC   R  Ro   R   Rp   R_   R:   R   R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedChangeDirectoryc  s    
c         C   s\   |  j    |  j j d  } |  j | t j  |  j |  j j   d  |  j j	 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.
        s   bar/foos   CWD bar/foo
s   252 I do what I want !(
   Ri  RC   R  Ro   R   Rp   R_   R:   R   R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!   test_strangeFailedChangeDirectoryr  s    
c         C   s   |  j    |  j j d d  } |  j |  j j   d  |  j j   d } |  j j |  |  j |  j j   d  d } |  j j |  | j |  j | g | g f  | 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
s8   350 Requested file action pending further information.
s   RNTO /ham
s&   250 Requested File Action Completed OK(	   Ri  RC   t   renameR   R:   R   Rh  R$   RX   (   R   R0   t   fromResponset
   toResponse(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_renameFromTo  s    
c         C   sf   |  j    d } d } |  j j | |  |  j j d  |  j j d  |  j |  j j   d  d S(   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
uxs   350 s   250 s!   RNFR /foo/ba r/baz
RNTO /qu ux
N(   Ri  RC   R  R$   R   R:   R   (   R   t   fromFilet   toFile(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_renameFromToEscapesPaths  s    
c         C   s   |  j    |  j j d d  } |  j |  j j   d  |  j j   |  j j d  |  j |  j j   d  |  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-   (   Ri  RC   R  R   R:   R   Rh  R$   Ro   R   Rp   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt$   test_renameFromToFailingOnFirstError  s    
c         C   s   |  j    |  j j d d  } |  j |  j j   d  |  j j   |  j j d  |  j |  j j   d  |  j j d  |  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
s8   350 Requested file action pending further information.
s   RNTO /ham
s!   550 Requested file unavailable.
(   Ri  RC   R  R   R:   R   Rh  R$   Ro   R   Rp   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt"   test_renameFromToFailingOnRenameTo  s    
c         C   s[   |  j    |  j j d  } |  j |  j j   d  |  j j d  | j |  j d g  S(   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   /spams   MKD /spam
s   257 "/spam" created.(	   Ri  RC   t   makeDirectoryR_   R:   R   R$   RX   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_makeDirectory  s
    
c         C   sI   |  j    |  j j d  } |  j |  j j   d  |  j j d  | 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 /sp am
s   257 win(   Ri  RC   R  R   R:   R   R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_makeDirectoryPathEscape  s
    
c         C   sX   |  j    |  j j d  } |  j |  j j   d  |  j j d  |  j | t j	  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   /spams   MKD /spam
s   550 PERMISSION DENIED(
   Ri  RC   R  R_   R:   R   R$   Ro   R   Rp   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedMakeDirectory  s
    
c            s^     f d   }   j      j j   j |  }   j   j j   d    j j d  | 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.
        c            s     j  |  d  d  S(   Ns   /bar/baz(   R_   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cbGet  s    s   PWD
s   257 "/bar/baz"(   Ri  RC   t   getDirectoryRX   R_   R:   R   R$   (   R   R  R0   (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_getDirectory  s    
c         C   sY   |  j    |  j j   } |  j | t j  |  j |  j j   d  |  j j	 d  | S(   sj   
        Test a failure in getDirectory method.

        The behaviour should be the same as PWD.
        s   PWD
s'   550 /bar/baz: No such file or directory(
   Ri  RC   R  Ro   R   Rp   R_   R:   R   R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedGetDirectory  s    
c         C   sY   |  j    |  j j   } |  j | t j  |  j |  j j   d  |  j j	 d  | S(   s   
        Test a different failure in getDirectory method.

        The response should be quoted to be parsed, so it returns an error
        otherwise.
        s   PWD
s   257 /bar/baz(
   Ri  RC   R  Ro   R   Rp   R_   R:   R   R$   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_anotherFailedGetDirectory  s    
c         C   sa   |  j    |  j j d  } |  j |  j j   d  d } |  j j |  | j |  j | g  S(   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/tests   DELE /tmp/test
s*   250 Requested file action okay, completed.(	   Ri  RC   t
   removeFileR_   R:   R   R$   RX   R   (   R   R0   t   response(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_removeFile(  s    
c            s}     j      j j d  }   j   j j   d  d    j j     j | t j	  } | j
    f d    | 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/tests   DELE /tmp/test
s,   501 Syntax error in parameters or arguments.c            s     j  |  j  g f  S(   N(   R   Rk   (   t   exc(   R   R  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  C  s    (   Ri  RC   R  R_   R:   R   R$   Ro   R   Rp   RX   (   R   R0   (    (   R   R  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_failedRemoveFile6  s    
c            sd     j      j j d  } d    j j     j | t j  } | j    f d    | 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/tests   765 blah blah blahc            s     j  |  j  g f  S(   N(   R   Rk   (   R  (   R   R  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  R  s    (   Ri  RC   R  R$   Ro   R   t   BadResponseRX   (   R   R0   (    (   R   R  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt!   test_unparsableRemoveFileResponseG  s    
c         C   sK   |  j    |  j j d  } d d g } t |  j j |  | j |  j  S(   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/tests   250-perhaps a progress reports   250 okay(   Ri  RC   R  R   R$   RX   R  (   R   R0   R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt    test_multilineRemoveFileResponseV  s    
	(-   R(   R)   Rs   R^   R  Ri  Rl  Rm  Rq  Rr  Ru  Rv  R~  R  R  R  R  R  R  R  R  R  R  R  R  R  R  t   _changeDirectorySuppressiont   suppressR  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRf    sX   	
									'	#	 	"	/	&	'	7	-		'	(	 																	t   FTPClientBasicTestsc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s3   t  j   } | j d  |  j d g | j  d  S(   Ns   220 Imaginary FTP.(   R   Rt   R$   Rj   t   greeting(   R   Rc  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testGreetingg  s    c         C   s3   t  j   } | j d  |  j d g | j  d  S(   Ns   220 (   R   Rt   R$   Rj   R  (   R   Rc  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testResponseWithNoMessagem  s    c         C   sE  t  j   } t j   | _ | j d  | j d  } g  } | j | j  | j	 |  j
  | j d  |  j g  |  | j d  |  j g  |  | j d  |  j g  |  | j d  |  j g  |  | j d  |  j g  |  | j d  |  j g  |  | j d	  |  j d d d d d d d	 g | d
  d  S(   Ns   220 Imaginary FTP.t   BLAHs   210-First line.s   123-Second line.s   Just some text.t   HiR-   t   321s	   210 Done.i    (   R   Rt   R   Ry  R:   R$   Rc   RX   R"   R   R   Rj   (   R   Rc  R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testMultilineResponset  s8    c         C   s   t  j   } t j   | _ | j d  | j d d  |  j d | j j	    | j j
   | j d  |  j d | j j	    d S(   sO   
        Passing None as the password avoids sending the PASS command.
        s   220 Welcome to Imaginary FTP.t   bobs
   USER bob
s   200 Hello bob.R-   N(   R   Rt   R   Ry  R:   R$   t
   queueLoginR*   R_   R   Rh  (   R   Rc  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_noPasswordGiven  s    c         C   s   t  j   } t j   | _ | j d  | j d d  |  j d | j j    | j j	   | j d  |  j d | j j    d S(   sQ   
        Receiving a 230 response to USER prevents PASS from being sent.
        s   220 Welcome to Imaginary FTP.R  t   secrets
   USER bob
s#   230 Hello bob.  No password needed.R-   N(
   R   Rt   R   Ry  R:   R$   R  R_   R   Rh  (   R   Rc  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_noPasswordNeeded  s    (   R(   R)   R  R  R  R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  e  s
   			0	t   PathHandlingc           B   s   e  Z d    Z RS(   c         C   s@  x d d g f d d g f d g  f d d d d g f d d d d g f d d g f d	 d g f g D]( \ } } |  j  t j g  |  |  qd Wx d d d g f d
 d d g f d d g f d d g f d d d d g f d d d d g f d d d g f d d d g f g D]+ \ } } |  j  t j d g |  |  qWx` d g  f d d g f d d g f d d d g f g D]( \ } } |  j  t j g  |  |  quWxZ d g  f d d g f d d d d g f g D]+ \ } } |  j  t j d g |  |  qWx d g  f d g  f d d g f d g  f d d g f d d g f d d d g f d d d g f d  d g f d! d g f d" g  f d# g  f g D]+ \ } } |  j  t j d g |  |  qWxE d d d$ d% d& d' d( d) d* g	 D]" } |  j t j t j g  |  qWx6 d+ d, d- g D]% } |  j t j t j d g |  qWd  S(.   NR   s   /at   /s   a/b/cR   t   cs   /a/b/cs   /a/s   a/s   b/s   /bs   /b/s   b/cs   b/c/s   /b/cs   /b/c/s   //s   //as   a//s   a//bs   //bs   b//cs   ..s   ../s   a/..R   s   /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/../s   a/../..s   a/../../s   /..s   /../s   /a/../..s	   /a/../../s   /a/b/../../..s   ../..s   ../../s
   ../a/../..(   R_   R   t
   toSegmentsR   t   InvalidPath(   R   t   inpt   outp(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   testNormalizer  sZ    	 # "#			# (   R(   R)   R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s   t   BaseFTPRealmTestsc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   
    Tests for L{ftp.BaseFTPRealm}, a base class to help define L{IFTPShell}
    realms with different user home directory policies.
    c         C   s   |  j  t t t j   d S(   s;   
        L{ftp.BaseFTPRealm} implements L{IRealm}.
        N(   R  R   R   R   t   BaseFTPRealm(   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_interface  s    c            s   t  j |  j     g    d t j f    f d     Y} | |  j    } | j d d t j  \ } } } |  j | t j	  |  j
 | j   d S(   s   
        L{ftp.BaseFTPRealm} calls its C{getHomeDirectory} method with the
        avatarId being requested to determine the home directory for that
        avatar.
        t	   TestRealmc              s   e  Z    f d    Z RS(   c            s     j  |   S(   N(   R"   (   R   t   avatarId(   t   avatarsR   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   getHomeDirectory  s    (   R(   R)   R  (    (   R  R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s   s   alice@example.comN(   R   RI   RE   R   R  t   requestAvatarR*   t	   IFTPShellR#  t   FTPShellR_   t   filesystemRoot(   R   R  t   realmt   ifacet   avatart   logout(    (   R  R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_getHomeDirectory  s    "c         C   sr   |  j    } t j |  } | j t j d t j  \ } } } |  j | t j	  |  j
 | j t j |   d S(   sy   
        L{ftp.BaseFTPRealm} returns an L{ftp.FTPAnonymousShell} instance for
        anonymous avatar requests.
        N(   RE   R   R  R  R   t	   ANONYMOUSR*   R  R#  R   R_   R  R   RI   (   R   R6   R  R  R  R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_anonymous)  s    c         C   s2   t  j |  j    } |  j t | j t    d S(   s   
        L{ftp.BaseFTPRealm.getHomeDirectory} should be overridden by a subclass
        and raises L{NotImplementedError} if it is not.
        N(   R   R  RE   R   t   NotImplementedErrorR  R  (   R   R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_notImplemented6  s    (   R(   R)   Rs   R  R  R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  	  s
   			t   FTPRealmTestCasec           B   s    e  Z d  Z d   Z d   Z RS(   s$   
    Tests for L{ftp.FTPRealm}.
    c         C   sS   d } t  j |  j   |  } | j d  } |  j t j |  j d  |  d S(   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/homes   alice@example.comN(   R   RL   RE   R  R_   R   RI   R   (   R   t   baseR  t   home(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  D  s
    c         C   sA   t  j |  j    } | j d  } |  j t j d  |  d S(   s   
        If no extra directory is passed to L{ftp.FTPRealm}, it uses C{"/home"}
        as the base directory containing all user home directories.
        s   alice@example.coms   /home/alice@example.comN(   R   RL   RE   R  R_   R   RI   (   R   R  R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_defaultHomeDirectoryQ  s    (   R(   R)   Rs   R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  @  s   	t   SystemFTPRealmTestsc           B   s&   e  Z d  Z e Z d   Z d   Z RS(   s*   
    Tests for L{ftp.SystemFTPRealm}.
    c         C   sk   t  j   } d d l } | j |  j } t j |  j    } | j |  } |  j	 | t
 j |   d S(   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(   t   getpasst   getuserRp  t   getpwnamt   pw_dirR   t   SystemFTPRealmRE   R  R_   R   RI   (   R   t   userRp  R  R  R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  b  s    c         C   sD   t  d  j d  } t j |  j    } |  j t | j |  d S(   s   
        L{ftp.SystemFTPRealm.getHomeDirectory} raises L{UnauthorizedLogin} when
        passed a username which has no corresponding home directory in the
        system's accounts database.
        i   t   hexN(   R   t   encodeR   R  RE   R   R   R  (   R   R  R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_noSuchUserv  s    (   R(   R)   Rs   t   nonPOSIXSkipt   skipR  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  \  s   	t   ErrnoToFailureTestCasec           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s9   
    Tests for L{ftp.errnoToFailure} errno checking.
    c         C   s(   t  j t j d  } |  j | t  j  S(   sS   
        C{errno.ENOENT} should be translated to L{ftp.FileNotFoundError}.
        R   (   R   t   errnoToFailuret   errnot   ENOENTRo   t   FileNotFoundError(   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_notFound  s    c         C   s(   t  j t j d  } |  j | t  j  S(   sV   
        C{errno.EPERM} should be translated to L{ftp.PermissionDeniedError}.
        R   (   R   R  R  t   EPERMRo   t   PermissionDeniedError(   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_permissionDenied  s    c         C   s(   t  j t j d  } |  j | t  j  S(   sW   
        C{errno.EACCES} should be translated to L{ftp.PermissionDeniedError}.
        R   (   R   R  R  t   EACCESRo   R  (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_accessDenied  s    c         C   s(   t  j t j d  } |  j | t  j  S(   sW   
        C{errno.ENOTDIR} should be translated to L{ftp.IsNotADirectoryError}.
        R   (   R   R  R  t   ENOTDIRRo   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_notDirectory  s    c         C   s(   t  j t j d  } |  j | t  j  S(   sQ   
        C{errno.EEXIST} should be translated to L{ftp.FileExistsError}.
        R   (   R   R  R  t   EEXISTRo   t   FileExistsError(   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_fileExists  s    c         C   s(   t  j t j d  } |  j | t  j  S(   sS   
        C{errno.EISDIR} should be translated to L{ftp.IsADirectoryError}.
        R   (   R   R  R  t   EISDIRRo   t   IsADirectoryError(   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_isDirectory  s    c         C   s=   y t  d   Wn& t j d d  } |  j | t   SXd S(   s   
        If an unknown errno is passed to L{ftp.errnoToFailure}, it should let
        the originating exception pass through.
        R   iR   N(   R   R   R  Ro   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_passThrough  s
    (
   R(   R)   Rs   R  R  R  R  R  R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s   						t   AnonymousFTPShellTestCasec           B   s   e  Z d  Z d   Z RS(   s*   
    Test anynomous shell properties.
    c         C   s5   t  j d  } | j d  } |  j | t  j  | S(   st   
        Check that L{ftp.FTPAnonymousShell} returns an error when trying to
        open it in write mode.
        R-   R   (   s   foo(   R   R   R   Ro   R  (   R   t   shellR0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_anonymousWrite  s    (   R(   R)   Rs   R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    s   t   IFTPShellTestsMixinc           B   sC  e  Z d  Z d   Z d   Z d   Z d 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   Z 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   Z d   Z  d    Z! d!   Z" d"   Z# d#   Z$ RS($   s7   
    Generic tests for the C{IFTPShell} interface.
    c         C   s   t     d S(   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  (   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   directoryExists  s    c         C   s   t     d S(   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  (   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR     s    c         C   s   t     d S(   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  (   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
   fileExists  s    R-   c         C   s   t     d S(   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  (   R   R   t   fileContent(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
   createFile	  s    c         C   s=   |  j  |  j d   |  j d  |  j |  j d   d S(   s   
        C{directoryExists} should report correctly about directory existence,
        and C{createDirectory} should create a directory detectable by
        C{directoryExists}.
        R   N(   R  R  R   R  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_createDirectory	  s    c         C   s=   |  j  |  j d   |  j d  |  j |  j d   d S(   s   
        C{fileExists} should report correctly about file existence, and
        C{createFile} should create a file detectable by C{fileExists}.
        s   file.txtN(   R  R  R  R  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_createFile	  s    c            s.     j  j d  }   f d   } | j |  S(   sI   
        Create a directory and check it ends in the filesystem.
        R   c            s     j    j d   d  S(   NR   (   R  R  (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cb)	  s    (   s   foo(   R  R  RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  $	  s    c         C   s2   |  j  d  |  j j d  } |  j | t j  S(   sm   
        Creating a directory that already exists should fail with a
        C{ftp.FileExistsError}.
        R   (   s   foo(   R   R  R  Ro   R   R
  (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_makeDirectoryError.	  s    c            s;     j  d    j j d  }   f d   } | j |  S(   sW   
        Try to remove a directory and check it's removed from the filesystem.
        R   c            s     j    j d   d  S(   NR   (   R  R  (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  >	  s    (   s   bar(   R   R  t   removeDirectoryRX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_removeDirectory8	  s    c         C   s2   |  j  d  |  j j d  } |  j | t j  S(   sn   
        removeDirectory should not work in file and fail with a
        C{ftp.IsNotADirectoryError}.
        s   file.txt(   s   file.txt(   R  R  R  Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_removeDirectoryOnFileC	  s    c         C   s%   |  j  j d  } |  j | t j  S(   sl   
        Removing directory that doesn't exist should fail with a
        C{ftp.FileNotFoundError}.
        R   (   s   bar(   R  R  Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_removeNotExistingDirectoryM	  s    c            s?     j  d    j j d  }   f d   } | j |  | S(   sR   
        Try to remove a file and check it's removed from the filesystem.
        s   file.txtc            s     j    j d   d  S(   Ns   file.txt(   R  R  (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  \	  s    (   s   file.txt(   R  R  R  RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  V	  s
    c         C   s2   |  j  d  |  j j d  } |  j | t j  S(   s:   
        removeFile should not work on directory.
        t   ned(   R   (   R   R  R  Ro   R   R  (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_removeFileOnDirectoryb	  s    c         C   s%   |  j  j d  } |  j | t j  S(   sl   
        Try to remove a non existent file, and check it raises a
        L{ftp.FileNotFoundError}.
        R   (   s   foo(   R  R  Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_removeNotExistingFilek	  s    c            sH     j  d    j d    j j d  }   f d   } | j |  S(   s6   
        Check the output of the list method.
        R   s   file.txtR  c            s0   |  j      j |  d g  f d g  f g  d  S(   Ns   file.txtR   (   R   R_   (   R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  {	  s    
	(   R  (   R   R  R  R   RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   test_listt	  s
    c            sK     j  d    j d    j j d d  }   f d   } | j |  S(	   s<   
        Check the output of list with asked stats.
        R   s   file.txtR  R   t   permissionsc            s   |  j      j t |   d    j |  d d d    j |  d d d    j t |  d d  d    j t |  d d  d  d  S(   Ni   i    s   file.txti   R   (   R   R_   R   (   R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  	  s    
(   R  (   s   sizeR$  (   R   R  R  R   RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_listWithStat	  s
    	c         C   s2   |  j  d  |  j j d d  } |  j | t  S(   sP   
        Querying an invalid stat should result to a C{AttributeError}.
        R   R  R   t   whateverstat(   R  (   s   sizeR&  (   R   R  R   Ro   t   AttributeError(   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_listWithInvalidStat	  s    c            s;     j  d    j j d  }   f d   } | j |  S(   s@   
        Check the output of the list method on a file.
        s   file.txtc            s'   |  j      j |  d g  f g  d  S(   Ns   file.txt(   R   R_   (   R  (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  	  s    
	(   s   file.txt(   R  R  R   RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_listFile	  s    c         C   s%   |  j  j d  } |  j | t j  S(   sm   
        list on a directory that doesn't exist should fail with a
        L{ftp.FileNotFoundError}.
        R   (   s   foo(   R  R   Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_listNotExistingDirectory	  s    c         C   s#   |  j  d  |  j j d  } | S(   s+   
        Try to access a resource.
        R   (   s   ned(   R   R  t   access(   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_access	  s    c         C   s%   |  j  j d  } |  j | t j  S(   sF   
        access should fail on a resource that doesn't exist.
        R   (   s   foo(   R  R+  Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_accessNotFound	  s    c            s?     j  d    j j d  }   f d   } | j |  | S(   sY   
        Check that openForReading returns an object providing C{ftp.IReadFile}.
        s   file.txtc            s     j  t j j |    d  S(   N(   R  R   t	   IReadFilet
   providedBy(   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  	  s    (   s   file.txt(   R  R  t   openForReadingRX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_openForReading	  s
    c         C   s%   |  j  j d  } |  j | t j  S(   sr   
        openForReading should fail with a C{ftp.FileNotFoundError} on a file
        that doesn't exist.
        R   (   s   ned(   R  R0  Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_openForReadingNotFound	  s    c         C   s2   |  j  d  |  j j d  } |  j | t j  S(   s>   
        openForReading should not work on directory.
        R   (   s   ned(   R   R  R0  Ro   R   R  (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_openForReadingOnDirectory	  s    c            sD    j  j d  }    f d   }  f d     | j |  | S(   sZ   
        Check that openForWriting returns an object providing C{ftp.IWriteFile}.
        R   c            s,    j  t j j |    |  j   j    S(   N(   R  R   t
   IWriteFileR/  R   RX   (   R   (   t   cb2R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   cb1	  s    c            s     j  t j |    d  S(   N(   R  R   R/  (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR5  	  s    (   s   foo(   R  R   RX   (   R   R0   R6  (    (   R5  R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_openForWriting	  s
    c         C   s2   |  j  d  |  j j d  } |  j | t j  S(   sd   
        openForWriting should not be able to open a directory that already
        exists.
        R   (   s   ned(   R   R  R   Ro   R   R  (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt$   test_openForWritingExistingDirectory	  s    c         C   s2   |  j  d  |  j j d  } |  j | t j  S(   s   
        openForWring should fail with a L{ftp.FileNotFoundError} if you specify
        a file in a directory that doesn't exist.
        R   t   idonotexistR   (   s   nedR9  s   foo(   R   R  R   Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt)   test_openForWritingInNotExistingDirectory	  s    c            sN   d    j  d     j j d d  }    f d   } | j |  | S(   s@   
        Check the output of the stat method on a file.
        s   wobble
s   file.txtR   RF   c            s/     j  |  d t      j |  d  d  S(   Ni    i   (   R_   R   R  (   R   (   R   R  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  
  s    (   s   file.txt(   s   sizes	   directory(   R  R  t   statRX   (   R   R0   R  (    (   R   R  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_statFile
  s    c            sB     j  d    j j d d  }   f d   } | j |  | S(   sE   
        Check the output of the stat method on a directory.
        R   R   RF   c            s     j  |  d  d  S(   Ni   (   R  (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  
  s    (   s   ned(   s   sizes	   directory(   R   R  R;  RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_statDirectory
  s
    c            sB     j  d    j j d d  }   f d   } | j |  | S(   s3   
        Check the owner and groups stats.
        R   R;  R=  c            s     j  t |   d  d  S(   Ni   (   R_   R   (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  %
  s    (   s   ned(   s   owners   group(   R   R  R;  RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_statOwnerGroup
  s
    c         C   s(   |  j  j d d  } |  j | t j  S(   sf   
        stat should fail with L{ftp.FileNotFoundError} on a file that doesn't
        exist.
        R   R   RF   (   s   foo(   s   sizes	   directory(   R  R;  Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_statNotExisting+
  s    c         C   s2   |  j  d  |  j j d d  } |  j | t  S(   sP   
        Querying an invalid stat should result to a C{AttributeError}.
        R   R   R&  (   s   ned(   s   sizes   whateverstat(   R   R  R;  Ro   R'  (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_invalidStat4
  s    c            s>     j  d    j j d d  }   f d   } | j |  S(   s,   
        Try to rename a directory.
        R   R   c            s0     j    j d     j   j d   d  S(   NR   R   (   R  R  R  (   R   (   R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  C
  s    (   s   ned(   s   foo(   R   R  R  RX   (   R   R0   R  (    (   R   s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_rename=
  s    c         C   s(   |  j  j d d  } |  j | t j  S(   sl   
        Renaming a directory that doesn't exist should fail with
        L{ftp.FileNotFoundError}.
        R   R   (   s   foo(   s   bar(   R  R  Ro   R   R   (   R   R0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   test_renameNotExistingI
  s    (%   R(   R)   Rs   R  R   R  R  R  R  R  R  R  R  R  R  R!  R"  R#  R%  R(  R)  R*  R,  R-  R1  R2  R3  R7  R8  R:  R<  R=  R>  R?  R@  RA  RB  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR    sF   					
	
	
		
																								
	
								t   FTPShellTestCasec           B   s>   e  Z d  Z d   Z d   Z d   Z d   Z d d  Z RS(   s/   
    Tests for the C{ftp.FTPShell} object.
    c         C   s>   t  j |  j    |  _ |  j j   t j |  j  |  _ d S(   sB   
        Create a root directory and instantiate a shell.
        N(   R   RI   RE   R<  R   R   R  R  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^   X
  s    c         C   s   |  j  j |  j   S(   s:   
        Test if the directory exists at C{path}.
        (   R<  R   t   isdir(   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  a
  s    c         C   s   |  j  j |  j   S(   s0   
        Create a directory in C{path}.
        (   R<  R   R   (   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   h
  s    c         C   s   |  j  j |  j   S(   s5   
        Test if the file exists at C{path}.
        (   R<  R   t   isfile(   R   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  o
  s    R-   c         C   s   |  j  j |  j |  S(   s@   
        Create a file named C{path} with some content.
        (   R<  R   t
   setContent(   R   R   R  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  v
  s    (   R(   R)   Rs   R^   R  R   R  R  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRC  S
  s   					t   TestConsumerc           B   s9   e  Z d  Z e e  d Z d   Z d   Z d   Z	 RS(   s   
    A simple consumer for tests. It only works with non-streaming producers.

    @ivar producer: an object providing
        L{twisted.internet.interfaces.IPullProducer}.
    c         C   s8   |  j  d k s t  g  |  _ | |  _  |  j  j   d S(   sc   
        Simple register of producer, checks that no register has happened
        before.
        N(   t   producerR*   t   AssertionErrorR.   t   resumeProducing(   R   RH  t	   streaming(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   registerProducer
  s    		c         C   s"   |  j  d k	 s t  d |  _  d S(   sN   
        Unregister the producer, it should be done after a register.
        N(   RH  R*   RI  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   unregisterProducer
  s    c         C   s!   |  j  j |  |  j j   d S(   s)   
        Save the data received.
        N(   R.   R"   RH  RJ  (   R   R%   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   
  s    N(
   R(   R)   Rs   R   R   R*   RH  RL  RM  R   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRG  ~
  s   
		t   TestProducerc           B   s    e  Z d  Z d   Z d   Z RS(   s   
    A dumb producer.
    c         C   s   | |  _  | |  _ d S(   s   
        @param toProduce: data to write
        @type toProduce: C{str}
        @param consumer: the consumer of data.
        @type consumer: C{IConsumer}
        N(   t	   toProducet   consumer(   R   RO  RP  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   
  s    	c         C   s   |  j  j |  j  d S(   s+   
        Send the data to consume.
        N(   RP  R   RO  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   start
  s    (   R(   R)   Rs   R   RQ  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRN  
  s   	t   IReadWriteTestsMixinc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   sJ   
    Generic tests for the C{IReadFile} and C{IWriteFile} interfaces.
    c         C   s   t     d S(   sY   
        Return an object providing C{IReadFile}, ready to send data C{content}.
        N(   R  (   R   t   content(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   getFileReader
  s    c         C   s   t     d S(   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   getFileWriter
  s    c         C   s   t     d S(   s6   
        Return the content of the file used.
        N(   R  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   getFileContent
  s    c            sL   d  t        f d   }    f d      j   j |  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.
        s   wobble
c            s   |  j    j    S(   N(   t   sendRX   (   t   reader(   t   cbSendRP  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  
  s    c            s     j  d j  j     d  S(   NR-   (   R_   R   R.   (   R   (   RS  R   RP  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRY  
  s    (   RG  RT  RX   (   R   R  (    (   RY  R   RS  RP  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt	   test_read
  s
    	c            sL   d    f d   }    f d       f d     j    j |  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.
        s   elbbow
c            s   |  j    j   |   S(   N(   R   RX   (   t   writer(   t	   cbReceive(    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR  
  s    c            sF   t   |   } |  j d  t  | j   |  j   | j   j    S(   N(   RN  RL  R*   R   RQ  RM  R   RX   (   RP  R[  RH  (   t   cbCloseRS  (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR\  
  s
    

c            s    j   j      d  S(   N(   R_   RV  (   Rd   (   RS  R   (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR]  
  s    (   RU  RX   (   R   R  (    (   RS  R   R\  R]  s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt
   test_write
  s
    (   R(   R)   Rs   RT  RU  RV  RZ  R^  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRR  
  s   				t   FTPReadWriteTestCasec           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   
    Tests for C{ftp._FileReader} and C{ftp._FileWriter}, the objects returned
    by the shell in C{openForReading}/C{openForWriting}.
    c         C   sG   t  j |  j    |  _ |  j j   t j |  j  |  _ d |  _ d S(   s5   
        Create a temporary file used later.
        s   file.txtN(	   R   RI   RE   R<  R   R   R  R  R?  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^     s    c         C   s2   |  j  j |  j  j |  |  j j |  j f  S(   sV   
        Return a C{ftp._FileReader} instance with a file opened for reading.
        (   R<  R   R?  RF  R  R0  (   R   RS  (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRT    s    c         C   s   |  j  j |  j f  S(   sV   
        Return a C{ftp._FileWriter} instance with a file opened for writing.
        (   R  R   R?  (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRU    s    c         C   s   |  j  j |  j  j   S(   s;   
        Return the content of the temporary file.
        (   R<  R   R?  t
   getContent(   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRV    s    (   R(   R)   Rs   R^   RT  RU  RV  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR_  
  s
   	
		t   CloseTestWriterc           B   s-   e  Z e e j  e Z d    Z d   Z RS(   c         C   s+   t    |  _ t j |  j  } t j |  S(   N(   R    R   R   t   FileConsumerR   Rg   (   R   t   fc(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   %  s    c         C   s   t  |  _ |  j S(   N(   R   t   closeStartedR0   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   )  s    	(	   R(   R)   R   R   R4  R   Rd  R   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRa  "  s   	t   CloseTestShellc           B   s   e  Z d    Z RS(   c         C   s   t  j |  j  S(   N(   R   Rg   R[  (   R   t   segs(    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR   .  s    (   R(   R)   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRe  -  s   t   FTPCloseTestc           B   s   e  Z d  Z d   Z RS(   s.   Tests that the server invokes IWriteFile.closec         C   se  t  j   } d g | _ t   | _ t   | j _ t j   | j j _	 t  j
   | _ d | j _ | j t    t  j   } t  j |  | _ | | _ | j d  g  } | j d  } | j | j  |  j | j j j d  | j d  |  j | j j j d  | j d  |  j | j j j d  |  j |  | j j j	 j d  |  j |  | S(	   st   Confirm that FTP uploads (i.e. ftp_STOR) correctly call and wait
        upon the IWriteFile object's close() methodR<  R   s   close() called earlys   some data heres   reason is ignoreds   close() not calleds   allow close() to finishN(   R   t   FTPt   workingDirectoryRe  R  Ra  R[  R   R/   R0   RP   R   R*   t   timeOutR`  R    R$  R  R  t   ftp_STORRX   R"   R  Rd  R1   R4   R  R2   (   R   R    t   dit	   stor_doneR0   (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyR^  4  s0    	(   R(   R)   Rs   R^  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyRg  1  s   (R   Rs   RG   R  R    R  t   zope.interfaceR   t   zope.interface.verifyR   t   twisted.trialR   R   t   twisted.python.randbytesR   t   twisted.cred.portalR   t   twisted.protocolsR   t   twisted.internetR   R	   R
   R   R   t   twisted.internet.interfacesR   t   twisted.cred.errorR   t   twisted.credR   R   R   t   twisted.pythonR   R   R   t   twisted.testR   R   R   R  R  R  t   platformt	   isWindowsR  R*   t   LineReceiverR   RT  R,   t   TestCaseR5   Ru   Rx   R   R   R  R  R-  R1  R/  R3  RV  Rf  R  R  R  R  R  R  R  R  RC  R  RG  RN  RR  R_  Ra  Re  Rg  (    (    (    s9   /usr/lib/python2.7/dist-packages/twisted/test/test_ftp.pyt   <module>   sr   (			`15	N6   m77&B +'?&