o
    Óó·i?  ã                   @  sr   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d„ZG dd„ deƒZdS )z0
Test cases covering L{twisted.python.zippath}.
é    )ÚannotationsN)ÚUnion)Ú_coerceToFilesystemEncoding)Ú
ZipArchiveÚZipPath)ÚAbstractFilePathTestsÚdirnameústr | bytesÚzfnameÚreturnÚNonec                 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)r   r
   ZcoercedDirnameZcoercedZfnameÚzfÚrootZignoredÚfilesÚfnameÚfspathZarcpath© r   úfC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\twisted/python/test/test_zippath.pyÚzipit   s   

üýû"ÿr   c                   @  sT   e Zd ZU dZded< ded< ddd„Zdd	d
„Zddd„Zddd„Zddd„Z	dS )ÚZipFilePathTestszk
    Test various L{ZipPath} path manipulations as well as reprs for L{ZipPath}
    and L{ZipArchive}.
    zZipArchive[bytes]r   r   r   r   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>4   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¡| j d¡¡ dS )zF
        L{ZipPath.sibling} returns a path at the same level.
        ZoneZtwoN)ÚassertEqualr   ÚchildZsiblingr&   r   r   r   Útest_sibling6   s   &zZipFilePathTests.test_siblingc                 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   r-   Úformatr   Úabspathr*   Úsepr,   Úreprr"   Úgetcwdr   )r'   r-   ÚpathReprÚrelativeCommonÚrelpathr   r   r   Útest_zipPathRepr<   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)r0   )r   r/   r:   r;   N)r   r-   r*   r   r3   r   r,   r4   )r'   r-   r6   r   r   r   Ú test_zipPathReprParentDirSegmentQ   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.
        r0   zZipArchive({!r})r   r   N)r   r*   r1   r   r   r2   r,   r4   r"   r5   r3   )r'   r   r6   r7   r8   r   r   r   Útest_zipArchiveRepr]   s   z$ZipFilePathTests.test_zipArchiveReprN)r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r)   r.   r9   r<   r=   r   r   r   r   r    %   s   
 



r    )r   r	   r
   r	   r   r   )rA   Ú
__future__r   r   r   Útypingr   Ztwisted.python.filepathr   Ztwisted.python.zippathr   r   Ztwisted.test.test_pathsr   r   r    r   r   r   r   Ú<module>   s   
