
    Vh?                    v    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y)z0
Test cases covering L{twisted.python.zippath}.
    )annotationsN)Union)_coerceToFilesystemEncoding)
ZipArchiveZipPath)AbstractFilePathTestsc                   t        d|       }t        d|      }t        j                  |d      5 }t        j                  |      D ]n  \  }}}|D ]c  }t        j
                  j                  ||      }	t        j
                  j                  ||      t        |       dz   d }
|j                  |	|
       e p 	 ddd       y# 1 sw Y   yxY w)zI
    Create a zipfile on zfname, containing the contents of dirname'
     w   N)	r   zipfileZipFileoswalkpathjoinlenwrite)dirnamezfnamecoercedDirnamecoercedZfnamezfrootignoredfilesfnamefspatharcpaths              P/home/dcms/DCMS/lib/python3.12/site-packages/twisted/python/test/test_zippath.pyzipitr!      s     1W=N/F;M		, 	*
 WW^$		* 
 *dE2'',,tU3CL14D4FG)*	*	* 	* 	*s   BC  C	c                  N    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	y
)ZipFilePathTestszk
    Test various L{ZipPath} path manipulations as well as reprs for L{ZipPath}
    and L{ZipArchive}.
    zZipArchive[bytes]r   r   c                   t        j                  |        t        | j                  | j                  dz          t	        d| j                        | _        t        | j                  dz         | _        | j                  | _        | j                  D cg c]+  }|j                  | j                  | j                  dz         - c}| _	        y c c}w )Ns   .zipr
   )r   setUpr!   cmnr   	nativecmnr   r   r   allreplace)selfxs     r    r%   zZipFilePathTests.setUp.   s    ##D)dhh7*+4RBtxx'12	II	EIXXNAIIdhh7(:;NNs   0C	c                    | j                  | j                  j                  d      j                  d      | j                  j                  d             y)zF
        L{ZipPath.sibling} returns a path at the same level.
        onetwoN)assertEqualr   childsibling)r*   s    r    test_siblingzZipFilePathTests.test_sibling6   s:     	/77>		PU@VW    c                   | j                   j                  d      }dj                  t        j                   j	                  | j
                  dz   t        j                  z   dz               }| j                  t        |      |       | j
                  j                  t        j                         t        j                  z   dd      dz   }t        |      }|j                  d      }| j                  t        |      |       y)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   r0   formatr   abspathr'   sepr/   reprr)   getcwdr   )r*   r0   pathReprrelativeCommonrelpaths        r    test_zipPathReprz!ZipFilePathTests.test_zipPathRepr<   s    
 @Dyyu?U"))GGOODNNV3bff<uDE

 	eh/ //		bff0Db!LvU^,e$ 	eh/r3   c                   | j                   j                  d      j                  d      j                  d      }d| j                  dz   t        j                  j                  g d      z   z  }| j                  t        |      |       y)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.
        r5   ..barzZipPath(%r)r6   )r
   r5   rA   rB   N)r   r0   r'   r   r9   r   r/   r:   )r*   r0   r<   s      r     test_zipPathReprParentDirSegmentz1ZipFilePathTests.test_zipPathReprParentDirSegmentQ   sk     		&,,T288? NNV#bffkk2J&KK
 	eh/r3   c                   t        | j                  dz         }dj                  t        j                  j                  | j                  dz               }| j                  t        |      |       | j                  j                  t        j                         t        j                  z   dd      dz   }t        |      }| j                  t        |      |       y)z
        Make sure that invoking ZipArchive's repr prints the correct class
        name and an absolute path to the zip file.
        r6   zZipArchive({!r})r
   r   N)r   r'   r7   r   r   r8   r/   r:   r)   r;   r9   )r*   r   r<   r=   r>   s        r    test_zipArchiveReprz$ZipFilePathTests.test_zipArchiveRepr]   s    
 $..612%,,RWW__T^^f=T-UV 	dX. //		bff0Db!LvU^, 	g1r3   N)returnNone)
__name__
__module____qualname____doc____annotations__r%   r2   r?   rC   rE    r3   r    r#   r#   %   s0    
 
OX0*
02r3   r#   )r   str | bytesr   rN   rF   rG   )rK   
__future__r   r   r   typingr   twisted.python.filepathr   twisted.python.zippathr   r   twisted.test.test_pathsr   r!   r#   rM   r3   r    <module>rT      s5    # 	   ? 6 9*&H2, H2r3   