o
    b-                     @   sT   d Z ddlZddlZddlmZ ddlmZ ddlmZ dd Z	G dd	 d	eZ
dS )
z0
Test cases covering L{twisted.python.zippath}.
    N)_coerceToFilesystemEncoding)
ZipArchive)AbstractFilePathTestsc           	      C   s   t d| } t d|}t|d5}t| D ]&\}}}|D ]}tj||}tj||t| d d }||| qqW d   dS 1 sHw   Y  dS )zI
    Create a zipfile on zfname, containing the contents of dirname'
     w   N)	r   zipfileZipFileoswalkpathjoinlenwrite)	dirnamezfnamezfrootignoredfilesfnamefspatharcpath r   B/usr/lib/python3/dist-packages/twisted/python/test/test_zippath.pyzipit   s   

"r   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )ZipFilePathTestszk
    Test various L{ZipPath} path manipulations as well as reprs for L{ZipPath}
    and L{ZipArchive}.
    c                    s\   t   t j jd  td j _t jd  _ j _ fdd j	D  _	d S )N   .zipr   c                    s    g | ]}|  j jd  qS )r   )replacecmn).0xselfr   r   
<listcomp>0   s     z*ZipFilePathTests.setUp.<locals>.<listcomp>)
r   setUpr   r   r   	nativecmnr   r   r   allr"   r   r"   r   r%   *   s   
zZipFilePathTests.setUpc                 C   s   | j d}dtj | jd tj d }| t|| | j	t
 tj ddd }t|}|d}| t|| dS )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   childformatr
   abspathr&   sepassertEqualreprr   getcwdr   )r#   r*   pathReprrelativeCommonrelpathr   r   r   test_zipPathRepr2   s   
z!ZipFilePathTests.test_zipPathReprc                 C   sJ   | j ddd}d| jd tjg d  }| t|| dS )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.
        r(   ..barzZipPath(%r)r)   )r   r(   r5   r6   N)r   r*   r&   r
   r-   r   r.   r/   )r#   r*   r1   r   r   r    test_zipPathReprParentDirSegmentG   s
   z1ZipFilePathTests.test_zipPathReprParentDirSegmentc                 C   sp   t | jd }dtj| jd }| t|| | jt	 tj
 ddd }t |}| t|| dS )z
        Make sure that invoking ZipArchive's repr prints the correct class
        name and an absolute path to the zip file.
        r)   zZipArchive({!r})r   r   N)r   r&   r+   r
   r   r,   r.   r/   r   r0   r-   )r#   r   r1   r2   r3   r   r   r   test_zipArchiveReprS   s   z$ZipFilePathTests.test_zipArchiveReprN)__name__
__module____qualname____doc__r%   r4   r7   r8   r   r   r   r   r   $   s    r   )r<   r
   r   twisted.python.filepathr   twisted.python.zippathr   twisted.test.test_pathsr   r   r   r   r   r   r   <module>   s   