o
    >h?                     @  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
   coercedDirnamecoercedZfnamezfrootignoredfilesfnamefspatharcpath r!   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/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.
        onetwoN)assertEqualr   child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   r3   formatr   abspathr.   sepr2   reprr&   getcwdr   )r+   r3   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.
        r6   ..barzZipPath(%r)r7   )r   r6   rA   rB   N)r   r3   r.   r   r:   r   r2   r;   )r+   r3   r=   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.
        r7   zZipArchive({!r})r   r   N)r   r.   r8   r   r   r9   r2   r;   r&   r<   r:   )r+   r   r=   r>   r?   r!   r!   r"   test_zipArchiveRepr]   s   z$ZipFilePathTests.test_zipArchiveReprN)r   r   )
__name__
__module____qualname____doc____annotations__r-   r5   r@   rC   rD   r!   r!   r!   r"   r$   %   s   
 



r$   )r   r	   r
   r	   r   r   )rH   
__future__r   r   r   typingr   twisted.python.filepathr   twisted.python.zippathr   r   twisted.test.test_pathsr   r#   r$   r!   r!   r!   r"   <module>   s   
