Your IP : 172.28.240.42


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


=Nc@sdZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZddlmZd	ejfd
YZde
jfdYZd
ejfdYZdZdefdYZdfdYZde
jfdYZde
jfdYZdejfdYZdefdYZddlm Z dejfdYZ!dS(sO
Test cases covering L{twisted.python.filepath} and L{twisted.python.zippath}.
iN(tset(tWindowsErrortERROR_DIRECTORY(tfilepath(t
ZipArchive(tplatform(tunittesttAbstractFilePathTestCasecBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZRS(sfile 1sfile 2cGs8tjjtjj|j|}|jj||S(N(tostpathtabspathtjointcmntalltappend(tselftptx((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt_mkpaths$cGstj|j|dS(N(RtmkdirR(Rtdirname((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytsubdirscGst|j|dS(Ntwb(topenR(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytsubfile#scCs2tj|_tjj|j}|_|g|_tj||j	d|j
d}|j|j|j
|j
dd}|j|j|j
|j	d|j
dd}|j
|j
dd}|j
|j
dd}|j
tj||_tjd|_dS(	Ntsub1tfile1tfile2tsub3s
file3.ext1s
file3.ext2s
file3.ext3t/(ttimetnowRR	R
tmktempRR
RRRtwritet	f1contenttcloset	f2contentRtFilePathtroot(RRtf((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytsetUp's(







cCsG|j|jjdjdjdj|jdddgdS(sV
        Verify that the segments between two paths are correctly identified.
        tatbtcN(tassertEqualR	tchildtsegmentsFrom(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_segmentsFromPositive>s-cCsV|jt|jjdjdjdj|jjdjdjddS(sNVerify that segmentsFrom notices when the ancestor isn't an ancestor.
        R)R*R+tdteN(tassertRaisest
ValueErrorR	R-R.(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_segmentsFromNegativeFs$cCsHg|jjD]}|j^q}|jt|t|jdS(si
        Verify that walking the path gives the same result as the known file
        hierarchy.
        N(R	twalkR,RR
(RtfooR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt	test_walkOs%cCsg}|jjdjdjd}|j}|}tjj|}x;||jjkr|j||}tjj|}qNW|jg|jD]}|j^q|dS(s{
        L{FilePath.parents()} should return an iterator of every ancestor of
        the L{FilePath} in question.
        R)R*R+N(R	R-RRR&RR,tparents(RtLtpathobjtfullpathtlastpathtthispathR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_parentsXs$	
cCs|jjd}|j|jd|j|jd|j|jd|j|jd|j|jdgdS(sVerify that a valid subdirectory will show up as a directory, but not as a
        file, not as a symlink, and be listable.
        RsThis directory does exist.sIt's a directory.RN(	R	R-t
failUnlesstexiststisdirtisfiletislinkR,tlistdir(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_validSubdiriscCs,|jjd}|j|jddS(sT
        Verify that a subdirectory that doesn't exist is reported as such.
        tsub2sThis directory does not exist.N(R	R-tfailIfR@(RRF((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_invalidSubdirzscCso|jjd}|j|jj|j|jjdjd}|j|jj|jdS(sF
        Make sure that we can read existent non-empty files.
        RRRN(R	R-R,RtreadR"R$(Rtf1tf2((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_validFilesscCsS|jjdddg}|jjdjdjd}|j||dS(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,(Rtmultipletsingle((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_multipleChildSegmentss$cCs|jjd}|jjd}|jjd}i}d||<d||<|j||d|j|j|g|j|jd||j|jd|d||<|j||d|jt|ddS(	sK
        Verify that path instances are usable as dictionary keys.
        RRiiiiiN(R	R-R,tkeystassertIdenticaltassertNotIdenticaltlen(RRJtf1primeRKtdictoid((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_dictionaryKeyss


cCsF|jjd}id|6}d||j<|jt|ddS(s
        Verify that path instances are usable as dictionary keys which do not clash
        with their string counterparts.
        RthellotgoodbyeiN(R	R-R,RT(RRJRV((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_dictionaryKeyWithStrings

cCs&|jtj|jjdjdS(sm
        Verify that children raises the appropriate exception for non-existent
        directories.
        snot realN(R2RtUnlistableErrorR	R-tchildren(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_childrenNonexistentErrorscCs&|jtj|jjdjdS(s
        Verify that listdir raises the appropriate exception for attempting to list
        a file rather than a directory.
        RN(R2RR[R	R-R\(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_childrenNotDirectoryErrorscCs~xw|j|jjdfD]Z}|jt|jt|jt|jt|jt|jtqWdS(s
        Verify that all times returned from the various new time functions are ints
        (and hopefully therefore 'high precision').
        RN(R	R-R,ttypet
getAccessTimetfloattgetModificationTimetgetStatusChangeTime(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_newTimesAreFloatss"cCs~xw|j|jjdfD]Z}|jt|jt|jt|jt|jt|jtqWdS(sy
        Verify that all times returned from the various time functions are
        integers, for compatibility.
        RN(R	R-R,R_tgetatimetinttgetmtimetgetctime(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_oldTimesAreIntss"(t__name__t
__module__R"R$RRRR(R/R4R7R>RERHRLRPRWRZR]R^RdRi(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs(													
	
						tFakeWindowsPathcBseZdZdZRS(sV
    A test version of FilePath which overrides listdir to raise L{WindowsError}.
    cCsttddS(s.
        @raise WindowsError: always.
        s0A directory's validness was called into questionN(RR(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRDs(RjRkt__doc__RD(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRlstListingCompatibilityTestscBs)eZdZdZdZdZRS(sU
    These tests verify compatibility with legacy behavior of directory listing.
    cCs?t|j}|jtj|j|jt|jdS(sn
        Verify that when a WindowsError is raised from listdir, catching
        WindowsError works.
        N(RlR R2RR[R\R(Rtfwp((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_windowsErrorExceptscCs,tj|j}|jt|jdS(sr
        Verify that in the normal case where a directory does not exist, we will
        get an OSError.
        N(RR%R R2tOSErrorR\(Rtfp((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_alwaysCatchOSErrorscCstj|j}|jt|j}|jj}|jd|j	jj}|j
|j
|j||dS(s
        Verify that the Unlistable exception raised will preserve the attributes of
        the previously-raised exception.
        toriginalExceptionN(RR%R R2RqR\t__dict__RQtremoveRttsortR,(RRrtosetd1td2((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_keepOriginalAttributess


(RjRkRmRpRsR{(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRns	
		c	Cstj|d}xytj|D]h\}}}xV|D]N}tjj||}tjj||t|d}|j||q8Wq"W|jdS(sI
    create a zipfile on zfname, containing the contents of dirname'
    twiN(	tzipfiletZipFileRR5R	RRTR!R#(	RtzfnametzfR&tignoredtfilestfnametfspathtarcpath((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytzipits
#tZipFilePathTestCasecBs;eZdZdZdZdZdZdZRS(sk
    Test various L{ZipPath} path manipulations as well as reprs for L{ZipPath}
    and L{ZipArchive}.
    cCstj|t|j|jdt|jd|_|j|_g|jD]"}|j|j|jd^qP|_dS(Ns.zip(	RR(RRRR	R&R
treplace(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR(&s

cCs|jjd}dtjj|jdtjdf}|jt|||jjtj	tjddd}t
|}|jd}|jt||dS(s
        Make sure that invoking ZipPath's repr prints the correct class name
        and an absolute path to the zip file.
        R6sZipPath(%r)s.ziptiN(R	R-RR
RtsepR,treprRtgetcwdR(RR-tpathReprtrelativeCommontrelpath((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_zipPathRepr.s()cCsk|jjdjdjd}d|jdtjjddddg}|jt||dS(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.
        R6s..tbarsZipPath(%r)s.zipRN(R	R-RRRRR,R(RR-R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt test_zipPathReprParentDirSegmentCs$*cCse|jjd}|jdtjjddg}d|jdf}|jt||dS(s
        Bytes in the ZipPath path which have special meaning in Python
        string literals are escaped in the ZipPath repr.
        t's.zipRs
ZipPath('%s')s
string-escapeN(	R	R-RRRRtencodeR,R(RR-R	R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_zipPathReprEscapingOs#cCsdtjj|jdf}|jt|j||jjtjtjddd}t	|}|jt||dS(s
        Make sure that invoking ZipArchive's repr prints the correct class
        name and an absolute path to the zip file.
        sZipArchive(%r)s.zipRiN(
RR	R
RR,RRRRR(RRRR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_zipArchiveReprZs
 )(RjRkRmR(RRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR!s				t
ExplodingFilecBs2eZdZeZddZdZdZRS(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}.
    icCs
tdS(s0
        @raise IOError: Always raised.
        N(tIOError(Rtn((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRIwscCs
tdS(s0
        @raise IOError: Always raised.
        N(R(Rtwhat((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR!~scCs
t|_dS(s6
        Mark the file as having been closed.
        N(tTruetclosed(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR#s(RjRkRmtFalseRRIR!R#(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRms
	tTrackingFilePathcBs8eZdZeddZdZdZdZRS(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}
    cCsAtjj||||dkr+g}n||_g|_dS(N(RR%t__init__tNonettrackingListtopenedFiles(RR	talwaysCreateR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs
		cOs,tjj|||}|jj||S(sI
        Override 'open' to track all files opened by this path.
        (RR%RRR(RR)tkR'((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRscCs#g|jD]}|jr
|^q
S(s
        Return a list of all L{TrackingFilePath}s associated with this
        L{TrackingFilePath} that have had their C{open()} method called.
        (RR(RR	((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytopenedPathsscCs)t|d|j}|jj||S(s}
        Override L{filepath.FilePath.clonePath} to give the new path a reference
        to the same tracking list.
        R(RRR(Rtnametclone((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt	clonePathsN(	RjRkRmRRRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs
			tExplodingFilePathcBs/eZdZddZddZdZRS(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.
    cCs5tjj|||dkr(|}n||_dS(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(RR%RRt_originalExploder(RtpathNametoriginalExploder((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs	cCst}|j_|S(s
        Create, save, and return a new C{ExplodingFile}.

        @param mode: Present for signature compatibility.  Ignored.

        @return: A new C{ExplodingFile}.
        (RRRr(RtmodeR'((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRscCst||jS(N(RR(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRsN(RjRkRmRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRstPermissionsTestCasecBsPeZdZddZdZdZdZdZdZ	dZ
RS(	s*
    Test Permissions and RWX classes
    cCso||krk|dkr!d}nt|dkr@|d7}n|jd|t|t|fn|S(s
        Tests that C{first} != C{second} is false.  This method tests the
        __ne__ method, as opposed to L{assertEqual} (C{first} == C{second}),
        which tests the __eq__ method.

        Note: this should really be part of trial
        Ris
sD%snot not unequal (__ne__ not implemented correctly):
a = %s
b = %s
N(RRTtfailureExceptiontpformat(Rtfirsttsecondtmsg((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytassertNotUnequals	
"cCsxttfD]}xyttfD]k}xbttfD]T}tj|||}|j|j||j|j||j|j|q3Wq Wq
Wtjttt}|j|jo|jo|jdS(s>
        L{RWX}'s constructor takes a set of booleans
        N(	RRRtRWXR,RIR!texecutet
assertTrue(RtrR|Rtrwx((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_rwxFromBoolssc	CsxttfD]}xttfD]y}xpttfD]b}|jtj|||tj||||jtj|||tj|||q3Wq Wq
W|jtjttttjttt|jdtjtttdS(s
        L{RWX}'s created with the same booleans are equivalent.  If booleans
        are different, they are not equal.
        iN(RRR,RRRtassertNotEqual(RRR|R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_rwxEqNes"c	Csd}xttfD]}xyttfD]k}xbttfD]T}tj|||}|j|j||d||d||dq<Wq)WqW|jtjtttjddS(s
        L{RWX}'s shorthand string should be 'rwx' if read, write, and execute
        permission bits are true.  If any of those permissions bits are false,
        the character is replaced by a '-'.
        cSs|r
|SdS(Nt-((tvaltletter((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytgetChar.sRR|Rsr-xN(RRRRR,t	shorthand(RRRR|RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_rwxShorthand's	c
	Cs`d}xtddD]}xtddD]}xtddD]}d|||f}t|d}tj|}|j|j||dd||jf|j|j||dd||jf|j|j||d	d
||jfqEWq/WqWtjd}x>dD]6}x-dD]%}	|jt	t	|||	q/Wq"WdS(s
        L{Permissions}'s constructor takes a valid permissions bitmask and
        parsaes it to produce the correct set of boolean permissions.
        cs8fd}tjgdD]}|||^qS(Ncs!ttd||f@dkS(NsS_I%s%si(tgetattrtstat(Rtwho(tstatModeInt(s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytgetPermissionBitDstRtWtX(RRR(RR(RRRR((Rs;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt_rwxFromStatCs	iis%d%d%dtUSRs%s: got user: %stGRPs%s: got group: %stOTHs%s: got other: %situsertgrouptotherRIR!RN(susersgroupsother(sreadswritesexecute(
trangeRfRtPermissionsR,RRRRR(
RRtutgtotchmodStringtchmodValtpermRR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_permissionsFromStat>s.	

cCs|jtjdtjd|jtjdtjd|jtjdtjd|jdtjddS(sd
        Two L{Permissions}'s that are created with the same bitmask
        are equivalent
        iiiN(R,RRRR(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_permissionsEqbsc
CsxtddD]}xtddD]}}xttddD]c}tjtd|||f}|j|jdjd|j|j|j	fDq<Wq&WqW|jtjdjddS(	s
        L{Permissions}'s shorthand string is the RWX shorthand string for its
        user permission bits, group permission bits, and other permission bits
        concatenated together, without a space.
        iis0%d%d%dRcss|]}|jVqdS(N(R(t.0R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pys	<genexpr>{sis	rwxrwx---N(
RRRtevalR,RRRRR(RRRRR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_permissionsShorthandps",N(RjRkRmRRRRRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs				$	tFilePathTestCasecBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZeeddBsdZee_ee_ee_ndZdZdZdZdZdZej dkr/de_ndZ!ej dkrVde!_ndZ"dZ#dZ$d Z%d!Z&d"Z'd#Z(d$Z)d%Z*d&Z+d'Z,d(Z-d)Z.d*Z/d+Z0d,Z1d-Z2d.d/Z3d0Z4d1Z5d2Z6d3Z7d4Z8d5Z9d6Z:d7Z;d8Z<d9Z=d:Z>d;Z?d<Z@d=ZAd>ZBd?ZCd@ZDdAZEejFreGeD_eGeE_eGe@_neGeC_eGeA_RS(Cs6
    Test various L{FilePath} path manipulations.
    cCsbx[dD]S}|jjdj||jtjtj|jjdjj|qWdS(s
        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).
        imiRN(imi(R	R-tchmodR,RtS_IMODERtst_mode(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt
test_chmods

'cCs>ttdddkr*tjdntj||dS(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.
        tsymlinks)Platform does not support symbolic links.N(RRRRtSkipTestR(RttargetR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs	cCs|jjd}|j|j|jd|j|jdj|jd|j|jdj|jdddS(sI
        Create several symbolic links to files and directories.
        Rs	sub1.linkRs
file2.linkssub1.file2.linkN(R	R-RR(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytcreateLinkss
%cCss|j|j|jjdj|jjdj|j|jjdj|jjdjddS(sd
        L{FilePath.realpath} returns the path of the ultimate target of a
        symlink.
        s
file2.links	link.linkRRN(RRR	R-R,trealpath(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_realpathSymlinks

cCs|j|jjdj|jjdj|j|jjdj|jjdj|jtj|jjdjdS(s
        L{FilePath.realpath} raises L{filepath.LinkError} if the path is a
        symbolic link which is part of a cycle.
        tlink1tlink2N(RR	R-R2Rt	LinkErrorR(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_realpathCyclicalSymlinks..cCs2|j|jjdj|jjddS(sj
        L{FilePath.realpath} returns the path itself if the path is not a
        symbolic link.
        RN(R,R	R-R(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_realpathNoSymlinkscsgjjjjdjjjdjdjfd}jtj|dS(sT
        Verify that walking a path with a cyclical symlink raises an error
        Rssub1.loopylinkcs#gjjD]}|j^qS(N(R	R5(R6(R(s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytiterateOverPathsN(RRR	R-R2RR(RR((Rs;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_walkCyclicalSymlinks

cspjjjjdjjjdjdjdfd}j|dS(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.
        Rssub1.loopylinkcSs|jS(N(RC(R	((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt
noSymLinksscs)gjjdD]}|j^qS(Ntdescend(R	R5(R6(RR(s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRsN(RRR	R-R(RR((RRs;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt)test_walkObeysDescendWithCyclicalSymlinkss
	cCsa|jd}g|jjd|D]}|j^q)}|jt|t|jdS(s{
        Verify that when the supplied C{descend} predicate returns C{False},
        the target is not traversed.
        cSs|jS(N(RC(R	((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRsRN(RR	R5R,RR
(RRR6R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_walkObeysDescends
	+cCsd}|jjdj||jjdj}|j||d}|jjdj|d|jjdj}|j||dS(Nt
newcontenttnewtcontents.tmp(R	R-t
setContentt
getContentR,(RRR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_getAndSetscCs6td}|jt|j|j|jjdS(s
        If reading from the underlying file raises an exception,
        L{FilePath.getContent} raises that exception after closing the file.
        RN(RR2RRRRrR(RRr((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_getContentFileClosingscCs9td}|jt|jd|j|jjdS(s
        If writing to the underlying file raises an exception,
        L{FilePath.setContent} raises that exception after closing the file.
        RtblahN(RR2RRRRrR(RRr((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_setContentFileClosingscCsjt|j}|jd|jd|j}|jt|d|j|d|ddS(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.
        talphatbetaiiiN(RR RRR,RTtassertNotEquals(RRrtopenedSiblings((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_setContentNameCollisions

cCst|j}|jd|j}|jt|d|j|djjdd|dj|jdd|j}|jt|d|j|djjdd	|djd
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.
        RXiis.news-%s does not end with default '.new' extensionRYs-something-elseis.%s does not end with -something-else extensionN(	RR RRR,RTRtbasenametendswith(RRrtopened((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_setContentExtension&s
cCs|jjd}|jjd}|j|j|j|j|j|j|j|j|j|j|jdS(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.
        tsub4RN(R	R-RRRCtassertFalseRA(Rts4ts3((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_symbolicLink;scCs|jjd|jjdf|jjdjd|jjdfg}xo|D]g\}}|j||j|jd|j|j|j|j|j|jqXWdS(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.
        RFs	sub2.links
file3.ext1sfile3.ext1.linksThis is a linkN(R	R-tlinkToRRCR,RARB(RttargetLinksRtlink((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_linkToJs!
cCsr|jt|jjdj|jjdjd|jt|jjdj|jjdjddS(s
        Verify C{linkTo} fails in the following case:
            - the target is in a directory that doesn't exist
            - the target already exists
        RtnosubRRN(R2RqR	R-R(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_linkToErrors\sRs.Your platform does not support symbolic links.cCs|jjdjd}d	}|j|j||jd}|j|j|j|j|j|jdj|j|j|j|dS(
NRtfile3s.foos.bartext1text2text3t*(s.foos.barRRR(R	R-RGtsiblingExtensionSearchtsiblingExtensionttouchR@Rv(Rtf3textstf3e((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestMultiExtos

cCs9tjd}|jd|jtj|jddS(Nt.sfoo/bars/foo(RR%tpreauthChildR2tInsecurePathR-(RRr((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestPreauthChildzs
cCsn|jjd}|j|j|jd|jt|jtjdd|jt|jtjdd|jt|j	tjdd|j|j
t|j|j
ttj
|j|j|j
t|jdt|j|j
t|j|jt|j|jt|j|jtdS(Ntstattestiitreraise(R	R-RR,tgetsizetabsRgRRhReR@RRRvtrestatRRCRARB(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt
testStatCaches
***cCsQtjtj|j}|j|jj|j|j|jj|jdS(N(tpickletloadstdumpsR	R,t	__class__(Rtnewpath((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestPersistscCsX|jtj|jjd|jtj|jjd|jtj|jjddS(Ns..s/etcs../..(R2RR R	R-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestInsecureUNIXscCs<|jtj|jjd|jtj|jjddS(Ns..\..sC:randomfile(R2RR R	R-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestInsecureWin32stwin32sConsider yourself lucky.cCsX|jtj|jjd|jtj|jjd|jtj|jjddS(sWindows 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.
        tCONsC:CONsC:\CONN(R2RR R	R-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestInsecureWin32WhackyscCss|jtjdtjd|jtjdtjdk|jtjdtjdk|jtjdtjdk|jtjdtjdk|jtjdtjdk|jtjdtjdk|jtjdtjdk|jtjdtjdk|jtjdtjdkdS(NR)tz(R,RR%R?RG(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestComparisons(cCs&|jtj|jjddgdS(st
        If C{".."} is in the sequence passed to L{FilePath.descendant},
        L{InsecurePath} is raised.
        R)s..N(R2RR R	RM(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_descendantOnlyscCsz|jjd}|jd}|j|j|j|j|jd|j|j||jjdS(Nt
sibling_starttsibling_test(	R	R-tsiblingR,RRtcreateDirectorytassertInR\(RRtts((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestSiblings
cCsz|jj}|j|j|jj|j|j|jj|j|j||jj	j
dS(N(R	ttemporarySiblingR,RtassertNotInRRDR9R:tparentR\(RR;((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestTemporarySiblings

cCsKd}|jj|}|j|jj|d|j|fdS(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=RRR(Rt
testExtensionR;((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_temporarySiblingExtensions
cCs'|jj|j|jjdS(s~
        L{FilePath.remove} on a L{FilePath} that refers to a directory will
        recursively delete its contents.
        N(R	RvRGR@(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_removeDirectorys
cCst|jjd}|j|jjdj|j|j|j|j|j|jjdjdS(sx
        For a path which is a symbolic link, L{FilePath.remove} just deletes
        the link, not the target.
        s	sub1.linkRN(R	R-RRvRR@R(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_removeWithSymlinks
"
cCst|jj}tj|j}|jj||jj|j|jt|jj}|j|j|j	||dS(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(
tlistR	R5RR%R tcopyToRvRwR,(RtoldPathsRrtnewPaths((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_copyToDirectorys


cCs]|jjd}d|_t|j}|jt|j||j|j	j
dS(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}.
        tnotherecSstS(N(R(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt<lambda>sN(R	R-RBRR R2RRFRRrR(Rtnosuchtdestination((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt!test_copyToMissingDestFileClosings
cCs^t|j}tt}|jt|j||j|jj|j|jjdS(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(	RR t__file__R2RRFRRrR(RRMtsource((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_copyToFileClosing's
cCs/|jttf|jj|jjddS(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.
        RN(R2RqRR	RFR-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_copyToDirectoryItself4scCs|j|jjdj|jjdjtj|j}|jj||j|jdj|j	g|jdj
D]}|j^qg|jdj
D]}|j^qdS(sn
        Verify that copying with followLinks=True copies symlink targets
        instead of symlinks
        RRN(RR	R-RR%R RFRRCR,R\R(RRrR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_copyToWithSymlink>s1cCs|jd|jjdjtj|j}|jj|dt|j|jdj	|j
tj|jjdjtj|jdjdS(sX
        Verify that copying with followLinks=False copies symlinks as symlinks
        RRtfollowLinksN(
RR	R-RR%R RFRRRCR,Rtreadlink(RRr((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_copyToWithoutSymlinkLs!cCsGtj|j}|jt|jd}|j|jtjdS(sV
        If the source path is missing, L{FilePath.copyTo} raises L{OSError}.
        ssome other pathN(	RR%R R2RqRFR,terrnotENOENT(RR	texc((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_copyToMissingSourceXscCst|jj}tj|j}|jj||j|jt|jj}|j|j|j||dS(sv
        Verify that moving an entire directory results into another directory
        with the same content.
        N(	RER	R5RR%R tmoveToRwR,(RRGRrRH((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_moveToas

cCstj|j}tj|j}|j|j|jt|j|jt|j||j|jt|j|jtdS(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(	RR%R RR,R@RRR[(RRrtfp2((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_moveToExistsCacheps

cCs|j|jdS(sp
        The assertion of test_moveToExistsCache should hold in the case of a
        cross-mount move.
        N(tsetUpFaultyRenameR^(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt test_moveToExistsCacheCrossMounts
cCsdS(N(R(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRKscCstj|j}tj|j}|jd|jd||j|jd|j|jdtj|j|j|jd|j	||j|jddS(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.
        t1234t
1234567890ii
N(
RR%R RR,R$RRvR	R[(RthookRrR]((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_moveToSizeCaches


cCs|jd|jdS(sn
        The assertion of test_moveToSizeCache should hold in the case of a
        cross-mount move.
        RcN(RdR_(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_moveToSizeCacheCrossMountscCs/|jttf|jj|jjddS(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.
        RN(R2RqRR	R[R-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_moveToErrorscs8gfd}tj|jtd|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}
        csGj||ftdkr:ttjdn||S(Nis;Test-induced failure simulating cross-device rename failure(RRTRqRWtEXDEV(tsrctdest(tinvokedWithtoriginalRename(s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pytfaultyRenamestrename(RRmtpatch(RRl((RkRjs;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR_s
	cCs'|j}|j|j|dS(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(RRj((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_crossMountMoveTos
cCs|j}|jjd}|jjd}|j|jjdj|j|j||j|j|j|jd|j	|dS(s
        By default, when moving a symlink, it should follow the link and
        actually copy the content of the linked node.
        RRRsfile 1N(
R_R	R-RR[RRCR,RR(RRjRKR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt test_crossMountMoveToWithSymlinks"
cCs|j}|jjd}|jjd}|j|jjdj|j|j|dt|j|j|j|j	d|j|dS(sk
        Verify that moveTo called with followLinks=False actually create
        another symlink.
        RRRRTsfile 1N(
R_R	R-RR[RRRCR,R(RRjRKR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt#test_crossMountMoveToWithoutSymlinks"cCsztj|j}|j}|jd|jk|jd|jt|j	dj
}|j|ddS(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
trbN(RR%R tcreateR?RR!R#RR	RIR,(RR	R'RI((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_createBinaryModes	

cCs|jjd}|jt|j}|j|jtj|jjd}|jd}|jd|j	|j}|j|j
d|j	|jd}|j	|j}|j|j
d|j	|jjd}|jd}|jd|j	|jd}|jd	|j	|jd
}|j|j
d|j	|jd}|j|j
d|jd
d|jd|j	|jd
}|j|j
d|j	|jd}|j|j
d|jd
d|jd|j	|jd}|jd|jd
d|j|j
d|jd
d
|j|j
d|j	|jt
|jdj	|}~|jttf|jdS(NtnonexistenttwriterR|sabc
defRtappendertabcR)tdefRtabcdefsr+iitghit	abcdefghisw+t123sa+t456t123456(R	R-R2RRR,RWRXR!R#RItseekt
requireCreateRRq(RRuR1RvR'Rwtexistent((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestOpensd

















cCsL|jjd}|jd}|jd|j|j|jdS(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.
        sexplicit-binaryRsabc
defN(R	R-RR!R#RR@(RRvtfile((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_openWithExplicitBinaryModems
	

cCsL|jjd}|jd}|jd|j|j|jdS(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.
        smultiple-binarytwbbsabc
defN(R	R-RR!R#RR@(RRvR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt)test_openWithRedundantExplicitBinaryModes}s



cCsOtj|j}|j|jt|j|j|jtdS(s
        Check that C{filepath.FilePath.exists} correctly restat the object if
        an operation has occurred in the mean time.
        N(RR%R R,R@RtmakedirsR(RRr((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_existsCaches
cCstj|j}|jd|j|jdt|jd}|jd|j	|j|jd|j
|j|jd|j|jddS(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}.
        t12345iRt12345678iN(
RR%R RR,R$RR	R!R#tchangedtstatinfoR(RRrtfObj((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_changeds



cCsxRdD]J}|jjdj||j|jjdjtj|qW|jjdjd|j|jjdjjddS(s
        Getting permissions for a file returns a L{Permissions} object for
        POSIX platforms (which supports separate user, group, and other
        permissions bits.
        iiRis	rwxrw-r--N(ii(R	R-RR,tgetPermissionsRRR(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_getPermissions_POSIXs
!cCsxRdD]J}|jjdj||j|jjdjtj|qW|jjdjd|j|jjdjjddS(sJ
        Getting permissions for a file returns a L{Permissions} object in
        Windows.  Windows requires a different test, because user permissions
        = group permissions = other permissions.  Also, chmod may not be able
        to set the execute bit, so we are skipping tests that set the execute
        bit.
        iimRiIs	r-xr-xr-xN(iim(R	R-RR,RRRR(RR((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_getPermissions_Windowss
!cCs0|j|jj|j|jjdS(s=
        Ensure that a file is not a block or socket
        N(RR	t
isBlockDevicetisSocket(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_whetherBlockOrSocketscCsr|jt|jj|jt|jj|jt|jj|jt|jj|jt|jjdS(sM
        Verify that certain file stats are not available on Windows
        N(R2tNotImplementedErrorR	tgetInodeNumbert	getDevicetgetNumberOfHardLinkst	getUserIDt
getGroupID(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt(test_statinfoBitsNotImplementedInWindowss
cCs|jjd}x|j|fD]t}|j|jt|j|jt|j|jt|j|jt|j|j	tq"W|j
|jj|j|j
|jj	|j	dS(so
        Verify that file inode/device/nlinks/uid/gid stats are numbers in
        a POSIX environment
        RN(R	R-tassertIsInstanceRtlongRRRfRRR,(RR+R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_statinfoBitsAreNumbersscsdddY}|fd}|j_dj_jjjjjjjjjjj	j
jjjjjjj
jdS(s
        Verify that the right numbers come back from the right accessor methods
        for file inode/device/nlinks/uid/gid (in a POSIX environment)
        tFakeStatcBs&eZdZdZdZdZdZRS(ii,iiiX(RjRktst_inotst_devtst_nlinktst_uidtst_gid(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs
csj_dS(N(R	R(targstkwargs(tfakeR(s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt
fakeRestatsN((R	R&RRR,RRRRRRRRRR(RRR((RRs;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttest_statinfoNumbersAreValids	N(HRjRkRmRRRRRRRRRRRRRRRRRRRRtskipMsgtskipRR!R'R-R.R/RtgetTypeR2R4R5R<R@RBRCRDRIRNRQRRRSRVRZR\R^R`RdReRfR_RoRpRqRtRRRRRRRRRRRt	isWindowsR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyRs	
											
	
														
									
			
	
								 									Y													(turlpathtURLPathTestCasecBs>eZdZdZdZdZdZdZRS(cCstjjd|_dS(Ns/http://example.com/foo/bar?yes=no&no=yes#footer(RtURLPatht
fromStringR	(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR(!scCs|jt|jddS(Ns/http://example.com/foo/bar?yes=no&no=yes#footer(R,tstrR	(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestStringConversion$scCsQ|jt|jjdd|jt|jjdjdddS(NRXs http://example.com/foo/bar/helloRs!http://example.com/foo/bar/hello/(R,RR	R-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestChildString's"cCsQ|jt|jjdd|jt|jjdjdddS(Ntbazshttp://example.com/foo/bazRshttp://example.com/foo/bar/baz(R,RR	R8R-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestSiblingString+s"cCs|jt|jjd|jt|jjdjd|jt|jjdjd|jt|jjjjjjddS(Nshttp://example.com/Rshttp://example.com/foo/R(R,RR	R?R-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestParentString4s((cCsK|jt|jjd|jt|jjdjddS(Nshttp://example.com/foo/Rshttp://example.com/foo/bar/(R,RR	thereR-(R((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyttestHereString<s(RjRkR(RRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyR s						("RmRRR(RWR}Rttwisted.python.compatRttwisted.python.win32RRttwisted.pythonRttwisted.python.zippathRttwisted.python.runtimeRt
twisted.trialRtTestCaseRR%RlRnRRRRRRRRR(((s;/usr/lib/python2.7/dist-packages/twisted/test/test_paths.pyt<module>s,H(	L 6+