
[XMc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l 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 d	 e j f d
     YZ d e j f d     YZ d e j f d     YZ d   Z d e f d     YZ d f  d     YZ d e j f d     YZ d e j f d     YZ d e f d     YZ d d l m Z d e j f d     YZ  d S(   sO   
Test cases covering L{twisted.python.filepath} and L{twisted.python.zippath}.
iN(   t   set(   t   WindowsErrort   ERROR_DIRECTORY(   t   filepath(   t
   ZipArchive(   t   platform(   t   unittestt   AbstractFilePathTestCasec           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 RS(   s   file 1s   file 2c         G   s8   t  j j t  j j |  j |   } |  j j |  | S(   N(   t   ost   patht   abspatht   joint   cmnt   allt   append(   t   selft   pt   x(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   _mkpath   s    $c         G   s   t  j |  j |    d  S(   N(   R   t   mkdirR   (   R   t   dirname(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   subdir   s    c         G   s   t  |  j |   d  S(   Nt   wb(   t   openR   (   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   subfile#   s    c         C   s2  t  j    |  _ t j j |  j    } |  _ | g |  _ t j |  |  j	 d  |  j
 d  } | j |  j  | j   |  j
 d d  } | j |  j  | j   |  j	 d  |  j
 d d  } | j   |  j
 d d  } | j   |  j
 d d  } | j   t j |  |  _ t j d  |  _ d  S(	   Nt   sub1t   file1t   file2t   sub3s
   file3.ext1s
   file3.ext2s
   file3.ext3t   /(   t   timet   nowR   R	   R
   t   mktempR   R   R   R   R   t   writet	   f1contentt   closet	   f2contentR   t   FilePatht   root(   R   R   t   f(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   setUp'   s(    




c         C   sG   |  j  |  j j d  j d  j d  j |  j  d d d g  d S(   sV   
        Verify that the segments between two paths are correctly identified.
        t   at   bt   cN(   t   assertEqualsR	   t   childt   segmentsFrom(   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_segmentsFromPositive>   s    -c         C   sV   |  j  t |  j j d  j d  j d  j |  j j d  j d  j d   d S(   sN   Verify that segmentsFrom notices when the ancestor isn't an ancestor.
        R)   R*   R+   t   dt   eN(   t   assertRaisest
   ValueErrorR	   R-   R.   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_segmentsFromNegativeF   s    $c         C   sH   g  |  j  j   D] } | j  ^ q } |  j t |  t |  j   d S(   si   
        Verify that walking the path gives the same result as the known file
        hierarchy.
        N(   R	   t   walkR,   R    R   (   R   t   fooR   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt	   test_walkO   s    %c         C   s   g  } |  j  j d  j d  j d  } | j  } | } t j  j |  } x; | |  j j  k r | j |  | } t j  j |  } qN W|  j g  | j   D] } | j  ^ q |  d S(   s{   
        L{FilePath.parents()} should return an iterator of every ancestor of
        the L{FilePath} in question.
        R)   R*   R+   N(   R	   R-   R   R   R&   R   R,   t   parents(   R   t   Lt   pathobjt   fullpatht   lastpatht   thispathR   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_parentsX   s    $	c         C   s   |  j  j d  } |  j | j   d  |  j | j   d  |  j | j   d  |  j | j   d  |  j | j   d g  d S(   s   Verify that a valid subdirectory will show up as a directory, but not as a
        file, not as a symlink, and be listable.
        R   s   This directory does exist.s   It's a directory.R   N(	   R	   R-   t
   failUnlesst   existst   isdirt   isfilet   islinkt   failUnlessEqualt   listdir(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_validSubdiri   s    c         C   s,   |  j  j d  } |  j | j   d  d S(   sT   
        Verify that a subdirectory that doesn't exist is reported as such.
        t   sub2s   This directory does not exist.N(   R	   R-   t   failIfR@   (   R   RG   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_invalidSubdirz   s    c         C   so   |  j  j d  } |  j | j   j   |  j  |  j  j d  j d  } |  j | j   j   |  j  d S(   sF   
        Make sure that we can read existent non-empty files.
        R   R   R   N(   R	   R-   RD   R   t   readR"   R$   (   R   t   f1t   f2(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_validFiles   s    c         C   sS   |  j  j d d d g  } |  j  j d  j d  j d  } |  j | |  d S(   s   
        C{fp.descendant([a, b, c])} returns the same L{FilePath} as is returned
        by C{fp.child(a).child(b).child(c)}.
        R)   R*   R+   N(   R	   t
   descendantR-   R,   (   R   t   multiplet   single(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_multipleChildSegments   s    $c         C   s   |  j  j d  } |  j  j d  } |  j  j d  } i  } d | | <d | | <|  j | | d  |  j | j   | g  |  j | j   d |  |  j | j   d |  d | | <|  j | | d  |  j t |  d  d S(	   sK   
        Verify that path instances are usable as dictionary keys.
        R   R   i   i   i    i   i   N(   R	   R-   R,   t   keyst   assertIdenticalt   assertNotIdenticalt   len(   R   RK   t   f1primeRL   t   dictoid(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_dictionaryKeys   s    


c         C   sF   |  j  j d  } i d | 6} d | | j  <|  j t |  d  d S(   s   
        Verify that path instances are usable as dictionary keys which do not clash
        with their string counterparts.
        R   t   hellot   goodbyei   N(   R	   R-   R,   RU   (   R   RK   RW   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_dictionaryKeyWithString   s    c         C   s&   |  j  t j |  j j d  j  d S(   sm   
        Verify that children raises the appropriate exception for non-existent
        directories.
        s   not realN(   R2   R   t   UnlistableErrorR	   R-   t   children(   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_childrenNonexistentError   s    c         C   s&   |  j  t j |  j j d  j  d S(   s   
        Verify that listdir raises the appropriate exception for attempting to list
        a file rather than a directory.
        R   N(   R2   R   R\   R	   R-   R]   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_childrenNotDirectoryError   s    c         C   s~   xw |  j  |  j  j d  f D]Z } |  j t | j    t  |  j t | j    t  |  j t | j    t  q Wd S(   s   
        Verify that all times returned from the various new time functions are ints
        (and hopefully therefore 'high precision').
        R   N(   R	   R-   RD   t   typet   getAccessTimet   floatt   getModificationTimet   getStatusChangeTime(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_newTimesAreFloats   s    "c         C   s~   xw |  j  |  j  j d  f D]Z } |  j t | j    t  |  j t | j    t  |  j t | j    t  q Wd S(   sy   
        Verify that all times returned from the various time functions are
        integers, for compatibility.
        R   N(   R	   R-   RD   R`   t   getatimet   intt   getmtimet   getctime(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_oldTimesAreInts   s    "(   t   __name__t
   __module__R"   R$   R   R   R   R(   R/   R4   R7   R>   RF   RI   RM   RQ   RX   R[   R^   R_   Re   Rj   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR      s(   													
	
						t   FakeWindowsPathc           B   s   e  Z d  Z d   Z RS(   sV   
    A test version of FilePath which overrides listdir to raise L{WindowsError}.
    c         C   s   t  t d   d S(   s.   
        @raise WindowsError: always.
        s0   A directory's validness was called into questionN(   R   R   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRE      s    (   Rk   Rl   t   __doc__RE   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRm      s   t   ListingCompatibilityTestsc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sU   
    These tests verify compatibility with legacy behavior of directory listing.
    c         C   s?   t  |  j    } |  j t j | j  |  j t | j  d S(   sn   
        Verify that when a WindowsError is raised from listdir, catching
        WindowsError works.
        N(   Rm   R    R2   R   R\   R]   R   (   R   t   fwp(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_windowsErrorExcept   s    c         C   s,   t  j |  j    } |  j t | j  d S(   sr   
        Verify that in the normal case where a directory does not exist, we will
        get an OSError.
        N(   R   R%   R    R2   t   OSErrorR]   (   R   t   fp(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_alwaysCatchOSError   s    c         C   s   t  j |  j    } |  j t | j  } | j j   } | j d  | j	 j j   } | j
   | j
   |  j | |  d S(   s   
        Verify that the Unlistable exception raised will preserve the attributes of
        the previously-raised exception.
        t   originalExceptionN(   R   R%   R    R2   Rr   R]   t   __dict__RR   t   removeRu   t   sortR,   (   R   Rs   t   oset   d1t   d2(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_keepOriginalAttributes  s    

(   Rk   Rl   Rn   Rq   Rt   R|   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRo      s   	
		c   	      C   s   t  j | d  } xy t j |   D]h \ } } } xV | D]N } t j j | |  } t j j | |  t |   d } | j | |  q8 Wq" W| j   d S(   sI   
    create a zipfile on zfname, containing the contents of dirname'
    t   wi   N(	   t   zipfilet   ZipFileR   R5   R	   R   RU   R!   R#   (	   R   t   zfnamet   zfR&   t   ignoredt   filest   fnamet   fspatht   arcpath(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   zipit  s    #t   ZipFilePathTestCasec           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   sk   
    Test various L{ZipPath} path manipulations as well as reprs for L{ZipPath}
    and L{ZipArchive}.
    c         C   s   t  j |   t |  j |  j d  t |  j d  |  _ |  j |  _ g  |  j D]" } | j |  j |  j d  ^ qP |  _ d  S(   Ns   .zip(	   R   R(   R   R   R   R	   R&   R   t   replace(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR(   &  s
    c         C   s   |  j  j d  } d t j  j |  j d t j d  f } |  j t |  |  |  j j t j	   t j d d  d } t
 |  } | j d  } |  j t |  |  d S(   s   
        Make sure that invoking ZipPath's repr prints the correct class name
        and an absolute path to the zip file.
        R6   s   ZipPath(%r)s   .zipt    i   N(   R	   R-   R   R
   R   t   sepR,   t   reprR   t   getcwdR   (   R   R-   t   pathReprt   relativeCommont   relpath(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_zipPathRepr.  s    ()c         C   sk   |  j  j d  j d  j d  } d |  j d t j j d d d d g  } |  j t |  |  d S(   s   
        The repr of a ZipPath with C{".."} in the internal part of its path
        includes the C{".."} rather than applying the usual parent directory
        meaning.
        R6   s   ..t   bars   ZipPath(%r)s   .zipR   N(   R	   R-   R   R   R   R   R,   R   (   R   R-   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt    test_zipPathReprParentDirSegmentC  s    $*c         C   se   |  j  j d  } |  j d t j j d d g  } d | j d  f } |  j t |  |  d S(   s   
        Bytes in the ZipPath path which have special meaning in Python
        string literals are escaped in the ZipPath repr.
        t   's   .zipR   s   ZipPath('%s')s   string-escapeN(	   R	   R-   R   R   R   R   t   encodeR,   R   (   R   R-   R	   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_zipPathReprEscapingO  s    #c         C   s   d t  j j |  j d  f } |  j t |  j  |  |  j j t  j   t  j d d  d } t	 |  } |  j t |  |  d S(   s   
        Make sure that invoking ZipArchive's repr prints the correct class
        name and an absolute path to the zip file.
        s   ZipArchive(%r)s   .zipR   i   N(
   R   R	   R
   R   R,   R   R   R   R   R   (   R   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_zipArchiveReprZ  s
     )(   Rk   Rl   Rn   R(   R   R   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR   !  s   				t   ExplodingFilec           B   s2   e  Z d  Z e Z d d  Z d   Z d   Z RS(   s   
    A C{file}-alike which raises exceptions from its I/O methods and keeps track
    of whether it has been closed.

    @ivar closed: A C{bool} which is C{False} until C{close} is called, then it
        is C{True}.
    i    c         C   s   t     d S(   s0   
        @raise IOError: Always raised.
        N(   t   IOError(   R   t   n(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRJ   w  s    c         C   s   t     d S(   s0   
        @raise IOError: Always raised.
        N(   R   (   R   t   what(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR!   ~  s    c         C   s   t  |  _ d S(   s6   
        Mark the file as having been closed.
        N(   t   Truet   closed(   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR#     s    (   Rk   Rl   Rn   t   FalseR   RJ   R!   R#   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR   m  s
   	t   TrackingFilePathc           B   s8   e  Z d  Z e d d  Z d   Z d   Z d   Z RS(   sc  
    A subclass of L{filepath.FilePath} which maintains a list of all other paths
    created by clonePath.

    @ivar trackingList: A list of all paths created by this path via
        C{clonePath} (which also includes paths created by methods like
        C{parent}, C{sibling}, C{child}, etc (and all paths subsequently created
        by those paths, etc).

    @type trackingList: C{list} of L{TrackingFilePath}

    @ivar openedFiles: A list of all file objects opened by this
        L{TrackingFilePath} or any other L{TrackingFilePath} in C{trackingList}.

    @type openedFiles: C{list} of C{file}
    c         C   sA   t  j j |  | |  | d  k r+ g  } n  | |  _ g  |  _ d  S(   N(   R   R%   t   __init__t   Nonet   trackingListt   openedFiles(   R   R	   t   alwaysCreateR   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s
    		c         O   s,   t  j j |  | |  } |  j j |  | S(   sI   
        Override 'open' to track all files opened by this path.
        (   R   R%   R   R   R   (   R   R)   t   kR'   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s    c         C   s#   g  |  j  D] } | j r
 | ^ q
 S(   s   
        Return a list of all L{TrackingFilePath}s associated with this
        L{TrackingFilePath} that have had their C{open()} method called.
        (   R   R   (   R   R	   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   openedPaths  s    c         C   s)   t  | d |  j } |  j j |  | S(   s}   
        Override L{filepath.FilePath.clonePath} to give the new path a reference
        to the same tracking list.
        R   (   R   R   R   (   R   t   namet   clone(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt	   clonePath  s    N(	   Rk   Rl   Rn   R   R   R   R   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s
   			t   ExplodingFilePathc           B   s/   e  Z d  Z d d  Z d d  Z d   Z RS(   s   
    A specialized L{FilePath} which always returns an instance of
    L{ExplodingFile} from its C{open} method.

    @ivar fp: The L{ExplodingFile} instance most recently returned from the
        C{open} method.
    c         C   s5   t  j j |  |  | d k r( |  } n  | |  _ d S(   sY  
        Initialize an L{ExplodingFilePath} with a name and a reference to the

        @param pathName: The path name as passed to L{filepath.FilePath}.
        @type pathName: C{str}

        @param originalExploder: The L{ExplodingFilePath} to associate opened
        files with.
        @type originalExploder: L{ExplodingFilePath}
        N(   R   R%   R   R   t   _originalExploder(   R   t   pathNamet   originalExploder(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s    	c         C   s   t    } |  j _ | S(   s   
        Create, save, and return a new C{ExplodingFile}.

        @param mode: Present for signature compatibility.  Ignored.

        @return: A new C{ExplodingFile}.
        (   R   R   Rs   (   R   t   modeR'   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s    c         C   s   t  | |  j  S(   N(   R   R   (   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s    N(   Rk   Rl   Rn   R   R   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s   t   FilePathTestCasec           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 e e d d>  s d Z e e _ e e _ e e _ n  d   Z d   Z d   Z d   Z d   Z d   Z e j    d k r/d e _ n  d   Z! e j    d k rVd e! _ n  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+   Z0 d,   Z1 d-   d.  Z2 d/   Z3 d0   Z4 d1   Z5 d2   Z6 d3   Z7 d4   Z8 d5   Z9 d6   Z: d7   Z; d8   Z< d9   Z= d:   Z> d;   Z? d<   Z@ d=   ZA e jB   reC e@ _ eC eA _ n	 eC e? _ RS(?   s6   
    Test various L{FilePath} path manipulations.
    c         C   sb   x[ d D]S } |  j  j d  j |  |  j t j t j |  j  j d  j   j  |  q Wd S(   s   
        Make sure that calling L{FilePath.chmod} modifies the permissions of
        the passed file as expected (using C{os.stat} to check). We use some
        basic modes that should work everywhere (even on Windows).
        im  i  R   N(   im  i  (   R	   R-   t   chmodR,   t   statt   S_IMODER   t   st_mode(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt
   test_chmod  s
    'c         C   s>   t  t d d  d k r* t j d   n  t j | |  d S(   s   
        Create a symbolic link named C{name} pointing at C{target}.

        @type target: C{str}
        @type name: C{str}
        @raise SkipTest: raised if symbolic links are not supported on the
            host platform.
        t   symlinks)   Platform does not support symbolic links.N(   t   getattrR   R   R   t   SkipTestR   (   R   t   targetR   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR      s    	c         C   s   |  j  j d  } |  j | j  |  j d   |  j | j d  j  |  j d   |  j | j d  j  |  j d d   d S(   sI   
        Create several symbolic links to files and directories.
        R   s	   sub1.linkR   s
   file2.links   sub1.file2.linkN(   R	   R-   R   R   (   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   createLinks  s
    %c         C   ss   |  j    |  j |  j j d  j |  j j d  j  |  j |  j j d  j   |  j j d  j d   d S(   sd   
        L{FilePath.realpath} returns the path of the ultimate target of a
        symlink.
        s
   file2.links	   link.linkR   R   N(   R   R   R	   R-   R,   t   realpath(   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_realpathSymlink  s
    
c         C   s   |  j  |  j j d  j |  j j d  j  |  j  |  j j d  j |  j j d  j  |  j t j |  j j d  j  d S(   s   
        L{FilePath.realpath} raises L{filepath.LinkError} if the path is a
        symbolic link which is part of a cycle.
        t   link1t   link2N(   R   R	   R-   R2   R   t	   LinkErrorR   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_realpathCyclicalSymlink&  s    ..c         C   s2   |  j  |  j j d  j   |  j j d   d S(   sj   
        L{FilePath.realpath} returns the path itself if the path is not a
        symbolic link.
        R   N(   R,   R	   R-   R   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_realpathNoSymlink1  s    c            sg     j      j   j j d  j   j j d  j d  j    f d   }   j t j |  d S(   sT   
        Verify that walking a path with a cyclical symlink raises an error
        R   s   sub1.loopylinkc             s#   g    j  j   D] }  |  j  ^ q S(   N(   R	   R5   (   R6   (   R   (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   iterateOverPathA  s    N(   R   R   R	   R-   R2   R   R   (   R   R   (    (   R   s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_walkCyclicalSymlink:  s
    
c            sp     j      j   j j d  j   j j d  j d  j  d       f d   }   j |    d S(   s   
        Verify that, after making a path with cyclical symlinks, when the
        supplied C{descend} predicate returns C{False}, the target is not
        traversed, as if it was a simple symlink.
        R   s   sub1.loopylinkc         S   s   |  j    S(   N(   RC   (   R	   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt
   noSymLinksP  s    c             s)   g    j  j d   D] }  |  j  ^ q S(   Nt   descend(   R	   R5   (   R6   (   R   R   (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR   R  s    N(   R   R   R	   R-   t
   assertTrue(   R   R   (    (   R   R   s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt)   test_walkObeysDescendWithCyclicalSymlinksF  s    
	c         C   sa   |  j    d   } g  |  j j d |  D] } | j ^ q) } |  j t |  t |  j   d S(   s{   
        Verify that when the supplied C{descend} predicate returns C{False},
        the target is not traversed.
        c         S   s   |  j    S(   N(   RC   (   R	   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR   ]  s    R   N(   R   R	   R5   R,   R    R   (   R   R   R6   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_walkObeysDescendW  s    
	+c         C   s   d } |  j  j d  j |  |  j  j d  j   } |  j | |  d } |  j  j d  j | d  |  j  j d  j   } |  j | |  d  S(   Nt
   newcontentt   newt   contents   .tmp(   R	   R-   t
   setContentt
   getContentRD   (   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_getAndSetc  s    c         C   s6   t  d  } |  j t | j  |  j | j j  d S(   s   
        If reading from the underlying file raises an exception,
        L{FilePath.getContent} raises that exception after closing the file.
        R   N(   R   R2   R   R   R   Rs   R   (   R   Rs   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_getContentFileClosingn  s    c         C   s9   t  d  } |  j t | j d  |  j | j j  d S(   s   
        If writing to the underlying file raises an exception,
        L{FilePath.setContent} raises that exception after closing the file.
        R   t   blahN(   R   R2   R   R   R   Rs   R   (   R   Rs   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_setContentFileClosingx  s    c         C   sj   t  |  j    } | j d  | j d  | j   } |  j t |  d  |  j | d | d  d S(   s   
        L{FilePath.setContent} will use a different temporary filename on each
        invocation, so that multiple processes, threads, or reentrant
        invocations will not collide with each other.
        t   alphat   betai   i    i   N(   R   R    R   R   R,   RU   t   assertNotEquals(   R   Rs   t   openedSiblings(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_setContentNameCollision  s    c         C   s   t  |  j    } | j d  | j   } |  j t |  d  |  j | d j   j d  d | d j    | j d d  | j   } |  j t |  d  |  j | d j   j d  d	 | d j    d
 S(   s   
        L{FilePath.setContent} creates temporary files with a user-supplied
        extension, so that if it is somehow interrupted while writing them, the
        file that it leaves behind will be identifiable.
        RY   i   i    s   .news-   %s does not end with default '.new' extensionRZ   s   -something-elsei   s.   %s does not end with -something-else extensionN(	   R   R    R   R   R,   RU   R   t   basenamet   endswith(   R   Rs   t   opened(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_setContentExtension  s    c         C   s   |  j  j d  } |  j  j d  } |  j | j  | j   |  j | j    |  j | j    |  j | j    |  j | j    d S(   s   
        Verify the behavior of the C{isLink} method against links and
        non-links. Also check that the symbolic link shares the directory
        property with its target.
        t   sub4R   N(   R	   R-   R   R   RC   t   assertFalseRA   (   R   t   s4t   s3(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_symbolicLink  s    c         C   s   |  j  j d  |  j  j d  f |  j  j d  j d  |  j  j d  f g } xo | D]g \ } } | j |  |  j | j   d  |  j | j   | j    |  j | j   | j    qX Wd S(   s   
        Verify that symlink creates a valid symlink that is both a link and a
        file if its target is a file, or a directory if its target is a
        directory.
        RG   s	   sub2.links
   file3.ext1s   file3.ext1.links   This is a linkN(   R	   R-   t   linkToR   RC   R,   RA   RB   (   R   t   targetLinksR   t   link(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_linkTo  s    !c         C   sr   |  j  t |  j j d  j |  j j d  j d   |  j  t |  j j d  j |  j j d  j d   d S(   s   
        Verify C{linkTo} fails in the following case:
            - the target is in a directory that doesn't exist
            - the target already exists
        R   t   nosubR   R   N(   R2   Rr   R	   R-   R   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_linkToErrors  s    R   s.   Your platform does not support symbolic links.c         C   s   |  j  j d  j d  } d	 } |  j | j |    | j d  } | j   |  j | j |   j    |  j | j d  j    | j   |  j | j |    d  S(
   NR   t   file3s   .foos   .bart   ext1t   ext2t   ext3t   *(   s   .foos   .barR   R   R   (   R	   R-   RH   t   siblingExtensionSearcht   siblingExtensiont   touchR@   Rw   (   R   t   f3t   extst   f3e(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testMultiExt  s    

c         C   s9   t  j d  } | j d  |  j t  j | j d  d  S(   Nt   .s   foo/bars   /foo(   R   R%   t   preauthChildR2   t   InsecurePathR-   (   R   Rs   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testPreauthChild  s    c         C   sn  |  j  j d  } | j   |  j | j   d  |  j t | j   t j    d d  |  j t | j   t j    d d  |  j t | j	   t j    d d  |  j | j
   t  |  j | j
   t  t j | j   |  j | j
   t  | j d t  |  j | j
   t  |  j | j   t  |  j | j   t  |  j | j   t  d  S(   Nt   stattesti    i   t   reraise(   R	   R-   R   RD   t   getsizet   absRh   R   Ri   Rf   R@   R   R   Rw   t   restatR   RC   RA   RB   (   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testStatCache  s    
***c         C   sQ   t  j t  j |  j   } |  j |  j j | j  |  j |  j j | j  d  S(   N(   t   picklet   loadst   dumpsR	   RD   t	   __class__(   R   t   newpath(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testPersist  s    c         C   sX   |  j  t j |  j j d  |  j  t j |  j j d  |  j  t j |  j j d  d  S(   Ns   ..s   /etcs   ../..(   R2   R   R   R	   R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testInsecureUNIX  s    c         C   s<   |  j  t j |  j j d  |  j  t j |  j j d  d  S(   Ns   ..\..s   C:randomfile(   R2   R   R   R	   R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testInsecureWin32	  s    t   win32s   Consider yourself lucky.c         C   sX   |  j  t j |  j j d  |  j  t j |  j j d  |  j  t j |  j j d  d S(   s  Windows has 'special' filenames like NUL and CON and COM1 and LPR
        and PRN and ... god knows what else.  They can be located anywhere in
        the filesystem.  For obvious reasons, we do not wish to normally permit
        access to these.
        t   CONs   C:CONs   C:\CONN(   R2   R   R   R	   R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testInsecureWin32Whacky  s    c         C   ss  |  j  t j d  t j d   |  j t j d  t j d  k  |  j t j d  t j d  k  |  j t j d  t j d  k  |  j t j d  t j d  k  |  j t j d  t j d  k   |  j t j d  t j d  k  |  j t j d  t j d  k  |  j t j d  t j d  k  |  j t j d  t j d  k  d  S(   NR)   t   z(   R,   R   R%   R?   RH   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testComparison  s(    c         C   s&   |  j  t j |  j j d d g  d S(   st   
        If C{".."} is in the sequence passed to L{FilePath.descendant},
        L{InsecurePath} is raised.
        R)   s   ..N(   R2   R   R   R	   RN   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_descendantOnly5  s    c         C   sz   |  j  j d  } | j d  } |  j | j   | j    |  j | j   d  | j   |  j | |  j  j    d  S(   Nt   sibling_startt   sibling_test(	   R	   R-   t   siblingR,   R   R   t   createDirectoryt   assertInR]   (   R   R   t   ts(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testSibling>  s    
c         C   sz   |  j  j   } |  j | j   |  j  j    |  j | j   |  j  j    | j   |  j | |  j  j	   j
    d  S(   N(   R	   t   temporarySiblingR,   R   t   assertNotInR   RE   R  R  t   parentR]   (   R   R  (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testTemporarySiblingF  s
    
c         C   sK   d } |  j  j |  } |  j | j   j |  d | j   | f  d S(   s   
        If L{FilePath.temporarySibling} is given an extension argument, it will
        produce path objects with that extension appended to their names.
        s   .test-extensions   %s does not end with %sN(   R	   R  R   R   R   (   R   t   testExtensionR  (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_temporarySiblingExtensionN  s
    c         C   s'   |  j  j   |  j |  j  j    d S(   s~   
        L{FilePath.remove} on a L{FilePath} that refers to a directory will
        recursively delete its contents.
        N(   R	   Rw   RH   R@   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_removeDirectoryZ  s    c         C   st   |  j  j d  } |  j |  j  j d  j  | j   | j   |  j | j    |  j |  j  j d  j    d S(   sx   
        For a path which is a symbolic link, L{FilePath.remove} just deletes
        the link, not the target.
        s	   sub1.linkR   N(   R	   R-   R   Rw   R   R@   R   (   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_removeWithSymlinkc  s
    "
c         C   s   t  |  j j    } t j |  j    } |  j j |  |  j j   | j |  j  t  |  j j    } | j   | j   |  j	 | |  d S(   s   
        L{FilePath.copyTo} makes a copy of all the contents of the directory
        named by that L{FilePath} if it is able to do so.
        N(
   t   listR	   R5   R   R%   R    t   copyToRw   Rx   R,   (   R   t   oldPathsRs   t   newPaths(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_copyToDirectoryp  s    

c         C   s]   |  j  j d  } d   | _ t |  j    } |  j t | j |  |  j | j	 j
  d S(   s   
        If an exception is raised while L{FilePath.copyTo} is trying to open
        source file to read from, the destination file is closed and the
        exception is raised to the caller of L{FilePath.copyTo}.
        t   notherec           S   s   t  S(   N(   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   <lambda>  s    N(   R	   R-   RB   R   R    R2   R   R  R   Rs   R   (   R   t   nosucht   destination(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt!   test_copyToMissingDestFileClosing  s
    c         C   s^   t  |  j    } t  t  } |  j t | j |  |  j | j j  |  j | j j  d S(   s   
        If an exception is raised while L{FilePath.copyTo} is copying bytes
        between two regular files, the source and destination files are closed
        and the exception propagates to the caller of L{FilePath.copyTo}.
        N(	   R   R    t   __file__R2   R   R  R   Rs   R   (   R   R   t   source(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_copyToFileClosing  s
    c         C   s/   |  j  t t f |  j j |  j j d   d S(   s   
        L{FilePath.copyTo} fails with an OSError or IOError (depending on
        platform, as it propagates errors from open() and write()) when
        attempting to copy a directory to a child of itself.
        R   N(   R2   Rr   R   R	   R  R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_copyToDirectoryItself  s    c         C   s   |  j  |  j j d  j |  j j d  j  t j |  j    } |  j j |  |  j | j d  j    |  j	 g  | j d  j
   D] } | j   ^ q g  | j d  j
   D] } | j   ^ q  d S(   sn   
        Verify that copying with followLinks=True copies symlink targets
        instead of symlinks
        R   R   N(   R   R	   R-   R   R%   R    R  R   RC   R,   R]   R   (   R   Rs   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_copyToWithSymlink  s    1c         C   s   |  j  d |  j j d  j  t j |  j    } |  j j | d t |  j | j d  j	    |  j
 t j |  j j d  j  t j | j d  j   d S(   sX   
        Verify that copying with followLinks=False copies symlinks as symlinks
        R   R   t   followLinksN(   R   R	   R-   R   R%   R    R  R   R   RC   R,   R   t   readlink(   R   Rs   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_copyToWithoutSymlink  s    !c         C   s   t  |  j j    } t j |  j    } |  j j |  | j |  j  t  |  j j    } | j   | j   |  j | |  d S(   sv   
        Verify that moving an entire directory results into another directory
        with the same content.
        N(	   R  R	   R5   R   R%   R    t   moveToRx   R,   (   R   R  Rs   R  (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_moveTo  s    

c         C   s   t  j |  j    } t  j |  j    } | j   |  j | j   t  |  j | j   t  | j |  |  j	 | j   t  |  j	 | j   t  d S(   s   
        A L{FilePath} that has been moved aside with L{FilePath.moveTo} no
        longer registers as existing.  Its previously non-existent target
        exists, though, as it was created by the call to C{moveTo}.
        N(
   R   R%   R    R   R,   R@   R   R   R*  t   assertEqual(   R   Rs   t   fp2(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_moveToExistsCache  s    
c         C   s   |  j    |  j   d S(   sp   
        The assertion of test_moveToExistsCache should hold in the case of a
        cross-mount move.
        N(   t   setUpFaultyRenameR.  (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt    test_moveToExistsCacheCrossMount  s    
c           C   s   d  S(   N(   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR    s    c         C   s   t  j |  j    } t  j |  j    } | j d  | j d  |   |  j | j   d  |  j | j   d  t j | j  |  j | j   d  | j	 |  |  j | j   d  d S(   s  
        L{FilePath.moveTo} clears its destination's status cache, such that
        calls to L{FilePath.getsize} after the call to C{moveTo} will report the
        new size, not the old one.

        This is a separate test from C{test_moveToExistsCache} because it is
        intended to cover the fact that the destination's cache is dropped;
        test_moveToExistsCache doesn't cover this case because (currently) a
        file that doesn't exist yet does not cache the fact of its non-
        existence.
        t   1234t
   1234567890i   i
   N(
   R   R%   R    R   R,  R   R   Rw   R	   R*  (   R   t   hookRs   R-  (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_moveToSizeCache  s    c         C   s   |  j  d |  j  d S(   sn   
        The assertion of test_moveToSizeCache should hold in the case of a
        cross-mount move.
        R3  N(   R4  R/  (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_moveToSizeCacheCrossMount  s    c         C   s/   |  j  t t f |  j j |  j j d   d S(   s   
        Verify error behavior of moveTo: it should raises one of OSError or
        IOError if you want to move a path into one of its child. It's simply
        the error raised by the underlying rename system call.
        R   N(   R2   Rr   R   R	   R*  R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_moveToError  s    c            s8   g      f d   } t  j   |  j t  d |   S(   s  
        Set up a C{os.rename} that will fail with L{errno.EXDEV} on first call.
        This is used to simulate a cross-device rename failure.

        @return: a list of pair (src, dest) of calls to C{os.rename}
        @rtype: C{list} of C{tuple}
        c            sG     j  |  | f  t    d k r: t t j d   n   |  |  S(   Ni   s;   Test-induced failure simulating cross-device rename failure(   R   RU   Rr   t   errnot   EXDEV(   t   srct   dest(   t   invokedWitht   originalRename(    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   faultyRename,  s    t   rename(   R   R>  t   patch(   R   R=  (    (   R<  R;  s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR/  #  s
    	c         C   s'   |  j    } |  j   |  j |  d S(   s   
        C{moveTo} should be able to handle C{EXDEV} error raised by
        C{os.rename} when trying to move a file on a different mounted
        filesystem.
        N(   R/  R+  R   (   R   R;  (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_crossMountMoveTo8  s    
c         C   s   |  j    } |  j j d  } |  j j d  } |  j |  j j d  j | j  | j |  |  j | j    |  j | j   d  |  j	 |  d S(   s   
        By default, when moving a symlink, it should follow the link and
        actually copy the content of the linked node.
        R   R   R   s   file 1N(
   R/  R	   R-   R   R*  R   RC   R,   R   R   (   R   R;  RL   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt    test_crossMountMoveToWithSymlinkH  s    "c         C   s   |  j    } |  j j d  } |  j j d  } |  j |  j j d  j | j  | j | d t |  j | j    |  j | j	   d  |  j |  d S(   sk   
        Verify that moveTo called with followLinks=False actually create
        another symlink.
        R   R   R   R'  s   file 1N(
   R/  R	   R-   R   R*  R   R   RC   R,   R   (   R   R;  RL   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt#   test_crossMountMoveToWithoutSymlinkW  s    "c         C   sz   t  j |  j    } | j   } |  j d | j k  | j d  | j   t | j	 d  j
   } |  j | d  d S(   s>  
        L{FilePath.create} should always open (and write to) files in binary
        mode; line-feed octets should be unmodified.

        (While this test should pass on all platforms, it is only really
        interesting on platforms which have the concept of binary mode, i.e.
        Windows platforms.)
        R*   s   
t   rbN(   R   R%   R    t   createR?   R   R!   R#   R   R	   RJ   R,  (   R   R	   R'   RJ   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_createBinaryModef  s    	
c         C   s  |  j  j d  } |  j t | j  } |  j | j t j  |  j  j d  } | j d  } | j d  | j	   | j   } |  j | j
   d  | j	   | j d  } | j	   | j   } |  j | j
   d  | j	   |  j  j d  } | j d  } | j d  | j	   | j d  } | j d	  | j	   | j d
  } |  j | j
   d  | j	   | j d  } |  j | j
   d  | j d d  | j d  | j	   | j d
  } |  j | j
   d  | j	   | j d  } |  j | j
   d  | j d d  | j d  | j	   | j d  } | j d  | j d d  |  j | j
   d  | j d d  |  j | j
   d  | j	   | j t  | j d  j	   | } ~ |  j t t f | j  d  S(   Nt   nonexistentt   writerR}   s   abc
defR   t   appendert   abcR)   t   deft   rt   abcdefs   r+i    i   t   ghit	   abcdefghis   w+t   123s   a+t   456t   123456(   R	   R-   R2   R   R   R,   R7  t   ENOENTR!   R#   RJ   t   seekt   requireCreateR   Rr   (   R   RF  R1   RG  R'   RH  t   existent(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testOpenx  sd    










c         C   sL   |  j  j d  } | j d  } | j d  | j   |  j | j  d S(   sj  
        Due to a bug in Python 2.7 on Windows including multiple 'b'
        characters in the mode passed to the built-in open() will cause an
        error.  FilePath.open() ensures that only a single 'b' character is
        included in the mode passed to the built-in open().

        See http://bugs.python.org/issue7686 for details about the bug.
        s   explicit-binaryR   s   abc
defN(   R	   R-   R   R!   R#   R   R@   (   R   RG  t   file(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_openWithExplicitBinaryMode  s
    	
c         C   sL   |  j  j d  } | j d  } | j d  | j   |  j | j  d S(   s  
        Due to a bug in Python 2.7 on Windows including multiple 'b'
        characters in the mode passed to the built-in open() will cause an
        error.  No matter how many 'b' modes are specified, FilePath.open()
        ensures that only a single 'b' character is included in the mode
        passed to the built-in open().

        See http://bugs.python.org/issue7686 for details about the bug.
        s   multiple-binaryt   wbbs   abc
defN(   R	   R-   R   R!   R#   R   R@   (   R   RG  RW  (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt)   test_openWithRedundantExplicitBinaryModes  s
    

c         C   sO   t  j |  j    } |  j | j   t  | j   |  j | j   t  d S(   s   
        Check that C{filepath.FilePath.exists} correctly restat the object if
        an operation has occurred in the mean time.
        N(   R   R%   R    R,   R@   R   t   makedirsR   (   R   Rs   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_existsCache  s    
c         C   s   t  j |  j    } | j d  |  j | j   d  t | j d  } | j d  | j	   |  j | j   d  | j
   |  j | j d  |  j | j   d  d S(   s   
        L{FilePath.changed} indicates that the L{FilePath} has changed, but does
        not re-read the status information from the filesystem until it is
        queried again via another method, such as C{getsize}.
        t   12345i   R   t   12345678i   N(   R   R%   R    R   R,   R   R   R	   R!   R#   t   changedR,  t   statinfoR   (   R   Rs   t   fObj(    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_changed  s    

c         C   sr   |  j  t |  j j  |  j  t |  j j  |  j  t |  j j  |  j  t |  j j  |  j  t |  j j  d S(   sM   
        Verify that certain file stats are not available on Windows
        N(   R2   t   NotImplementedErrorR	   t   getInodeNumbert	   getDevicet   getNumberOfHardLinkst	   getUserIDt
   getGroupID(   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt(   test_statinfoBitsNotImplementedInWindows  s
    c         C   s   |  j  j d  } x |  j  | f D]t } |  j | j   t  |  j | j   t  |  j | j   t  |  j | j   t  |  j | j	   t  q" W|  j
 |  j  j   | j    |  j
 |  j  j	   | j	    d S(   so   
        Verify that file inode/device/nlinks/uid/gid stats are numbers in
        a POSIX environment
        R   N(   R	   R-   t   assertIsInstanceRd  t   longRe  Rf  Rg   Rg  Rh  R,   (   R   R+   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_statinfoBitsAreNumbers"  s    c            s   d d d     Y} |       f d   } |   j  _ d   j  _   j   j  j    j    j   j  j    j    j   j  j	    j
    j   j  j    j    j   j  j    j  d S(   s   
        Verify that the right numbers come back from the right accessor methods
        for file inode/device/nlinks/uid/gid (in a POSIX environment)
        t   FakeStatc           B   s&   e  Z d  Z d Z d Z d Z d Z RS(   i   i,  i  i  iX  (   Rk   Rl   t   st_inot   st_devt   st_nlinkt   st_uidt   st_gid(    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRm  8  s
   c             s      j  _ d  S(   N(   R	   R`  (   t   argst   kwargs(   t   fakeR   (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt
   fakeRestatA  s    N(    (   R	   R   R   R`  R,   Rd  Rn  Re  Ro  Rf  Rp  Rg  Rq  Rh  Rr  (   R   Rm  Rv  (    (   R   Ru  s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   test_statinfoNumbersAreValid2  s    	N(D   Rk   Rl   Rn   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   skipMsgt   skipR   R   R   R   R  R  R   t   getTypeR  R  R  R  R  R  R  R  R  R!  R$  R%  R&  R)  R+  R.  R0  R4  R5  R6  R/  R@  RA  RB  RE  RV  RX  RZ  R\  Rb  Ri  Rl  Rw  t	   isWindowsR   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR     s   												
	
														
													
						 									Y								(   t   urlpatht   URLPathTestCasec           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   t  j j d  |  _ d  S(   Ns/   http://example.com/foo/bar?yes=no&no=yes#footer(   R|  t   URLPatht
   fromStringR	   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR(   Z  s    c         C   s   |  j  t |  j  d  d  S(   Ns/   http://example.com/foo/bar?yes=no&no=yes#footer(   R,   t   strR	   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testStringConversion]  s    c         C   sQ   |  j  t |  j j d   d  |  j  t |  j j d  j d   d  d  S(   NRY   s    http://example.com/foo/bar/helloR   s!   http://example.com/foo/bar/hello/(   R,   R  R	   R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testChildString`  s    "c         C   sQ   |  j  t |  j j d   d  |  j  t |  j j d  j d   d  d  S(   Nt   bazs   http://example.com/foo/bazR   s   http://example.com/foo/bar/baz(   R,   R  R	   R  R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testSiblingStringd  s    "c         C   s   |  j  t |  j j    d  |  j  t |  j j d  j    d  |  j  t |  j j d  j    d  |  j  t |  j j   j   j   j   j    d  d  S(   Ns   http://example.com/R   s   http://example.com/foo/R  (   R,   R  R	   R  R-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testParentStringm  s    ((c         C   sK   |  j  t |  j j    d  |  j  t |  j j d  j    d  d  S(   Ns   http://example.com/foo/R   s   http://example.com/foo/bar/(   R,   R  R	   t   hereR-   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   testHereStringu  s    (   Rk   Rl   R(   R  R  R  R  R  (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR}  Y  s   						(!   Rn   R   R   R   R7  R~   R   t   twisted.python.compatR    t   twisted.python.win32R   R   t   twisted.pythonR   t   twisted.python.zippathR   t   twisted.python.runtimeR   t   twisted.trialR   t   TestCaseR   R%   Rm   Ro   R   R   R   R   R   R   R|  R}  (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt   <module>   s*   H(	L 6+   l