
    tf?                    ~    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dS )z0
Test cases covering L{twisted.python.zippath}.
    )annotationsN)Union)_coerceToFilesystemEncoding)
ZipArchiveZipPath)AbstractFilePathTestsdirnamestr | byteszfnamereturnNonec                   t          d|           }t          d|          }t          j        |d          5 }t          j        |          D ]y\  }}}|D ]p}t          j                            ||          }	t          j                            ||          t          |           dz   d         }
|                    |	|
           qz	 ddd           dS # 1 swxY w 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arcpaths              _/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/python/test/test_zippath.pyzipitr$      s,    1W==N/F;;M		,	, 	*
 W^$$		* 	* 
 * *dE22',,tU33CLL14D4F4FG))))*	*	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   BCCCc                  P    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	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                    t          j                    t           j         j        dz              t	          d j                   _        t           j        dz              _         j         _         fd j	        D              _	        d S )N   .zipr   c                V    g | ]%}|                     j        j        d z             &S )r(   )replacecmn).0xselfs     r#   
<listcomp>z*ZipFilePathTests.setUp.<locals>.<listcomp>4   s0    NNNAIIdh7(:;;NNN    )
r   setUpr$   r+   r   	nativecmnr   r   r   allr.   s   `r#   r1   zZipFilePathTests.setUp.   s    #D)))dh7*+++4RBBtx'122	I	NNNNTXNNNr0   c                    |                      | j                            d                              d          | j                            d                     dS )zF
        L{ZipPath.sibling} returns a path at the same level.
        onetwoN)assertEqualr   childsiblingr4   s    r#   test_siblingzZipFilePathTests.test_sibling6   sK     	//77>>	PU@V@VWWWWWr0   c                   | j                             d          }d                    t          j                             | j        dz   t          j        z   dz                       }|                     t          |          |           | j        	                    t          j
                    t          j        z   dd          dz   }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   r9   formatr   abspathr2   sepr8   reprr*   getcwdr   )r.   r9   pathReprrelativeCommonrelpaths        r#   test_zipPathReprz!ZipFilePathTests.test_zipPathRepr<   s    
 @Dyu?U?U"))GOODNV3bf<uDEE
 

 	eh/// //	bf0Db!LLvU^,,e$$ 	eh/////r0   c                *   | j                             d                              d                              d          }d| j        dz   t          j                            g d          z   z  }|                     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=   rI   rJ   N)r   r9   r2   r   rA   r   r8   rB   )r.   r9   rD   s      r#    test_zipPathReprParentDirSegmentz1ZipFilePathTests.test_zipPathReprParentDirSegmentQ   s     	&&,,T2288?? NV#bfkk2J2J2J&K&KK
 	eh/////r0   c                   t          | j        dz             }d                    t          j                            | j        dz                       }|                     t          |          |           | j                            t          j	                    t          j
        z   dd          dz   }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   r2   r?   r   r   r@   r8   rB   r*   rC   rA   )r.   r   rD   rE   rF   s        r#   test_zipArchiveReprz$ZipFilePathTests.test_zipArchiveRepr]   s    
 $.6122%,,RW__T^f=T-U-UVV 	dX... //	bf0Db!LLvU^,, 	g11111r0   N)r   r   )
__name__
__module____qualname____doc____annotations__r1   r;   rG   rK   rM    r0   r#   r&   r&   %   s          
 O O O OX X X X0 0 0 0*
0 
0 
0 
02 2 2 2 2 2r0   r&   )r	   r
   r   r
   r   r   )rQ   
__future__r   r   r   typingr   twisted.python.filepathr   twisted.python.zippathr   r   twisted.test.test_pathsr   r$   r&   rS   r0   r#   <module>rY      s     # " " " " " 				        ? ? ? ? ? ? 6 6 6 6 6 6 6 6 9 9 9 9 9 9* * * *&H2 H2 H2 H2 H2, H2 H2 H2 H2 H2r0   