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   