%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/test/__pycache__/test_paths.cpython-312.pyc

�

Ϫ�f�&���dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZmZmZmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZmZddl m!Z!ddl"m#Z#dd
l$m%Z&e!jN�Z(Gd�de&�Z)Gd�de)�Z*Gd�dejVe�Z,ejBdk7r
Gd�d�Z-Gd�de)�Z.Gd�d�Z/Gd�dejVe�Z0Gd�dejVe�Z1ed�Z2Gd �d!e)�Z3Gd"�d#e*�Z4Gd$�d%e)�Z5Gd&�d'e&�Z6y)(z1
Test cases covering L{twisted.python.filepath}.
�)�annotationsN)�pformat)	�IO�AnyStr�Callable�Dict�List�Optional�Tuple�TypeVar�Union)�skipIf)�verifyObject)�NoReturn)�filepath)�FileMode�OtherAnyStr)�platform)�ERROR_DIRECTORY)�SynchronousTestCasec��eZdZdZdd�Zy)�
BytesTestCasezH
    Override default method implementations to support byte paths.
    c�J�tj|�jd�S)z<
        Return a temporary path, encoded as bytes.
        �utf-8)�TestCase�mktemp�encode��selfs �9/usr/lib/python3/dist-packages/twisted/test/test_paths.pyrzBytesTestCase.mktemp's�����t�$�+�+�G�4�4�N)�return�bytes)�__name__�
__module__�__qualname__�__doc__r�r!r rr"s���5r!rc��eZdZdZdZdZdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zdd�Z
dd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zy)�AbstractFilePathTestsz1
    Tests for L{IFilePath} implementations.
    �file 1sfile 2c���tjjtjj|jg|����}|j
j
|�|S�N)�os�path�abspath�join�cmn�all�append)r�p�xs   r �_mkpathzAbstractFilePathTests._mkpath6s?���G�G�O�O�B�G�G�L�L����6�A�6�7����������r!c�H�tj|j|��yr-)r.�mkdirr7�r�dirnames  r �subdirzAbstractFilePathTests.subdir;s��
�������w�'�(r!c�4�t|j|�d�S)N�wb)�openr7r:s  r �subfilezAbstractFilePathTests.subfile>s���L�D�L�L�'�*�D�1�1r!c�J�tj�|_tjj	|j��x}|_|g|_tj|�|jd�|jd�5}|j|j�ddd�|jdd�5}|j|j�ddd�|jd�|jdd�j�|jdd�j�|jdd�j�tj |�|_tj d�|_y#1swY��xYw#1swY��xYw)	N�sub1�file1�file2�sub3�
file3.ext1s
file3.ext2s
file3.ext3�/)�time�nowr.r/r0rr2r3r9r<r@�write�	f1content�	f2content�closer�FilePath�root)rr2�fs   r �setUpzAbstractFilePathTests.setUpAs+���9�9�;������������7�7��d�h��5���
����
����G��
�\�\�(�
#�	$�q�
�G�G�D�N�N�#�	$�
�\�\�'�8�
,�	$��
�G�G�D�N�N�#�	$����G�����W�m�,�2�2�4����W�m�,�2�2�4����W�m�,�2�2�4��%�%�c�*��	��%�%�d�+��	�	$�	$��	$�	$�s�
F
�F�
F�F"c�j�|jttj|j��y)zO
        Instances of the path type being tested provide L{IFilePath}.
        N)�
assertTruerr�	IFilePathr/rs r �test_verifyObjectz'AbstractFilePathTests.test_verifyObjectRs!��	
����X�%7�%7����C�Dr!c���|j|jjd�jd�jd�j|j�gd��y)zV
        Verify that the segments between two paths are correctly identified.
        �a�b�c�rWrXrYN)�assertEqualr/�child�segmentsFromrs r �test_segmentsFromPositivez/AbstractFilePathTests.test_segmentsFromPositiveXsJ��	
����I�I�O�O�D�!�'�'��-�3�3�D�9�F�F�t�y�y�Q��	
r!c�"�|jt|jjd�jd�jd�j|jjd�jd�jd��y)zW
        Verify that segmentsFrom notices when the ancestor isn't an ancestor.
        rWrXrY�d�eN)�assertRaises�
ValueErrorr/r\r]rs r �test_segmentsFromNegativez/AbstractFilePathTests.test_segmentsFromNegativeasg��	
�����I�I�O�O�D�!�'�'��-�3�3�D�9�F�F��I�I�O�O�D�!�'�'��-�3�3�D�9�	
r!c���|jj�D�cgc]}|j��}}|jt|�t|j��ycc}w)zi
        Verify that walking the path gives the same result as the known file
        hierarchy.
        N)r/�walkr[�setr3)r�foor6s   r �	test_walkzAbstractFilePathTests.test_walkksG��
"&�����!1�2�#�S�X�X�2��2�����Q���T�X�X��/��
3s�A!c��g}|jjd�jd�jd�}|j}|}tjj|�}||jjk7rL|j|�|}tjj|�}||jjk7r�L|j
|j�D�cgc]}|j��c}|�ycc}w)z{
        L{FilePath.parents()} should return an iterator of every ancestor of
        the L{FilePath} in question.
        rWrXrYN)r/r\r.r;rOr4r[�parents)r�L�pathobj�fullpath�lastpath�thispathr6s       r �test_parentsz"AbstractFilePathTests.test_parentsss���

���)�)�/�/�$�'�-�-�d�3�9�9�$�?���<�<�����7�7�?�?�8�,���$�)�)�.�.�(�
�H�H�X���H��w�w���x�0�H��$�)�)�.�.�(�	
���'�/�/�*;�<�Q�!�&�&�<�a�@��<s�+Dc�|�|jjd�}|j|j�d�|j|j	�d�|j|j
�d�|j|j�d�|j|j�dg�y)z�
        Verify that a valid subdirectory will show up as a directory, but not as a
        file, not as a symlink, and be listable.
        rBzThis directory does exist.zIt's a directory.rDN)
r/r\rS�exists�isdir�assertFalse�isfile�islinkr[�listdir)r�sub1s  r �test_validSubdirz&AbstractFilePathTests.test_validSubdir�s���
�y�y���w�'��������
�'C�D�����
�
��&9�:��������(;�<��������(;�<��������(��4r!c�z�|jjd�}|j|j�d�y)zT
        Verify that a subdirectory that doesn't exist is reported as such.
        �sub2zThis directory does not exist.N)r/r\rurs)r�sub2s  r �test_invalidSubdirz(AbstractFilePathTests.test_invalidSubdir�s-���y�y���w�'���������(H�Ir!c���|jjd�}|j�5}|j|j	�|j
�ddd�|jjd�jd�}|j�5}|j|j	�|j�ddd�y#1swY�wxYw#1swYyxYw)zF
        Make sure that we can read existent non-empty files.
        rCNrBrD)r/r\r?r[�readrKrL)r�f1rP�f2s    r �test_validFilesz%AbstractFilePathTests.test_validFiles�s����Y�Y�_�_�X�
&��
�W�W�Y�	7�!����Q�V�V�X�t�~�~�6�	7�
�Y�Y�_�_�W�
%�
+�
+�H�
5��
�W�W�Y�	7�!����Q�V�V�X�t�~�~�6�	7�	7�	7�	7��	7�	7�s�+C
�+C�
C�C"c���|jjgd��}|jjd�jd�jd�}|j||�y)z�
        C{fp.descendant([a, b, c])} returns the same L{FilePath} as is returned
        by C{fp.child(a).child(b).child(c)}.
        rZrWrXrYN)r/�
descendantr\r[)r�multiple�singles   r �test_multipleChildSegmentsz0AbstractFilePathTests.test_multipleChildSegments�sQ��
�9�9�'�'�(:�;��������&�,�,�T�2�8�8��>������6�*r!c�V�|jjd�}|jjd�}|jjd�}i}d||<d||<|j||d�|jt|j	��|g�|jt|j	��d|�|j
t|j	��d|�d||<|j||d�|jt|�d�y)	zK
        Verify that path instances are usable as dictionary keys.
        rCrD��r��N)r/r\r[�list�keys�assertIs�assertIsNot�len)rr��f1primer��dictoids     r �test_dictionaryKeysz)AbstractFilePathTests.test_dictionaryKeys�s����Y�Y�_�_�X�
&���)�)�/�/�(�+��
�Y�Y�_�_�X�
&������������������a�(�����g�l�l�n�-��t�4��
�
�d�7�<�<�>�*�1�-�r�2�����g�l�l�n�-�a�0�'�:�����������a�(�����W��q�)r!c��|jjd�}|di}d||j<|jt|�d�y)z�
        Verify that path instances are usable as dictionary keys which do not clash
        with their string counterparts.
        rC�hello�goodbyer�N)r/r\r[r�)rr�r�s   r �test_dictionaryKeyWithStringz2AbstractFilePathTests.test_dictionaryKeyWithString�sA��
�Y�Y�_�_�X�
&��FH�'�]��$����������W��q�)r!c��|jtj|jj	d�j
�y)zm
        Verify that children raises the appropriate exception for non-existent
        directories.
        snot realN�rbr�UnlistableErrorr/r\�childrenrs r �test_childrenNonexistentErrorz3AbstractFilePathTests.test_childrenNonexistentError�s0��
	
����$�$�d�i�i�o�o�k�&B�&K�&K�	
r!c��|jtj|jj	d�j
�y)z�
        Verify that listdir raises the appropriate exception for attempting to list
        a file rather than a directory.
        rCNr�rs r �test_childrenNotDirectoryErrorz4AbstractFilePathTests.test_childrenNotDirectoryError�s-��
	
���(�2�2�D�I�I�O�O�H�4M�4V�4V�Wr!c�j�|j|jjd�fD]�}|jt|j	��t
�|jt|j
��t
�|jt|j��t
���y)z�
        Verify that all times returned from the various new time functions are ints
        (and hopefully therefore 'high precision').
        rCN)r/r\r[�type�
getAccessTime�float�getModificationTime�getStatusChangeTime�rr5s  r �test_newTimesAreFloatsz,AbstractFilePathTests.test_newTimesAreFloats�s���
���D�I�I�O�O�H�5�5�	C�A����T�!�/�/�"3�4�e�<����T�!�"7�"7�"9�:�E�B����T�!�"7�"7�"9�:�E�B�	Cr!c�j�|j|jjd�fD]�}|jt|j	��t
�|jt|j
��t
�|jt|j��t
���y)zy
        Verify that all times returned from the various time functions are
        integers, for compatibility.
        rCN)r/r\r[r��getatime�int�getmtime�getctimer�s  r �test_oldTimesAreIntsz*AbstractFilePathTests.test_oldTimesAreInts�sz��
���D�I�I�O�O�H�5�5�	6�A����T�!�*�*�,�/��5����T�!�*�*�,�/��5����T�!�*�*�,�/��5�	6r!N)r5r#r"r#)r;r#r"�None)r;r#r"zio.BufferedWriter�r"r�)r$r%r&r'rKrLr7r<r@rQrUr^rdrirqrzr~r�r�r�r�r�r�r�r�r(r!r r*r*.sw����I��I��
)�2�,�"E�
�
�0�A� 
5�J�	7�+�*�$*�
�X�C�6r!r*c��eZdZdZdd�Zy)�FakeWindowsPathzV
    A test version of FilePath which overrides listdir to raise L{WindowsError}.
    c�:�tdd|jt��)z.
        @raise WindowsError: always.
        Nz0A directory's validness was called into question)�OSErrorr/rrs r rxzFakeWindowsPath.listdir�s!����>��I�I��	
�	
r!N)r"zList[AnyStr])r$r%r&r'rxr(r!r r�r��s���
r!r��win32c��eZdZy)�WindowsErrorN)r$r%r&r(r!r r�r�s��r!r�c�`�eZdZdZeej�d�dd��Zdd�Zdd�Z	y)�ListingCompatibilityTestszU
    These tests verify compatibility with legacy behavior of directory listing.
    zOnly relevant on on Windows.c���t|j��}|jtj|j
�|jt|j
�y)zn
        Verify that when a WindowsError is raised from listdir, catching
        WindowsError works.
        N)r�rrbrr�r�r�)r�fwps  r �test_windowsErrorExceptz1ListingCompatibilityTests.test_windowsErrorExceptsB���d�k�k�m�,�����(�2�2�C�L�L�A����,����5r!c��tj|j��}|jt|j
�y)zr
        Verify that in the normal case where a directory does not exist, we will
        get an OSError.
        N)rrNrrbr�r��r�fps  r �test_alwaysCatchOSErrorz1ListingCompatibilityTests.test_alwaysCatchOSErrors.��
�
�
�t�{�{�}�
-�����'�2�;�;�/r!c��tj|j��}|jt|j
�}t
|jj��}|jd�t
|jjj��}|j�|j�|j||�y)z�
        Verify that the Unlistable exception raised will preserve the attributes of
        the previously-raised exception.
        �originalExceptionN)
rrNrrbr�r�r��__dict__r��remover��sortr[)rr��ose�d1�d2s     r �test_keepOriginalAttributesz5ListingCompatibilityTests.test_keepOriginalAttributes"s���
�
�
�t�{�{�}�
-���������5��
�#�,�,�#�#�%�
&��
�	�	�%�&�
�#�'�'�0�0�5�5�7�
8��
���	�
���	�����R� r!Nr�)
r$r%r&r'rr�	isWindowsr�r�r�r(r!r r�r�s=����"��"�"�$�$�&D�E�6�F�6�0�!r!r�c�>�eZdZdZdZd	d
d�Zdd�Zdd�Zd
d�Zdd�Z	y)�
ExplodingFilez�
    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}.
    Fc��t���z0
        @raise IOError: Always raised.
        �r�)r�ns  r r�zExplodingFile.read<����i�r!c��t��r�r�)r�whats  r rJzExplodingFile.writeBr�r!c��d|_y)z6
        Mark the file as having been closed.
        TN)�closedrs r rMzExplodingFile.closeHs����r!c��|Sr-r(rs r �	__enter__zExplodingFile.__enter__Ns���r!c�$�|j�yr-)rM)r�exc_type�	exc_value�	tracebacks    r �__exit__zExplodingFile.__exit__Qs���
�
�r!N)r)r�r�r"r)r�r#r"rr�)r"r�)r��objectr�r�r�r�r"r�)
r$r%r&r'r�r�rJrMr�r�r(r!r r�r�1s'����F�����r!r�c�X�eZdZdZ		d							dd�Zd	d
d�Z		dd�Z	d					d
d�Zy)�TrackingFilePathac
    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}
    Nc�j�tjj|||�|�g}||_g|_yr-)rrN�__init__�trackingList�openedFiles)rr/�alwaysCreater�s    r r�zTrackingFilePath.__init__gs>��	���"�"�4��|�<����L�
�	
��-/��r!c�|�tjj||�}|jj	|�|S)zI
        Override 'open' to track all files opened by this path.
        )rrNr?r�r4�r�moderPs   r r?zTrackingFilePath.openws5��
���"�"�4��.��������"��r!c�Z�|jD�cgc]}|js�|��c}Scc}w)z�
        Return a list of all L{TrackingFilePath}s associated with this
        L{TrackingFilePath} that have had their C{open()} method called.
        )r�r�)rr/s  r �openedPathszTrackingFilePath.openedPathss&��"&�!2�!2�G��d�6F�6F��G�G��Gs�(�(c�j�t||j��}|jj|�|S)z}
        Override L{filepath.FilePath.clonePath} to give the new path a reference
        to the same tracking list.
        )r�)r�r�r4)rr/r��clones    r �	clonePathzTrackingFilePath.clonePath�s/��!��D�4E�4E�F����� � ��'��r!)FN)r/rr��boolr�zEOptional[List[Union[TrackingFilePath[str], TrackingFilePath[bytes]]]]r"r���r�r�rr"z	IO[bytes])r"z;List[Union[TrackingFilePath[str], TrackingFilePath[bytes]]]�F)r/rr�r�r"zTrackingFilePath[OtherAnyStr])r$r%r&r'r�r?r�r�r(r!r r�r�Usr���(#�
�
/��/��/�
�	/�
�/� �H�	D�H�7<�	��	�/3�	�	&�	r!r�c�R�eZdZUdZded<	d					d	d�Zd
dd�Z	d					d
d�Zy)�ExplodingFilePathz�
    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.
    r�r�Nc�Z�tjj||�|�|}||_y)aY
        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)rrNr��_originalExploder)r�pathName�originalExploders   r r�zExplodingFilePath.__init__�s.��"	���"�"�4��2��#�#��!1��r!c�<�t�x}|j_|S)z�
        Create, save, and return a new C{ExplodingFile}.

        @param mode: Present for signature compatibility.  Ignored.

        @return: A new C{ExplodingFile}.
        )r�r�r�r�s   r r?zExplodingFilePath.open�s��)6��7��D�"�"�%��r!c�.�t||j�Sr-)r�r�)r�namer�s   r r�zExplodingFilePath.clonePath�s��!��t�'=�'=�>�>r!r-)r�rr�zAOptional[Union[ExplodingFilePath[str], ExplodingFilePath[bytes]]]r"r�r�r�r�)r�rr�r�r"zfilepath.FilePath[OtherAnyStr])r$r%r&r'�__annotations__r�r?r�r(r!r r�r��s\���	��
�2��2�
�2�
�
2�,	�7<�?��?�/3�?�	'�?r!r��Tc�b�eZdZdZ	d							dd�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	d
d	�Z
d
d
�Zy)�PermissionsTestsz*
    Test Permissions and RWX classes
    Nc	��||k7rC|�d}t|�dkDr|dz
}|j|�dt|��dt|��d���|S)z�
        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
        �r�
z8not not unequal (__ne__ not implemented correctly):
a = z
b = )r��failureExceptionr)r�first�second�msgs    r �assertNotUnequalz!PermissionsTests.assertNotUnequal�sX���F�?��{����3�x�!�|��t����'�'�(+�W�U�^�W�V�_�N��
��r!c��|jt�5}|jddd�ddd�|jdt	j
��|jdt	|j
��|jt�5}|jdd�ddd�|jdt	j
��|jdd�y#1swY��xYw#1swY�MxYw)zR
        Self-test for assertNotUnequal to make sure the assertion works.
        r�r�zcustom messageNz __ne__ not implemented correctly)rb�AssertionErrorr�assertIn�str�	exception)r�ae�ae2s   r �	test_testzPermissionsTests.test_test�s����
�
�~�
.�	:�"��!�!�!�Q�(8�9�	:��
�
�8�#�b�l�l�:K�L��
�
�&��B�L�L�(9�:�
�
�
�~�
.�	(�#��!�!�!�Q�'�	(��
�
�8�#�c�m�m�:L�M����a��#�	:�	:��	(�	(�s�C$�C0�$C-�0C9c��dD]{}dD]t}dD]m}tj|||�}|j|j|�|j|j|�|j|j
|��o�v�}tjddd�}|j
|jxr|jxr|j
�y)z>
        L{RWX}'s constructor takes a set of booleans
        �TFTN)r�RWXr[r�rJ�executerS)rr��wr6�rwxs     r �test_rwxFromBoolsz"PermissionsTests.test_rwxFromBools�s����	5�A�"�
5��&�5�A�"�,�,�q�!�Q�/�C��$�$�S�X�X�q�1��$�$�S�Y�Y��2��$�$�S�[�[�!�4�	5�
5�	5��l�l�4��t�,��������>�S�Y�Y�>�3�;�;�?r!c���dD]�}dD]�}dD]z}|jtj|||�tj|||��|jtj|||�tj|||���|����|j	tjddd�tjddd��|j	dtjddd��y)z�
        L{RWX}'s created with the same booleans are equivalent.  If booleans
        are different, they are not equal.
        rTFr�N)r[rrr�assertNotEqual)rr�rr6s    r �test_rwxEqNezPermissionsTests.test_rwxEqNe�s���
�	X�A�"�
X��&�X�A��$�$�X�\�\�!�Q��%:�H�L�L��A�q�<Q�R��)�)�(�,�,�q�!�Q�*?����a�QR�TU�AV�W�X�
X�	X�
	
����L�L��t�T�*�H�L�L��t�U�,K�	
�	
���A�x�|�|�D�$��=�>r!c�D�d
d�}dD]b}dD][}dD]T}tj|||�}|j|j�||d�||d�z||d�z��V�]�d|jtjddd�j�d�y	)z�
        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 '-'.
        c��|r|Sy)N�-r()�val�letters  r �getCharz3PermissionsTests.test_rwxShorthand.<locals>.getChars
����
�r!rr�rr6TFzr-xN)rr�rr
r"r
)rrr[�	shorthand)rrr�rr6rs      r �test_rwxShorthandz"PermissionsTests.test_rwxShorthand
s���	�
�	�A�"�
��&��A�"�,�,�q�!�Q�/�C��$�$��
�
����3��'�!�S�/�9�G�A�s�O�K���
�	�	
������d�E�4�8�B�B�D�e�Lr!c
��dd�}tdd�D]�}tdd�D]�}tdd�D]�}d|||fz}t|d�}tj|�}|j	|j
||d�|�d|j
���|j	|j||d�|�d|j���|j	|j||d	�|�d
|j���������tjd�}dD].}d
D]'}	|jtt||�|	���)�0y)z�
        L{Permissions}'s constructor takes a valid permissions bitmask and
        parsaes it to produce the correct set of boolean permissions.
        c�L����d�fd��tj��fd�dD��S)Nc�>��ttd|�|���}�|zdkDS)N�S_Ir)�getattr�stat)r��who�constant�statModeInts   �r �getPermissionBitzYPermissionsTests.test_permissionsFromStat.<locals>._rwxFromStat.<locals>.getPermissionBit*s*��� '���D�6�#��.?� @��#�h�.�!�3�3r!c3�0�K�|]
}�|�����y�wr-r()�.0r�r*r's  ��r �	<genexpr>zRPermissionsTests.test_permissionsFromStat.<locals>._rwxFromStat.<locals>.<genexpr>/s�����J�$�"�4��-�J�s�)�R�W�X)r�r
r'r
r"r�)rr)r)r'r*s``@r �_rwxFromStatz?PermissionsTests.test_permissionsFromStat.<locals>._rwxFromStat)s#���
4��<�<�J�/�J��
r!r�z%d%d%d�USRz: got user: �GRPz
: got group: �OTHz
: got other: �)�user�group�other)r�rJrN)r)r�r'r
r"zfilepath.RWX)
�ranger�r�Permissionsr[r7r8r9rSr%)
rr1�u�g�o�chmodString�chmodVal�permr'r�s
          r �test_permissionsFromStatz)PermissionsTests.test_permissionsFromStat#sY��	��q�!��	�A��1�a�[�
���q�!���A�"*�a��A�Y�"6�K�"�;��2�H�#�/�/��9�D��$�$��	�	�$�X�u�5�&�-�|�D�I�I�;�?��
�$�$��
�
�$�X�u�5�&�-�}�T�Z�Z�L�A��
�$�$��
�
�$�X�u�5�&�-�}�T�Z�Z�L�A���
�	�*�#�#�E�*��-�	C�C�4�
C��������c�(:�D� A�B�
C�	Cr!c��|jtjd�tjd��|jtjd�tjd��|j	tjd�tjd��|j	dtjd��y)zd
        Two L{Permissions}'s that are created with the same bitmask
        are equivalent
        r6�r�N)r[rr;rrrs r �test_permissionsEqz#PermissionsTests.test_permissionsEqLs���
	
����-�-�e�4�h�6J�6J�5�6Q�R����h�2�2�5�9�8�;O�;O�PU�;V�W����H�0�0��7��9M�9M�e�9T�U����A�x�3�3�E�:�;r!c���tdd�D]�}tdd�D]�}tdd�D]~}tjtd|||fzd��}|j	|j�dj
d�|j|j|jfD���������|j	tjd�j�d�y)	z�
        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.
        rr2z0o%d%d%drc3�<K�|]}|j����y�wr-)r)r,r6s  r r-z=PermissionsTests.test_permissionsShorthand.<locals>.<genexpr>bs���� �./�A�K�K�M� �s�i�z	rwxrwx---N)
r:rr;r�r[rr1r7r8r9)rr<r=r>rAs     r �test_permissionsShorthandz*PermissionsTests.test_permissionsShorthandVs����q�!��		�A��1�a�[�
���q�!���A�#�/�/��J�!�Q���4J�A�0N�O�D��$�$����(���� �48�I�I�t�z�z�4�:�:�3V� ����
�		�	
����-�-�e�4�>�>�@�+�Nr!r-)rr�rr�rz
Optional[str]r"r�r�)r$r%r&r'rrrrr rBrErHr(r!r r�r��sZ���
>B���� &��-:��	
��*$�@�
?�M�,'C�R<�Or!r�c���eZdZdZdHd�ZdHd�Zeed�dHd��Zeed�dHd��Z	dHd�Z
eed�dHd��Zeed�dHd	��Zeed�dHd
��Z
dHd�ZdHd�Zeed�dHd
��Zeed�dHd��Zeed�dHd��ZdHd�ZdHd�ZdHd�ZdHd�ZdHd�Zeej2�dk7d�dHd��Zeej2�dk7d�dHd��ZdHd�ZdHd�ZdHd�ZdHd�ZdHd�Z dHd�Z!eed�dHd��Z"dHd �Z#dHd!�Z$dHd"�Z%dHd#�Z&eed�dHd$��Z'eed�dHd%��Z(dHd&�Z)dHd'�Z*dHd(�Z+dHd)�Z,d*�fdId+�Z-dHd,�Z.dHd-�Z/dJd.�Z0dHd/�Z1eed�dHd0��Z2eed�dHd1��Z3dHd2�Z4dHd3�Z5dHd4�Z6dHd5�Z7dHd6�Z8dHd7�Z9dHd8�Z:dHd9�Z;dHd:�Z<dHd;�Z=dHd<�Z>dHd=�Z?eej��d>�dHd?��ZAdHd@�ZBeej��dA�dHdB��ZCdHdC�ZDeej��dA�dHdD��ZEeej��d>�dHdE��ZFeej��d>�dHdF��ZGyG)K�
FilePathTestsz�
    Test various L{FilePath} path manipulations.

    In particular, note that tests defined on this class instead of on the base
    class are only run against L{twisted.python.filepath}.
    c
�0�dD]�}|jjd�j|�|jt	j
t
j|jjd�j�j�|���y)z�
        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).
        )�mr6rBN)r/r\�chmodr[r&�S_IMODEr.�st_mode�rr�s  r �
test_chmodzFilePathTests.test_chmodqsl��#�	�D��I�I�O�O�G�$�*�*�4�0�������R�W�W�T�Y�Y�_�_�W�%=�%B�%B�C�K�K�L�d�
�	r!c��|jjd�}tj|j|j	d��tj|jd�j|j	d��tj|jd�j|j	dd��y)zI
        Create several symbolic links to files and directories.
        rB�	sub1.linkrD�
file2.linkssub1.file2.linkN)r/r\r.�symlinkr7)rr<s  r �createLinkszFilePathTests.createLinks}s���������)��
�
�
�6�;�;����\� :�;�
�
�
�6�<�<��)�.�.����]�0K�L�
�
�
��L�L��"�'�'����g�?Q�)R�	
r!z"Platform does not support symlinksc��|j�tj|jj	d�j|jj	d�j�|j|jj	d�j
�|jj	d�j	d��y)zd
        L{FilePath.realpath} returns the path of the ultimate target of a
        symlink.
        rTs	link.linkrBrDN)rVr.rUr/r\r[�realpathrs r �test_realpathSymlinkz"FilePathTests.test_realpathSymlink�s���	
����
�
�
��I�I�O�O�M�*�/�/�������1N�1S�1S�	
�	
����I�I�O�O�L�)�2�2�4��I�I�O�O�G�$�*�*�8�4�	
r!c��tj|jjd�j|jjd�j�tj|jjd�j|jjd�j�|j	t
j|jjd�j�y)z�
        L{FilePath.realpath} raises L{filepath.LinkError} if the path is a
        symbolic link which is part of a cycle.
        �link1slink2N)r.rUr/r\rbr�	LinkErrorrXrs r �test_realpathCyclicalSymlinkz*FilePathTests.test_realpathCyclicalSymlink�s���	�
�
�4�9�9�?�?�8�,�1�1�4�9�9�?�?�8�3L�3Q�3Q�R�
�
�
�4�9�9�?�?�8�,�1�1�4�9�9�?�?�8�3L�3Q�3Q�R����(�,�,�d�i�i�o�o�h�.G�.P�.P�Qr!c��|j|jjd�j�|jjd��y)zj
        L{FilePath.realpath} returns the path itself if the path is not a
        symbolic link.
        rBN)r[r/r\rXrs r �test_realpathNoSymlinkz$FilePathTests.test_realpathNoSymlink�s7��
	
���������1�:�:�<�d�i�i�o�o�g�>V�Wr!c�H���j�tj�jj	d�j�jj	d�j	d�j�d�fd�}�jtj|�y)zT
        Verify that walking a path with a cyclical symlink raises an error
        rB�sub1.loopylinkc�r���jj�D�cgc]}|j��c}Scc}wr-�r/rf)rhrs �r �iterateOverPathz?FilePathTests.test_walkCyclicalSymlink.<locals>.iterateOverPath�s&���(,�	�	���(8�9��C�H�H�9�9��9s�4N�r"zList[bytes])rVr.rUr/r\rbrr\)rrds` r �test_walkCyclicalSymlinkz&FilePathTests.test_walkCyclicalSymlink�sr���
	
����
�
�
��I�I�O�O�G�$�)�)��I�I�O�O�G�$�*�*�+<�=�B�B�	
�
	:�	
���(�,�,�o�>r!c�@����j�tj�jj	d�j�jj	d�j	d�j�dd��d��fd�}�j|��y)z�
        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.
        rBrac�$�|j�Sr-�rw�r/s r �
noSymLinkszKFilePathTests.test_walkObeysDescendWithCyclicalSymlinks.<locals>.noSymLinks�����{�{�}�$�$r!c�v���jj���D�cgc]}|j��c}Scc}w)N��descendrc)rhrkrs ��r rdzPFilePathTests.test_walkObeysDescendWithCyclicalSymlinks.<locals>.iterateOverPath�s*���(,�	�	���z��(J�K��C�H�H�K�K��Ks�6N�r/zfilepath.FilePath[bytes]r"r�re)rVr.rUr/r\rS)rrdrks` @r �)test_walkObeysDescendWithCyclicalSymlinksz7FilePathTests.test_walkObeysDescendWithCyclicalSymlinks�sq���	
����
�
�
��I�I�O�O�G�$�)�)��I�I�O�O�G�$�*�*�+<�=�B�B�	
�
	%�	L�	
����)�*r!c��|j�dd�}|jj|��D�cgc]}|j��}}|jt	|�t	|j
��ycc}w)z{
        Verify that when the supplied C{descend} predicate returns C{False},
        the target is not traversed.
        c�$�|j�Sr-rirjs r rkz7FilePathTests.test_walkObeysDescend.<locals>.noSymLinks�rlr!rnNrp)rVr/rfr[rgr3)rrkrhr6s    r �test_walkObeysDescendz#FilePathTests.test_walkObeysDescend�s_��	
����	%�"&�����
��!C�D�#�S�X�X�D��D�����Q���T�X�X��/��
Es�A7c��d}|jjd�j|�|jjd�j�}|j	||�d}|jjd�j|d�|jjd�j�}|j	||�y)Ns
newcontentsnewscontents.tmp)r/r\�
setContent�
getContentr[)r�content�
newcontents   r �test_getAndSetzFilePathTests.test_getAndSet�s������	�	�����*�*�7�3��Y�Y�_�_�V�,�7�7�9�
�����*�-����	�	�����*�*�7�G�<��Y�Y�_�_�V�,�7�7�9�
�����*�-r!c��td�}|jt|j�|j	|j
j�y)z�
        If reading from the underlying file raises an exception,
        L{FilePath.getContent} raises that exception after closing the file.
        rN)r�rb�IOErrorrwrSr�r�r�s  r �test_getContentFileClosingz(FilePathTests.test_getContentFileClosing�s6��
�r�
"�����'�2�=�=�1���������%r!c��|jjd�}|jjd�}tj|j|j�|j	|j��|j
|j��|j	|j��|j	|j��y)z�
        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.
        ssub4rEN)r/r\r.rUrSrwrurt)r�s4�s3s   r �test_symbolicLinkzFilePathTests.test_symbolicLink�s����Y�Y�_�_�W�
%��
�Y�Y�_�_�W�
%��
�
�
�2�7�7�B�G�G�$�����	�	��$��������%�������
�#�������
�#r!c�(�|jjd�|jjd�f|jjd�jd�|jjd�fg}|D]�\}}|j|�|j|j	�d�|j|j
�|j
��|j|j�|j����y)z�
        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.
        r|s	sub2.linkrFsfile3.ext1.linkzThis is a linkN)r/r\�linkTorSrwr[rtrv)r�targetLinks�target�links    r �test_linkTozFilePathTests.test_linkTo�s����Y�Y�_�_�W�
%�t�y�y���|�'D�E��	�	����(�.�.�}�=��	�	��� 2�3�
�
��(�	=�L�F�D��M�M�$���O�O�D�K�K�M�+;�<����V�\�\�^�T�Z�Z�\�:����V�]�]�_�d�k�k�m�<�		=r!c��|jt|jjd�j|jjd�jd��|jt|jjd�j|jjd�jd��y)z�
        Verify C{linkTo} fails in the following case:
            - the target is in a directory that doesn't exist
            - the target already exists
        rCsnosubrBrDN)rbr�r/r\r�rs r �test_linkToErrorszFilePathTests.test_linkToErrorss���	
�����I�I�O�O�H�%�,�,��I�I�O�O�H�%�+�+�H�5�	
�
	
�����I�I�O�O�H�%�,�,��I�I�O�O�G�$�*�*�8�4�	
r!c��|jjd�jd�}d}|j|j|��|j	d�}|j�|j|�}|�J�|j|j
��|jd�}|�J�|j|j
��|j�|j|j|��y)NrE�file3)�.foos.barsext1sext2sext3r��*)r/r\ru�siblingExtensionSearch�siblingExtension�touchrsr�)r�f3�exts�f3e�found�globbeds      r �testMultiExtzFilePathTests.testMultiExt$s���
�Y�Y�_�_�W�
%�
+�
+�H�
5��:�����2��2�2�D�9�:��!�!�'�*���	�	��)��)�)�4�0��� � � ����U�\�\�^�+�,��+�+�D�1���"�"�"����W�^�^�-�-�.��
�
�����2��2�2�D�9�:r!c��tjd�}|jd�|jtj|jd�y)N�.sfoo/bar�/mon€y)rrN�preauthChildrb�InsecurePathr�s  r �testPreauthChildzFilePathTests.testPreauthChild3s:��
�
�
�t�
$��
���
�#����(�/�/����-�Pr!c�4�|jjd�}|j�|j|j	�d�|jt|j
�tj�z
�dzd�|jt|j�tj�z
�dzd�|jt|j�tj�z
�dzd�|j|j��|j|j��tj|j�|j|j��|jd��|j|j��|j|j!��|j|j#��|j|j%��y)Nsstattestr�F)�reraise)r/r\r�r[�getsize�absr�rHr�r�rSrsr.r��restatrurwrtrvr�s  r �
testStatCachezFilePathTests.testStatCache8sX���I�I�O�O�K�(��	���	��������a�(�����Q�Z�Z�\�D�I�I�K�7�8�B�>��B�����Q�Z�Z�\�D�I�I�K�7�8�B�>��B�����Q�Z�Z�\�D�I�I�K�7�8�B�>��B�������
�#�������
�#�
�	�	�!�&�&��������
�#�	�������������$��������$��������#��������$r!c�(�tjtj|j��}|j	|jj
|j
�|j	|jj|j�yr-)�pickle�loads�dumpsr/r[�	__class__)r�newpaths  r �testPersistzFilePathTests.testPersistKsY���,�,�v�|�|�D�I�I�6�7��������,�,�g�.?�.?�@������������6r!c�B�|jtj|jjd�|jtj|jjd�|jtj|jjd�y)Ns..s/etcs../..�rbrr�r/r\rs r �testInsecureUNIXzFilePathTests.testInsecureUNIXPsb�����(�/�/������%�H����(�/�/������'�J����(�/�/������(�Kr!r�zTest will run only on Windows.c���|jtj|jjd�|jtj|jjd�y)Ns..\..sC:randomfiler�rs r �testInsecureWin32zFilePathTests.testInsecureWin32UsB�����(�/�/������)�L����(�/�/������/�Rr!c�B�|jtj|jjd�|jtj|jjd�|jtj|jjd�y)a

        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.
        sCONsC:CONzC:\CONNr�rs r �testInsecureWin32Whackyz%FilePathTests.testInsecureWin32WhackyZsd��	
���(�/�/������&�I����(�/�/������(�K����(�/�/������)�Lr!c��|jtjd�tjd��|jtjd�tjd�kD�|jtjd�tjd�k\�|jtjd�tjd�k\�|jtjd�tjd�k�|jtjd�tjd�k�|jtjd�tjd�k�|jtjd�tjd�k7�|jtjd�tjd�k7�|j	tjd�tjd�k7�y)NrW�z)r[rrNrSrurs r �testComparisonzFilePathTests.testComparisonfs�������*�*�4�0�(�2C�2C�D�2I�J�����)�)�$�/�(�2C�2C�D�2I�I�J�����)�)�$�/�8�3D�3D�T�3J�J�K�����)�)�$�/�8�3D�3D�T�3J�J�K�����)�)�$�/�8�3D�3D�T�3J�J�K�����)�)�$�/�(�2C�2C�D�2I�I�J�����)�)�$�/�8�3D�3D�T�3J�J�K�����)�)�$�/�8�3D�3D�T�3J�J�K�����)�)�$�/�8�3D�3D�T�3J�J�K�����*�*�4�0�H�4E�4E�d�4K�K�Lr!c�r�|jtj|jjddg�y)zt
        If C{".."} is in the sequence passed to L{FilePath.descendant},
        L{InsecurePath} is raised.
        �mon€yz..N)rbrr�r/r�rs r �test_descendantOnlyz!FilePathTests.test_descendantOnlyss.��
	
����!�!�4�9�9�#7�#7�,��9M�	
r!c�l�|jjd�}|jd�}|j|j	�|j	��|j|j�d�|j
�|j||jj��y)Ns
sibling_startssibling_test)	r/r\�siblingr[r;�basename�createDirectoryr	r�)rr5�tss   r �testSiblingzFilePathTests.testSibling|s|���I�I�O�O�,�-��
�Y�Y��
'���������q�y�y�{�3���������8�
�����
�
�b�$�)�)�,�,�.�/r!c��|jj�}|j|j�|jj��|j	|j�|jj
��|j�|j||jj�j��yr-)r/�temporarySiblingr[r;�assertNotInr�rxr�r	�parentr�)rr�s  r �testTemporarySiblingz"FilePathTests.testTemporarySibling�s���
�Y�Y�
'�
'�
)���������t�y�y�'8�'8�':�;���������	�	�(9�(9�(;�<�
�����
�
�b�$�)�)�*�*�,�5�5�7�8r!c���d}|jj|�}|j|j�j	|�|j��d|���y)z�
        If L{FilePath.temporarySibling} is given an extension argument, it will
        produce path objects with that extension appended to their names.
        s.test-extensionz does not end with N)r/r�rSr��endswith)r�
testExtensionr�s   r �test_temporarySiblingExtensionz,FilePathTests.test_temporarySiblingExtension�sT��
+�
�
�Y�Y�
'�
'�
�
6������K�K�M�"�"�=�1��{�{�}��2�=�2C�D�	
r!c��|jj�|j|jj��y)z~
        L{FilePath.remove} on a L{FilePath} that refers to a directory will
        recursively delete its contents.
        N)r/r�rursrs r �test_removeDirectoryz"FilePathTests.test_removeDirectory�s/��
	
�	�	����������)�)�+�,r!c��|jjd�}tj|jjd�j|j�|j	�|j|j
��|j|jjd�j
��y)zx
        For a path which is a symbolic link, L{FilePath.remove} just deletes
        the link, not the target.
        rSrBN)r/r\r.rUr�rursrS)rr�s  r �test_removeWithSymlinkz$FilePathTests.test_removeWithSymlink�sz���y�y���|�,��
�
�
�4�9�9�?�?�7�+�0�0�$�)�)�<����
��������'�����	�	����0�7�7�9�:r!c���t|jj��}tj|j��}|jj
|�|jj�|j
|j�t|jj��}|j�|j�|j||�y)z�
        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)
r�r/rfrrNr�copyTor�r�r[�r�oldPathsr��newPathss    r �test_copyToDirectoryz"FilePathTests.test_copyToDirectory�s���
��	�	���(�)��
�
�
�t�{�{�}�
-���	�	������	�	����
�	�	�$�)�)����	�	���(�)���
�
���
�
������8�,r!c��|jjd�}d�|_t|j	��}|jt|j|�|j|jj�y)z�
        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}.
        snotherec��y)NTr(r(r!r �<lambda>zAFilePathTests.test_copyToMissingDestFileClosing.<locals>.<lambda>���r!N)r/r\rvr�rrbr|r�rSr�r�)r�nosuch�destinations   r �!test_copyToMissingDestFileClosingz/FilePathTests.test_copyToMissingDestFileClosing�s]��������,��%��
�(����
�6�����'�6�=�=�+�>�������-�-�.r!c�*�t|j��}tt�}|jt|j
|�|j
|jj�|j
|jj�y)z�
        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�__file__rbr|r�rSr�r�)rr��sources   r �test_copyToFileClosingz$FilePathTests.test_copyToFileClosing�s`��(����
�6��"�8�,�����'�6�=�=�+�>�����	�	�(�(�)�������-�-�.r!c��|jttf|jj|jjd��y)z�
        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.
        rCN)rbr�r|r/r�r\rs r �test_copyToDirectoryItselfz(FilePathTests.test_copyToDirectoryItself��5��	
���
�g���	�	� 0� 0�$�)�)�/�/�(�2K�	
r!c��tj|jjd�j|jjd�j�t	j
|j
��}|jj|�|j|jd�j��|j|jd�j�D�cgc]}|j���c}|jd�j�D�cgc]}|j���c}�ycc}wcc}w)zn
        Verify that copying with followLinks=True copies symlink targets
        instead of symlinks
        rBr[N)
r.rUr/r\rrNrr�rurwr[r�r�)rr�r6s   r �test_copyToWithSymlinkz$FilePathTests.test_copyToWithSymlink�s���	�
�
�4�9�9�?�?�7�+�0�0�$�)�)�/�/�(�2K�2P�2P�Q�
�
�
�t�{�{�}�
-���	�	�����������(�+�2�2�4�5����#%�8�8�G�#4�#=�#=�#?�@�a�Q�Z�Z�\�@�#%�8�8�H�#5�#>�#>�#@�A�a�Q�Z�Z�\�A�	
��@��As�5E�/E
c�:�tjd|jjd�j�t	j
|j
��}|jj|d��|j|jd�j��|jtj|jjd�j�tj|jd�j��y)zX
        Verify that copying with followLinks=False copies symlinks as symlinks
        rBr[F��followLinksN)r.rUr/r\rrNrr�rSrwr[�readlinkr�s  r �test_copyToWithoutSymlinkz'FilePathTests.test_copyToWithoutSymlink�s���
	�
�
�7�D�I�I�O�O�H�5�:�:�;�
�
�
�t�{�{�}�
-���	�	������/��������*�1�1�3�4�����K�K��	�	����1�6�6�7��K�K�����*�/�/�0�	
r!c���tj|j��}|jt|j
d�}|j
|jtj�y)zV
        If the source path is missing, L{FilePath.copyTo} raises L{OSError}.
        ssome other pathN)	rrNrrbr�r�r[�errno�ENOENT)rr/�excs   r �test_copyToMissingSourcez&FilePathTests.test_copyToMissingSourcesK��� � �����/���������6H�I��������E�L�L�1r!c��t|jj��}tj|j��}|jj
|�|j
|j�t|jj��}|j�|j�|j||�y)zv
        Verify that moving an entire directory results into another directory
        with the same content.
        N)	r�r/rfrrNr�moveTor�r[r�s    r �test_moveTozFilePathTests.test_moveTo	s���
��	�	���(�)��
�
�
�t�{�{�}�
-���	�	�����
�	�	�$�)�)����	�	���(�)���
�
���
�
������8�,r!c���tj|j��}tj|j��}|j�|j	|j��|j
|j��|j|�|j
|j��|j	|j��y)z�
        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)rrNrr�rSrsrur�)rr��fp2s   r �test_moveToExistsCachez$FilePathTests.test_moveToExistsCaches����
�
�t�{�{�}�
-��������
�.��
���
�
	
����	�	��$��������&�
�	�	�#���������%�����
�
��%r!c�D�|j�|j�y)zp
        The assertion of test_moveToExistsCache should hold in the case of a
        cross-mount move.
        N)�setUpFaultyRenamer�rs r � test_moveToExistsCacheCrossMountz.FilePathTests.test_moveToExistsCacheCrossMount+s��
	
��� ��#�#�%r!c��yr-r(r(r!r r�zFilePathTests.<lambda>3r�r!c�B�tj|j��}tj|j��}|jd�|jd�|�|j	|j�d�|j	|j�d�t
j|j�|j	|j�d�|j|�|j	|j�d�y)a
        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.
        s1234s
1234567890r��
N)
rrNrrvr[r�r.r�r/r�)r�hookr�r�s    r �test_moveToSizeCachez"FilePathTests.test_moveToSizeCache3s����
�
�t�{�{�}�
-��������
�.��
�
�
�g�����}�%���	
�������q�)���������+�	�	�	�#�(�(����������+�
�	�	�#����������*r!c�6��d�fd�}�j|��y)zn
        The assertion of test_moveToSizeCache should hold in the case of a
        cross-mount move.
        c�&���j�yr-)r�rs�r rQz;FilePathTests.test_moveToSizeCacheCrossMount.<locals>.setUpXs����"�"�$r!)r�Nr�)r�)rrQs` r �test_moveToSizeCacheCrossMountz,FilePathTests.test_moveToSizeCacheCrossMountRs���	%�	
�!�!�u�!�-r!c��|jttf|jj|jjd��y)z�
        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.
        rCN)rbr�r|r/r�r\rs r �test_moveToErrorzFilePathTests.test_moveToError]r�r!c�j���g�d��fd�}tj�|jtd|��S)a
        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����j||f�t��dk(rttjd���||�S)N�z;Test-induced failure simulating cross-device rename failure)r4r�r�r��EXDEV)�src�dest�invokedWith�originalRenames  ��r �faultyRenamez5FilePathTests.setUpFaultyRename.<locals>.faultyRenameqsH�������T�{�+��;��1�$���K�K�T���"�#�t�,�,r!�rename)rr
rr
r"r�)r.r�patch)rrrrs  @@r r�zFilePathTests.setUpFaultyRenamegs0�����	-������
�
�2�x��.��r!c�f�|j�}|j�|j|�y)z�
        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�rS)rrs  r �test_crossMountMoveToz#FilePathTests.test_crossMountMoveTo~s.���,�,�.��	
����	
����$r!c���|j�}|jjd�}|jjd�}tj|jjd�j|j�|j|�|j
|j��|j|j�d�|j|�y)z�
        By default, when moving a symlink, it should follow the link and
        actually copy the content of the linked node.
        rDr�rCr+N)r�r/r\r.rUr�rurwr[rwrS�rrr�r�s    r � test_crossMountMoveToWithSymlinkz.FilePathTests.test_crossMountMoveToWithSymlink�s����,�,�.��
�Y�Y�_�_�X�
&��
�Y�Y�_�_�X�
&��
�
�
�4�9�9�?�?�8�,�1�1�2�7�7�;�
�	�	�"�
��������%��������)�4�����$r!c���|j�}|jjd�}|jjd�}tj|jjd�j|j�|j|d��|j
|j��|j|j�d�|j
|�y)zk
        Verify that moveTo called with followLinks=False actually create
        another symlink.
        rDr�rCFr�r+N)
r�r/r\r.rUr�rSrwr[rwrs    r �#test_crossMountMoveToWithoutSymlinkz1FilePathTests.test_crossMountMoveToWithoutSymlink�s����,�,�.��
�Y�Y�_�_�X�
&��
�Y�Y�_�_�X�
&��
�
�
�4�9�9�?�?�8�,�1�1�2�7�7�;�
�	�	�"�%�	�(�����	�	��$��������)�4�����$r!c��tj|j��}|j�5}|j	d|j
�|j
d�ddd�t|jd�5}|j�}|j|d�ddd�y#1swY�KxYw#1swYyxYw)a>
        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.)
        �b�
N�rb)rrNr�creater	r�rJr?r/r�r[)rr/rPr�r�s     r �test_createBinaryModez#FilePathTests.test_createBinaryMode�s���� � �����/��
�[�[�]�	�a��M�M�#�q�v�v�&�
�G�G�E�N�	��$�)�)�T�
"�	*�b��7�7�9�D����T�5�)�	*�	*�	�	��	*�	*�s�.B,�#B8�,B5�8Cc��|jjd�}|jt|j�}|j|jtj�|jjd�}|j	d�5}|jd�ddd�|j	�5}|j|j�d�ddd�|j	d�j�|j	�5}|j|j�d�ddd�|jjd�}|j	d�5}|jd�ddd�|j	d�5}|jd	�ddd�|j	d
�5}|j|j�d�ddd�|j	d�5}|j|j�d�|jd
d�|jd�ddd�|j	d
�5}|j|j�d�ddd�|j	d�5}|j|j�d�|jd
d�|jd�ddd�|j	d�5}|jd�|jd
d�|j|j�d�|jd
d
�|j|j�d�ddd�|jd�|j	d�j�|}~|jttf|j�y#1swY��#xYw#1swY���xYw#1swY���xYw#1swY��sxYw#1swY��UxYw#1swY��(xYw#1swY���xYw#1swY���xYw#1swY��[xYw#1swY��xYw)Nsnonexistentswriterr�abc
defr!sappendersabc�asdefr�sabcdefzr+rrsghis	abcdefghizw+s123za+s456s123456T)r/r\rbr|r?r[r�r�rJr�rM�seek�
requireCreater�)r�nonexistent�e�writerrP�appender�existents       r �testOpenzFilePathTests.testOpen�s]���i�i�o�o�n�5�����g�{�'7�'7�8��������%�,�,�/�������+��
�[�[��
�	!��
�G�G�K� �	!�
�[�[�]�	4�a����Q�V�V�X�{�3�	4�	���C���� �
�[�[�]�	,�a����Q�V�V�X�s�+�	,�
�9�9�?�?�;�/��
�]�]�3�
�	�1�
�G�G�F�O�	��]�]�3�
�	�1�
�G�G�F�O�	��]�]�3�
�	2�1����Q�V�V�X�y�1�	2��]�]�4�
 �
	�A����Q�V�V�X�y�1�
�F�F�1�a�L�
�G�G�F�O�
	��]�]�3�
�	5�1����Q�V�V�X�|�4�	5�
�]�]�4�
 �	�A����Q�V�V�X�s�+�
�F�F�1�a�L�
�G�G�F�O�	��]�]�4�
 �
	2�A�

�G�G�F�O�
�F�F�1�a�L����Q�V�V�X�s�+�
�F�F�1�a�L����Q�V�V�X�y�1�
	2�	�!�!�$�'������#�#�%�������7�G�,�h�m�m�<�I	!�	!��
	4�	4��
	,�	,��	�	��	�	��	2�	2��
	�
	��	5�	5��
	�	��
	2�
	2�s{�O�<!O�!O�)O,�O9�?!P�9AP�!P �AP-�-A6P:�O�O�O)�,O6�9P�P�P� P*�-P7�:Qc���|jjd�}|jd�}|5}|jd�ddd�|j	|j
�y#1swY�%xYw)aj
        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-binaryr>rN�r/r\r?rJrSrs�rr�opener�files    r �test_openWithExplicitBinaryModez-FilePathTests.test_openWithExplicitBinaryMode
s[�������!3�4�����T�"��
�	$�t��J�J�{�#�	$�����
�
�&�	$�	$���A%�%A.c���|jjd�}|jd�}|5}|jd�ddd�|j	|j
�y#1swY�%xYw)a�
        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-binary�wbbrNr"r#s    r �)test_openWithRedundantExplicitBinaryModesz7FilePathTests.test_openWithRedundantExplicitBinaryModess[�������!3�4�����U�#��
�	$�t��J�J�{�#�	$�����
�
�&�	$�	$�r'c���tj|j��}|j|j	��|j�|j
|j	��y)z�
        Check that C{filepath.FilePath.exists} correctly restat the object if
        an operation has occurred in the mean time.
        N)rrNrrurs�makedirsrSr�s  r �test_existsCachezFilePathTests.test_existsCache)sI��
�
�
�t�{�{�}�
-���������%�
���
�����	�	��$r!c�d�tjtjj	|j�ddd��}|j
|j��|j�|j|j��|j|j��y)z�
        C{FilePath.makedirs} creates a directory at C{path}}, including
        recursively creating all parent directories leading up to the path.
        sfoosbarsbazN)rrNr.r/r1rrursr,rSrtr�s  r �(test_makedirsMakesDirectoriesRecursivelyz6FilePathTests.test_makedirsMakesDirectoriesRecursively4sn��
�
�
�r�w�w�|�|�D�K�K�M�6�6�6�R�
S���������%�
���
�����	�	��$�������
�#r!c�(�tj|j��}|j|j	��|jd��|j
|j	��|j
|j��y)z�
        Calling C{FilePath.makedirs} with C{ignoreExistingDirectory} set to
        C{True} has no effect if directory does not exist.
        T��ignoreExistingDirectoryN)rrNrrursr,rSrtr�s  r �8test_makedirsMakesDirectoriesWithIgnoreExistingDirectoryzFFilePathTests.test_makedirsMakesDirectoriesWithIgnoreExistingDirectoryAs`��
�
�
�t�{�{�}�
-���������%�
���D��1�����	�	��$�������
�#r!c�8�tjtjj	|j���}|j
�|jt|j�}|j|jtj�y)z}
        C{FilePath.makedirs} throws an C{OSError} exception
        when called on a directory that already exists.
        N)rrNr.r/r1rr,rbr�r[r��EEXIST�rr�rs   r �(test_makedirsThrowsWithExistentDirectoryz6FilePathTests.test_makedirsThrowsWithExistentDirectoryNs^��
�
�
�r�w�w�|�|�D�K�K�M�:�
;��
���
��%�%�g�r�{�{�;�	�������%�,�,�7r!c�
�tj|j��}|j�|j	|j��|jd��|j	|j��y)z�
        C{FilePath.makedirs} succeeds when called on a directory that already
        exists and the c{ignoreExistingDirectory} argument is set to C{True}.
        Tr1N)rrNrr,rSrsr�s  r �+test_makedirsAcceptsIgnoreExistingDirectoryz9FilePathTests.test_makedirsAcceptsIgnoreExistingDirectoryZsU��
�
�
�t�{�{�}�
-��
���
�����	�	��$�
���D��1�����	�	��$r!c�@�tj|j��}|j�|j	|j��|j
t|jd��}|j|jtj�y)z�
        When C{FilePath.makedirs} is called with C{ignoreExistingDirectory} set
        to C{True} it throws an C{OSError} exceptions if path is a file.
        Tr1N)rrNrrrSrvrbr�r,r[r�r5r6s   r �5test_makedirsIgnoreExistingDirectoryExistAlreadyAFilezCFilePathTests.test_makedirsIgnoreExistingDirectoryExistAlreadyAFilegso��
�
�
�t�{�{�}�
-��
�	�	������	�	��$��%�%��R�[�[�$�&�
�	�	
������%�,�,�7r!c��dd�}|jtd|�tj|j	��}|jt|jd��}|j|jtj�y)z�
        When C{FilePath.makedirs} is called with C{ignoreExistingDirectory} set
        to C{True} it raises an C{OSError} exception if exception errno is not
        EEXIST.
        c�6�ttjd��)NzPermission Denied)r�r��EACCESrjs r �faultyMakedirsz_FilePathTests.test_makedirsRaisesNonEexistErrorsIgnoreExistingDirectory.<locals>.faultyMakedirs}s���%�,�,�(;�<�<r!r,Tr1N)r/r
r"r�)rr.rrNrrbr�r,r[r�r>)rr?r�rs    r �9test_makedirsRaisesNonEexistErrorsIgnoreExistingDirectoryzGFilePathTests.test_makedirsRaisesNonEexistErrorsIgnoreExistingDirectoryvsi��	=�	
�
�
�2�z�>�2�
�
�
�t�{�{�}�
-���%�%��R�[�[�$�&�
�	�	
������%�,�,�7r!c���tj|j��}|jd�|j	|j�d�t
|jd�5}|jd�ddd�|j	|j�d�|j�|j	|j�d�y#1swY�ZxYw)z�
        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}.
        s12345r�r>s12345678Nr2)
rrNrrvr[r�r?r/rJ�changed)rr��fObjs   r �test_changedzFilePathTests.test_changed�s����
�
�t�{�{�}�
-��
�
�
�h���������q�)��"�'�'�4�
 �	$�D��J�J�{�#�	$�	
�������q�)�
�
�
��	
�������q�)�	$�	$�s�+C�CzTest does not run on Windowsc���dD]x}|jjd�j|�|j|jjd�j	�tj|���z|jjd�jd�|j|jjd�j	�j�d�y)z�
        Getting permissions for a file returns a L{Permissions} object for
        POSIX platforms (which supports separate user, group, and other
        permissions bits.
        )r6rDrB��z	rwxrw-r--N)r/r\rMr[�getPermissionsrr;rrPs  r �test_getPermissions_POSIXz'FilePathTests.test_getPermissions_POSIX�s���#�	�D��I�I�O�O�G�$�*�*�4�0�����	�	����(�7�7�9�8�;O�;O�PT�;U�
�	�
	
�	�	���� �&�&�u�-�����I�I�O�O�G�$�3�3�5�?�?�A�;�	
r!c��tj|j��|j|jg�}|j|g�y)z�
        While accessing L{twisted.python.filepath.FilePath.statinfo} is
        deprecated, the filepath itself is not.
        N)rrNr�
flushWarnings�test_filePathNotDeprecatedr[)r�warningInfos  r rKz(FilePathTests.test_filePathNotDeprecated�sA��
	���$�+�+�-�(��(�(�$�*I�*I�)J�K������b�)r!zTest will run only on Windowsc�J�|j|jjd�jd�dD]x}|jjd�j|�|j	|jjd�j�t
j|���z|jjd�jd�|j	|jjd�j�j�d�y)aJ
        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.
        rBr6)r6rLiIz	r-xr-xr-xN)	�
addCleanupr/r\rMr[rGrr;rrPs  r �test_getPermissions_Windowsz)FilePathTests.test_getPermissions_Windows�s���	
����	�	����0�6�6��>�"�	�D��I�I�O�O�G�$�*�*�4�0�����	�	����(�7�7�9�8�;O�;O�PT�;U�
�	�
	
�	�	���� �&�&�u�-�����I�I�O�O�G�$�3�3�5�?�?�A�;�	
r!c��|j|jj��|j|jj��y)z=
        Ensure that a file is not a block or socket
        N)rur/�
isBlockDevice�isSocketrs r �test_whetherBlockOrSocketz'FilePathTests.test_whetherBlockOrSocket�s:��	
������0�0�2�3�������+�+�-�.r!c��|jt|jj�|jt|jj�|jt|jj
�|jt|jj�|jt|jj�y)zM
        Verify that certain file stats are not available on Windows
        N)rb�NotImplementedErrorr/�getInodeNumber�	getDevice�getNumberOfHardLinks�	getUserID�
getGroupIDrs r �(test_statinfoBitsNotImplementedInWindowsz6FilePathTests.test_statinfoBitsNotImplementedInWindows�s���
	
���-�t�y�y�/G�/G�H����-�t�y�y�/B�/B�C����-�t�y�y�/M�/M�N����-�t�y�y�/B�/B�C����-�t�y�y�/C�/C�Dr!c��|jjd�}|j|fD]�}|j|j�t�|j|j�t�|j|j
�t�|j|j�t�|j|j�t���|j|jj�|j��|j|jj�|j��y)zo
        Verify that file inode/device/nlinks/uid/gid stats are numbers in
        a POSIX environment
        rCN)
r/r\�assertIsInstancerVr�rWrXrYrZr[)r�cr5s   r �test_statinfoBitsAreNumbersz)FilePathTests.test_statinfoBitsAreNumbers�s���
�I�I�O�O�H�%�����A��	7�A��!�!�!�"2�"2�"4�c�:��!�!�!�+�+�-��5��!�!�!�"8�"8�":�C�@��!�!�!�+�+�-��5��!�!�!�,�,�.�#�6�	7�	
������,�,�.����
�>�������-�-�/�����@r!c����Gd�d�}|��d��fd�}|�j_d�j_�j�jj	��j
��j�jj
��j��j�jj��j��j�jj��j��j�jj��j�y)z�
        Verify that the right numbers come back from the right accessor methods
        for file inode/device/nlinks/uid/gid (in a POSIX environment)
        c� �eZdZdZdZdZdZdZy)�<FilePathTests.test_statinfoNumbersAreValid.<locals>.FakeStat��i,i�rFiXN)r$r%r&�st_ino�st_dev�st_nlink�st_uid�st_gidr(r!r �FakeStatrb�s���F��F��H��F��Fr!ric�(����j_yr-)r/�	_statinfo)�args�kwargs�fakers  ��r �
fakeRestatz>FilePathTests.test_statinfoNumbersAreValid.<locals>.fakeRestats���"&�D�I�I�r!N)rlr�rmr�r"r�)r/r�rkr[rVrdrWrerXrfrYrgrZrh)rrirorns`  @r �test_statinfoNumbersAreValidz*FilePathTests.test_statinfoNumbersAreValid�s����	�	��z��	'�&��	�	��#��	�	��������1�1�3�T�[�[�A�������,�,�.����<�������7�7�9�4�=�=�I�������,�,�.����<�������-�-�/����=r!Nr�)r�zCallable[[], None]r"r�)r"zList[Tuple[str, str]])Hr$r%r&r'rQrVr�symlinkSkiprYr]r_rfrqrtrzr}r�r�r�r�r�r�r�r�r�getTyper�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
rrr r&r*r-r/r3r7r9r;r@rDr�rHrKrOrSr[r_rpr(r!r rJrJis����
�	
��K�=�>�
�?�
��K�=�>�R�?�R�X��K�=�>�
?�?�
?��K�=�>�+�?�+�*�K�=�>�0�?�0�.�&��K�=�>�$�?�$��K�=�>�=�?�=�&�K�=�>�
�?�
�"
;�Q�
%�&7�
L�
��H����'�)�+K�L�S�M�S���H����'�)�+K�L�	M�M�	M�M�
�0�9�

�-��K�=�>�
;�?�
;�
-�/�&
/�
��K�=�>�
�?�
��K�=�>�
�?�
�2�-�&�(&�?K�+�>	.�
��.
%��K�=�>�%�?�%��K�=�>�%�?�%�*�"L=�\
'�'� 	%�$�$�
8�%�
8�8�&*�,��H��� �"@�A�
�B�
� *��"��"�"�$�$�&E�F�
�G�
�,/��"��"�"�$�$�&E�F�E�G�E���H��� �"@�A�
A�B�
A���H��� �"@�A�>�B�>r!rJc�@�eZdZdZd	d�Zd	d�Zd	d�Zd
d�Zd	d�Zd	d�Z	y)�SetContentTestsz+
    Tests for L{FilePath.setContent}.
    c��|j�}tj|�}|jd�t	|d�5}|j�}ddd�|j
d�y#1swY�xYw)zx
        Contents of the file referred to by a L{FilePath} can be written using
        L{FilePath.setContent}.
        shello, worldrN)rrrNrvr?r�r[)r�
pathStringr/rC�contentss     r �
test_writezSetContentTests.test_writesg��
�[�[�]�
�� � ��,������(�
�*�d�
#�	#�t��y�y�{�H�	#�����(�3�	#�	#�s�A/�/A8c��td�}|jt|jd�|j	|j
j�y)z�
        If writing to the underlying file raises an exception,
        L{FilePath.setContent} raises that exception after closing the file.
        rsblahN)r�rbr|rvrSr�r�r�s  r �test_fileClosingz SetContentTests.test_fileClosing$s8��
�r�
"�����'�2�=�=�'�:���������%r!c��t|j��}|jd�|jd�|j�}|j	t|�d�|j
|d|d�y)z�
        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.
        salphasbetar�rrN)r�rrvr�r[r�r)rr��openedSiblingss   r �test_nameCollisionz"SetContentTests.test_nameCollision-si���d�k�k�m�
,��
�
�
�h��
�
�
�g�����)������^�,�a�0����N�1�-�~�a�/@�Ar!c��|j�}|jt|�dd�|j|dj	�j�j
|�dj|dj�|��y)aA
        Assert that the L{TrackingFilePath} C{fp} was used to open one sibling
        with the given extension.

        @param fp: A L{TrackingFilePath} which should have been used to open
            file at a sibling path.
        @type fp: L{TrackingFilePath}

        @param extension: The extension the sibling path is expected to have
            had.
        @type extension: L{str}

        @raise: C{self.failureException} is raised if the extension of the
            opened file is incorrect or if not exactly one file was opened
            using C{fp}.
        rz expected exactly one opened filerz%{!r} does not end with {!r} extensionN)r�r[r�rS�
asTextModer�r��format)rr��	extension�openeds    r �_assertOneOpenedz SetContentTests._assertOneOpened=sw��"���!������V��a�)K�L�����1�I� � �"�+�+�-�6�6�y�A�3�:�:��q�	�"�"�$�i�
�	
r!c�|�t|j��}|jd�|j|d�y)z�
        L{FilePath.setContent} creates temporary files with the extension
        I{.new} if no alternate extension value is given.
        shelloz.newN�r�rrvr�r�s  r �test_defaultExtensionz%SetContentTests.test_defaultExtensionWs0��
�d�k�k�m�
,��
�
�
�h�����b�&�)r!c�~�t|j��}|jdd�|j|d�y)z�
        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.
        sgoodbyes-something-elsez-something-elseNr�r�s  r �test_customExtensionz$SetContentTests.test_customExtension`s4���d�k�k�m�
,��
�
�
�j�"4�5����b�"3�4r!Nr�)r�zTrackingFilePath[AnyStr]r�r
r"r�)
r$r%r&r'rxrzr}r�r�r�r(r!r rtrts&���
4�&�B� 
�4*�5r!rtc��eZdZdZd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Z	d)d�Z
d)d	�Zd)d
�Zd)d�Z
eej �d�d)d
��Zeej �d�d)d��Zeej �d�d)d��Zeej �d�d)d��Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Zd)d�Z d)d�Z!d)d�Z"d)d �Z#d)d!�Z$d)d"�Z%d)d#�Z&d)d$�Z'd)d%�Z(d)d&�Z)d)d'�Z*y()*�UnicodeFilePathTestszp
    L{FilePath} instances should have the same internal representation as they
    were instantiated with.
    c��tjd�}|jt|j�t
�y)ze
        L{FilePath} instantiated with a text path will return a text-mode
        FilePath.
        �	./mon€yN)rrNr[r�r/r
r�s  r �test_UnicodeInstantiationz.UnicodeFilePathTests.test_UnicodeInstantiationqs,��
�
�
�~�
.������b�g�g���,r!c��tjd�}|jdj��}|j	t|j�t�y)z�
        Calling L{FilePath.child} on a text-mode L{FilePath} with a L{bytes}
        subpath will return a bytes-mode FilePath.
        �./parent-mon€y�
child-mon€yN�rrNr\rr[r�r/r#�rr�r\s   r �#test_UnicodeInstantiationBytesChildz8UnicodeFilePathTests.test_UnicodeInstantiationBytesChildysF��
�
�
�4�
5�����+�2�2�4�5������e�j�j�)�5�1r!c��tjd�}|jd�}|jt	|j
�t�y)z�
        Calling L{FilePath.child} on a text-mode L{FilePath} with a text
        subpath will return a text-mode FilePath.
        r�r�N)rrNr\r[r�r/r
r�s   r �%test_UnicodeInstantiationUnicodeChildz:UnicodeFilePathTests.test_UnicodeInstantiationUnicodeChild�s<��
�
�
�4�
5������&������e�j�j�)�3�/r!c��tjd�}|jd�}|jt	|j
�t�y)z�
        Calling L{FilePath.preauthChild} on a text-mode L{FilePath} with a text
        subpath will return a text-mode FilePath.
        r�r�N)rrNr�r[r�r/r
r�s   r �,test_UnicodeInstantiationUnicodePreauthChildzAUnicodeFilePathTests.test_UnicodeInstantiationUnicodePreauthChild�s<��
�
�
�4�
5������-������e�j�j�)�3�/r!c��tjd�}|jdj��}|j	t|j�t�y)z�
        Calling L{FilePath.preauthChild} on a text-mode L{FilePath} with a bytes
        subpath will return a bytes-mode FilePath.
        r�r�N)rrNr�rr[r�r/r#r�s   r �*test_UnicodeInstantiationBytesPreauthChildz?UnicodeFilePathTests.test_UnicodeInstantiationBytesPreauthChild�sF��
�
�
�4�
5����� 2� 9� 9� ;�<������e�j�j�)�5�1r!c��tjd�}|jt|j�t
�y)zj
        L{FilePath} instantiated with a L{bytes} path will return a bytes-mode
        FilePath.
        �./N)rrNr[r�r/r#r�s  r �test_BytesInstantiationz,UnicodeFilePathTests.test_BytesInstantiation�s,��
�
�
�u�
%������b�g�g���.r!c��tjd�}|jdj��}|j	t|j�t�y)z�
        Calling L{FilePath.child} on a bytes-mode L{FilePath} with a bytes
        subpath will return a bytes-mode FilePath.
        r�r�Nr�r�s   r �!test_BytesInstantiationBytesChildz6UnicodeFilePathTests.test_BytesInstantiationBytesChild�sE��
�
�
�u�
%�����+�2�2�4�5������e�j�j�)�5�1r!c��tjdj��}|jd�}|j	t|j�t�y)z�
        Calling L{FilePath.child} on a bytes-mode L{FilePath} with a text
        subpath will return a text-mode FilePath.
        uparent-mon€yr�N)rrNrr\r[r�r/r
r�s   r �#test_BytesInstantiationUnicodeChildz8UnicodeFilePathTests.test_BytesInstantiationUnicodeChild�sE��
�
�
�2�9�9�;�
<������&������e�j�j�)�3�/r!c���tjdj��}|jdj��}|j	t|j�t�y)z�
        Calling L{FilePath.preauthChild} on a bytes-mode L{FilePath} with a
        bytes subpath will return a bytes-mode FilePath.
        r�r�N)rrNrr�r[r�r/r#r�s   r �(test_BytesInstantiationBytesPreauthChildz=UnicodeFilePathTests.test_BytesInstantiationBytesPreauthChild�sO��
�
�
�4�;�;�=�
>����� 2� 9� 9� ;�<������e�j�j�)�5�1r!c��tjdj��}|jd�}|j	t|j�t�y)z�
        Calling L{FilePath.preauthChild} on a bytes-mode L{FilePath} with a text
        subpath will return a text-mode FilePath.
        r�r�N)rrNrr�r[r�r/r
r�s   r �*test_BytesInstantiationUnicodePreauthChildz?UnicodeFilePathTests.test_BytesInstantiationUnicodePreauthChild�sE��
�
�
�4�;�;�=�
>������-������e�j�j�)�3�/r!zTest will not work on Windowsc�h�tjd�}t|�}|jd|�y)�S
        The repr of a L{unicode} L{FilePath} shouldn't burst into flames.
        r�uFilePath('/mon€y')N�rrN�reprr[�rr��
reprOutputs   r �test_unicodereprz%UnicodeFilePathTests.test_unicoderepr�s.��
�
�
�}�
-���"�X�
����2�J�?r!c��tjdj��}t|�}|j	d|�y)�Q
        The repr of a L{bytes} L{FilePath} shouldn't burst into flames.
        u/parent-mon€yz%FilePath(b'/parent-mon\xe2\x82\xacy')N)rrNrr�r[r�s   r �test_bytesreprz#UnicodeFilePathTests.test_bytesrepr�s8��
�
�
�3�:�:�<�
=���"�X�
����C�Z�Pr!zTest only works on Windowsc�h�tjd�}t|�}|jd|�y)r�zC:\zFilePath('C:\\')Nr�r�s   r �test_unicodereprWindowsz,UnicodeFilePathTests.test_unicodereprWindows�s.��
�
�
�v�
&���"�X�
����-�z�:r!c�h�tjd�}t|�}|jd|�y)r�sC:\zFilePath(b'C:\\')Nr�r�s   r �test_bytesreprWindowsz*UnicodeFilePathTests.test_bytesreprWindows�s.��
�
�
�w�
'���"�X�
����.�
�;r!c��tjd�}|jd�}|j|djt
�y)zT
        C{globChildren} will return the same type as the pattern argument.
        �/r�rN)rrN�globChildrenr]r/r#�rr�r�s   r �test_mixedTypeGlobChildrenz/UnicodeFilePathTests.test_mixedTypeGlobChildren�s<���
�
�s�
#���?�?�4�(�����h�q�k�.�.��6r!c��tjd�}|jd�}|j|djt
�y)z8
        C{globChildren} works with L{unicode}.
        r��*rN)rrNr�r]r/r
r�s   r �test_unicodeGlobChildrenz-UnicodeFilePathTests.test_unicodeGlobChildren�s<���
�
�s�
#���?�?�3�'�����h�q�k�.�.��4r!c�v�tjd�}|j|j�t�y)zQ
        Calling C{basename} on an text- L{FilePath} returns L{unicode}.
        �./N)rrNr]r�r
r�s  r �test_unicodeBasenamez)UnicodeFilePathTests.test_unicodeBasename�s*���
�
�t�
$�����b�k�k�m�S�1r!c�v�tjd�}|j|j�t�y)zS
        Calling C{dirname} on a text-mode L{FilePath} returns L{unicode}.
        r�N)rrNr]r;r
r�s  r �test_unicodeDirnamez(UnicodeFilePathTests.test_unicodeDirnames*���
�
�t�
$�����b�j�j�l�C�0r!c��tjd�}|j�}|j|jt
�y)zk
        Calling C{parent} on a text-mode L{FilePath} will return a text-mode
        L{FilePath}.
        r�N)rrNr�r]r/r
)rr�r�s   r �test_unicodeParentz'UnicodeFilePathTests.test_unicodeParents3��
�
�
�t�
$����������f�k�k�3�/r!c��tjd�}|jd�}|j|jt
�y)zx
        A L{bytes} extension to C{temporarySibling} will mean a L{bytes} mode
        L{FilePath} is returned.
        r��.txtN)rrNr�r]r/r#�rr��tempSiblings   r �test_mixedTypeTemporarySiblingz3UnicodeFilePathTests.test_mixedTypeTemporarySiblings:��
�
�
�~�
.���)�)�'�2�����k�.�.��6r!c��tjd�}|jd�}|j|jt
�y)z|
        A L{unicode} extension to C{temporarySibling} will mean a L{unicode}
        mode L{FilePath} is returned.
        u/tmp/mon€y�.txtN)rrNr�r]r/r
r�s   r �test_unicodeTemporarySiblingz1UnicodeFilePathTests.test_unicodeTemporarySiblings;��
�
�
�0�
1���)�)�&�1�����k�.�.��4r!c�D�tjd�}tj|j�dz�}|j�|j	d�}|�J�|j|tj�|j|jt�y)z�
        C{siblingExtensionSearch} called with L{bytes} on a L{unicode}-mode
        L{FilePath} will return a L{list} of L{bytes}-mode L{FilePath}s.
        r�r�r�N)rrN�_asTextPathr�r�r]r/r#�rr�r��newPaths    r �$test_mixedTypeSiblingExtensionSearchz9UnicodeFilePathTests.test_mixedTypeSiblingExtensionSearch&s��
�
�
�~�
.���#�#�B�N�N�$4�v�$=�>���
�
���+�+�G�4���"�"�"����g�x�'8�'8�9����g�l�l�E�2r!c�D�tjd�}tj|j�dz�}|j�|j	d�}|�J�|j|tj�|j|jt�y)z�
        C{siblingExtensionSearch} called with L{unicode} on a L{unicode}-mode
        L{FilePath} will return a L{list} of L{unicode}-mode L{FilePath}s.
        r�r�N)rrNr�r�r�r]r/r
r�s    r �"test_unicodeSiblingExtensionSearchz7UnicodeFilePathTests.test_unicodeSiblingExtensionSearch4s��
�
�
�~�
.���#�#�B�N�N�$4�v�$=�>���
�
���+�+�F�3���"�"�"����g�x�'8�'8�9����g�l�l�C�0r!c�<�tjd�}tj|j�dz�}|j�|j	d�}|j|tj�|j|jt�y)z�
        C{siblingExtension} called with L{bytes} on a L{unicode}-mode
        L{FilePath} will return a L{bytes}-mode L{FilePath}.
        r�r�r�N)rrNr�r�r�r]r/r#r�s    r �test_mixedTypeSiblingExtensionz3UnicodeFilePathTests.test_mixedTypeSiblingExtensionCss��
�
�
�~�
.���#�#�B�N�N�$4�v�$=�>���
�
���%�%�g�.�����g�x�'8�'8�9����g�l�l�E�2r!c�<�tjd�}tj|j�dz�}|j�|j	d�}|j|tj�|j|jt�y)z�
        C{siblingExtension} called with L{unicode} on a L{unicode}-mode
        L{FilePath} will return a L{unicode}-mode L{FilePath}.
        r�r�N)rrNr�r�r�r]r/r
r�s    r �test_unicodeSiblingExtensionz1UnicodeFilePathTests.test_unicodeSiblingExtensionQss��
�
�
�~�
.���#�#�B�N�N�$4�v�$=�>���
�
���%�%�f�-�����g�x�'8�'8�9����g�l�l�C�0r!c���tj|j��}|j�tj|j��}|j	|jd�|j
��|j	|jd�|j��|j	|jd�d�|j	|jd�d�y)z~
        C{siblingExtension} passed an empty string should return the same path,
        in the type of its argument.
        r!rN)rrNrr�r[r��asBytesModer)rrs�	notExistss   r �test_selfSiblingExtensionSearchz4UnicodeFilePathTests.test_selfSiblingExtensionSearch_s���
�"�"�4�;�;�=�1�������%�%�d�k�k�m�4�	�����6�6�s�;�V�=O�=O�=Q�R�����6�6�r�:�F�<M�<M�<O�P�����9�9�"�=�t�D�����9�9�#�>��Er!c�d��tjd���j�|j�fd���j	d�}|j��j
d�}|�J�|j|tj�|j|jt�y)z�
        C{childSearchPreauth} called with L{bytes} on a L{unicode}-mode
        L{FilePath} will return a L{bytes}-mode L{FilePath}.
        r�c�$���j�Sr-�r��r�s�r r�zGUnicodeFilePathTests.test_mixedTypeChildSearchPreauth.<locals>.<lambda>s�
����	�	��r!�text.txtstext.txtN)
rrNr�rNr\r��childSearchPreauthr]r/r#�rr\r�r�s   @r � test_mixedTypeChildSearchPreauthz5UnicodeFilePathTests.test_mixedTypeChildSearchPreauthls����
�
�
�~�
.��
�������+�,�����$��
���
��'�'��4���"�"�"����g�x�'8�'8�9����g�l�l�E�2r!c�d��tjd���j�|j�fd���j	d�}|j��j
d�}|�J�|j|tj�|j|jt�y)z�
        C{childSearchPreauth} called with L{unicode} on a L{unicode}-mode
        L{FilePath} will return a L{unicode}-mode L{FilePath}.
        r�c�$���j�Sr-r�r�s�r r�zEUnicodeFilePathTests.test_unicodeChildSearchPreauth.<locals>.<lambda>�r�r!r�N)
rrNr�rNr\r�r�r]r/r
r�s   @r �test_unicodeChildSearchPreauthz3UnicodeFilePathTests.test_unicodeChildSearchPreauth}s����
�
�
�~�
.��
�������+�,�����$��
���
��'�'�
�3���"�"�"����g�x�'8�'8�9����g�l�l�C�0r!c��tjd�}|j�}|j||�|j	|j
t�y)�r
        C{asBytesMode} on a L{unicode}-mode L{FilePath} returns a new
        L{bytes}-mode L{FilePath}.
        �./tmpN)rrNr�r�r]r/r#�rr��newfps   r �test_asBytesModeFromUnicodez0UnicodeFilePathTests.test_asBytesModeFromUnicode�sD��
�
�
�w�
'����� ������U�#����e�j�j�%�0r!c��tjd�}|j�}|j||�|j	|j
t�y)r��./tmpN)rrNrr�r]r/r
r�s   r �test_asTextModeFromBytesz-UnicodeFilePathTests.test_asTextModeFromBytes�sC��
�
�
�x�
(���
�
�������U�#����e�j�j�#�.r!c��tjd�}|j�}|j||�|j	|j
t�y)zs
        C{asBytesMode} on a L{bytes}-mode L{FilePath} returns the same
        L{bytes}-mode L{FilePath}.
        r�N)rrNr�r�r]r/r#r�s   r �test_asBytesModeFromBytesz.UnicodeFilePathTests.test_asBytesModeFromBytes�sB��
�
�
�x�
(����� ���
�
�b�%� ����e�j�j�%�0r!c��tjd�}|j�}|j||�|j	|j
t�y)zv
        C{asTextMode} on a L{unicode}-mode L{FilePath} returns the same
        L{unicode}-mode L{FilePath}.
        r�N)rrNrr�r]r/r
r�s   r �test_asTextModeFromUnicodez/UnicodeFilePathTests.test_asTextModeFromUnicode�sA��
�
�
�w�
'���
�
����
�
�b�%� ����e�j�j�#�.r!c��tjd�}|jd��}|jd|j�y)z�
        C{asBytesMode} with an C{encoding} argument uses that encoding when
        coercing the L{unicode}-mode L{FilePath} to a L{bytes}-mode L{FilePath}.
        �☃r��encoding�☃N)rrNr�r	r/r�s   r �'test_asBytesModeFromUnicodeWithEncodingz<UnicodeFilePathTests.test_asBytesModeFromUnicodeWithEncoding�s6��
�
�
�x�
(�������0���
�
�o�u�z�z�2r!c��tjd�}|jd��}|jd|j�y)z�
        C{asTextMode} with an C{encoding} argument uses that encoding when
        coercing the L{bytes}-mode L{FilePath} to a L{unicode}-mode L{FilePath}.
        r�rr�r�N)rrNrr	r/r�s   r �$test_asTextModeFromBytesWithEncodingz9UnicodeFilePathTests.test_asTextModeFromBytesWithEncoding�s6��
�
�
��
/���
�
�w�
�/���
�
�h��
�
�+r!c��tjd�}|jt�5|j	d��ddd�y#1swYyxYw)z�
        C{asBytesMode} with an C{encoding} argument that can't be used to encode
        the unicode path raises a L{UnicodeError}.
        r��asciir�N)rrNrb�UnicodeErrorr�r�s  r �/test_asBytesModeFromUnicodeWithUnusableEncodingzDUnicodeFilePathTests.test_asBytesModeFromUnicodeWithUnusableEncoding�sE��
�
�
�x�
(��
�
�
�|�
,�	-��N�N�G�N�,�	-�	-�	-���A�Ac��tjd�}|jt�5|j	d��ddd�y#1swYyxYw)z�
        C{asTextMode} with an C{encoding} argument that can't be used to encode
        the unicode path raises a L{UnicodeError}.
        s\u2603zutf-32r�N)rrNrbr�rr�s  r �,test_asTextModeFromBytesWithUnusableEncodingzAUnicodeFilePathTests.test_asTextModeFromBytesWithUnusableEncoding�sE��
�
�
�z�
*��
�
�
�|�
,�	-��M�M�8�M�,�	-�	-�	-�r�Nr�)+r$r%r&r'r�r�r�r�r�r�r�r�r�r�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr(r!r r�r�ksV���
-�2�0�0�2�/�2�0�2�0���H��� �"A�B�@�C�@���H��� �"A�B�Q�C�Q��"��"�"�$�$�&B�C�;�D�;��"��"�"�$�$�&B�C�<�D�<�7�5�2�1�0�7�5�3�
1�3�1�F�3�"1�"1�/�1�/�3�,�-�-r!r�)7r'�
__future__rr��ior.r�r&�sysrH�pprintr�typingrrrrr	r
rrr
�unittestr�zope.interface.verifyrr�twisted.pythonr�twisted.python.filepathrr�twisted.python.runtimer�twisted.python.win32r�twisted.trial.unittestrr�_supportsSymlinksrqrr*rNr�r�r�r�r�r�r�r�rJrtr�r(r!r �<module>rs6���#��	�	�
��
���T�T�T��.��#�9�+�0�B�,�(�,�,�.�.��	5�H�	5�z6�M�z6�z
�h�'�'��/�
�4�<�<�7��
�
�#!�
�#!�L!�!�H<�x�(�(��0�<�~/?��)�)�&�1�/?�d�C�L��]O�}�]O�@g>�)�g>�TU5�m�U5�pm-�8�m-r!

Zerion Mini Shell 1.0