Ë
    oj?  ã                  óv   — d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZ ddlmZ dd„Z G d	„ d
e«      Zy)z0
Test cases covering L{twisted.python.zippath}.
é    )ÚannotationsN)ÚUnion)Ú_coerceToFilesystemEncoding)Ú
ZipArchiveÚZipPath)ÚAbstractFilePathTestsc                ó˜  — t        d| «      }t        d|«      }t        j                  |d«      5 }t        j                  |«      D ]n  \  }}}|D ]c  }t        j
                  j                  ||«      }	t        j
                  j                  ||«      t        | «      dz   d }
|j                  |	|
«       Œe Œp 	 ddd«       y# 1 sw Y   yxY w)zI
    Create a zipfile on zfname, containing the contents of dirname'
    Ú Úwé   N)	r   ÚzipfileÚZipFileÚosÚwalkÚpathÚjoinÚlenÚwrite)ÚdirnameÚzfnameÚcoercedDirnameÚcoercedZfnameÚzfÚrootÚignoredÚfilesÚfnameÚfspathÚarcpaths              úB/usr/lib/python3/dist-packages/twisted/python/test/test_zippath.pyÚzipitr!      s½   € ô 1°°WÓ=€NÜ/°°FÓ;€Mä	�‰˜¨Ó	,ð 	*°ô
 �W‰W�^Ó$ò		*ñ 
ØØØàò *�ÜŸ™Ÿ™ d¨EÓ2�ÜŸ'™'Ÿ,™, t¨UÓ3´C¸³LÀ1Ñ4DÐ4FÐG�Ø—‘˜ Õ)ñ*ñ	*÷	*÷ 	*ñ 	*ús   ¯BC Ã C	c                  óN   — e Zd ZU dZded<   ded<   dd„Zdd„Zdd„Zdd„Zdd	„Z	y
)ÚZipFilePathTestszk
    Test various L{ZipPath} path manipulations as well as reprs for L{ZipPath}
    and L{ZipArchive}.
    zZipArchive[bytes]r   r   c                óœ  — t        j                  | «       t        | j                  | j                  dz   «       t	        d| j                  «      | _        t        | j                  dz   «      | _        | j                  | _        | j                  D �cg c]+  }|j                  | j                  | j                  dz   «      ‘Œ- c}| _	        y c c}w )Ns   .zipr
   )r   ÚsetUpr!   Úcmnr   Ú	nativecmnr   r   r   ÚallÚreplace)ÚselfÚxs     r    r%   zZipFilePathTests.setUp.   sŠ   € Ü×#Ñ# DÔ)Üˆd�h‰h˜Ÿ™ 7Ñ*Ô+Ü4°R¸¿¹ÓBˆŒÜ˜tŸx™x¨'Ñ1Ó2ˆŒ	Ø—I‘IˆŒ	ØEIÇXÁXÖNÀ�A—I‘I˜dŸh™h¨¯©°7Ñ(:Õ;ÒNˆ�ùÒNs   Â0C	c                óª   — | j                  | j                  j                  d«      j                  d«      | j                  j                  d«      «       y)zF
        L{ZipPath.sibling} returns a path at the same level.
        ÚoneÚtwoN)ÚassertEqualr   ÚchildÚsibling)r*   s    r    Útest_siblingzZipFilePathTests.test_sibling6   s:   € ð 	×Ñ˜Ÿ™Ÿ™¨Ó/×7Ñ7¸Ó>ÀÇ	Á	ÇÁÐPUÓ@VÕWó    c                ó  — | j                   j                  d«      }dj                  t        j                   j	                  | j
                  dz   t        j                  z   dz   «      «      }| j                  t        |«      |«       | j
                  j                  t        j                  «       t        j                  z   dd«      dz   }t        |«      }|j                  d«      }| j                  t        |«      |«       y)z„
        Make sure that invoking ZipPath's repr prints the correct class name
        and an absolute path to the zip file.
        ÚfoozZipPath({!r})ú.zipr
   r   N)r   r0   Úformatr   Úabspathr'   Úsepr/   Úreprr)   Úgetcwdr   )r*   r0   ÚpathReprÚrelativeCommonÚrelpaths        r    Útest_zipPathReprz!ZipFilePathTests.test_zipPathRepr<   sÁ   € ð
 @D¿y¹y¿¹ÈuÓ?UˆØ"×)Ñ)Ü�G‰G�O‰O˜DŸN™N¨VÑ3´b·f±fÑ<¸uÑDÓEó
ˆð
 	×Ñœ˜e› hÔ/ð Ÿ™×/Ñ/´·	±	³¼b¿f¹fÑ0DÀbÈ!ÓLÈvÑUˆÜ˜^Ó,ˆØ—‘˜eÓ$ˆð 	×Ñœ˜e› hÕ/r3   c                ó  — | j                   j                  d«      j                  d«      j                  d«      }d| j                  dz   t        j                  j                  g d¢«      z   z  }| j                  t        |«      |«       y)z³
        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.
        r5   ú..ÚbarzZipPath(%r)r6   )r
   r5   rA   rB   N)r   r0   r'   r   r9   r   r/   r:   )r*   r0   r<   s      r    Ú test_zipPathReprParentDirSegmentz1ZipFilePathTests.test_zipPathReprParentDirSegmentQ   sk   € ð —	‘	—‘ Ó&×,Ñ,¨TÓ2×8Ñ8¸Ó?ˆØ Ø�N‰N˜VÑ#¤b§f¡f§k¡kÒ2JÓ&KÑKñ
ˆð 	×Ñœ˜e› hÕ/r3   c                ó²  — t        | j                  dz   «      }dj                  t        j                  j                  | j                  dz   «      «      }| j                  t        |«      |«       | j                  j                  t        j                  «       t        j                  z   dd«      dz   }t        |«      }| j                  t        |«      |«       y)z‡
        Make sure that invoking ZipArchive's repr prints the correct class
        name and an absolute path to the zip file.
        r6   zZipArchive({!r})r
   r   N)r   r'   r7   r   r   r8   r/   r:   r)   r;   r9   )r*   r   r<   r=   r>   s        r    Útest_zipArchiveReprz$ZipFilePathTests.test_zipArchiveRepr]   s¡   € ô
 ˜$Ÿ.™.¨6Ñ1Ó2ˆØ%×,Ñ,¬R¯W©W¯_©_¸T¿^¹^ÈfÑ=TÓ-UÓVˆð 	×Ñœ˜d› XÔ.ð Ÿ™×/Ñ/´·	±	³¼b¿f¹fÑ0DÀbÈ!ÓLÈvÑUˆÜ˜^Ó,ˆð 	×Ñœ˜g›¨Õ1r3   N)ÚreturnÚNone)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r%   r2   r?   rC   rE   © r3   r    r#   r#   %   s0   … ñð
 ÓØ
ÓóOóXó0ó*
0ô2r3   r#   )r   ústr | bytesr   rN   rF   rG   )rK   Ú
__future__r   r   r   Útypingr   Útwisted.python.filepathr   Útwisted.python.zippathr   r   Útwisted.test.test_pathsr   r!   r#   rM   r3   r    ú<module>rT      s5   ðñõ #ã 	Û Ý å ?ß 6Ý 9ó*ô&H2Ð,õ H2r3   