
    <eo                        d dl mZ  ej        dd           d dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ d dl
mZ ej        Zedz   Zd	Z G d
 dej                  Z G d dej                  Zedk    r ej                     dS dS )    )supportextralargefilez>test requires loads of disk-space bytes and a long time to runN)TemporaryFile)	os_helper)requires_zlib2<   c                   L    e Zd Zd Zd Zd Z e            d             Zd ZdS )TestsWithSourceFilec                 "   d t          d          D             }d                    |                              d          | _        t	          t
          d          5 }|                    | j                   d d d            d S # 1 swxY w Y   d S )Nc              3       K   | ]	}d |z  V  
dS )zTest of zipfile line %d.N ).0is     */usr/lib/python3.11/test/test_zipfile64.py	<genexpr>z,TestsWithSourceFile.setUp.<locals>.<genexpr>    s(      KKq.2KKKKKK    i@B 
asciiwb)rangejoinencodedataopenTESTFNwrite)selfline_genfps      r   setUpzTestsWithSourceFile.setUp   s    KKE'NNKKKIIh''..w77	 &$ 	 2HHTY	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   BBBc                    t          j        |d|          5 }dt          | j                  z  }t	          j                    t          z   }t          |          D ]}|                    d|z  | j                   |t	          j                    k    rYt	          j                    t          z   }t          d||fz  t          j                   t          j                                         	 d d d            n# 1 swxY w Y   t          j        |d|          5 }t          |          D ]}|                     |                    d|z            | j                   |t	          j                    k    rYt	          j                    t          z   }t          d||fz  t          j                   t          j                                         	 d d d            d S # 1 swxY w Y   d S )Nwl        ztestfn%dz/  zipTest still writing %d of %d, be patient...)filerz/  zipTest still reading %d of %d, be patient...)zipfileZipFilelenr   time	monotonic_PRINT_WORKING_MSG_INTERVALr   writestrprintsys
__stdout__flushassertEqualread)r   fcompressionzipfp	filecount	next_timenums          r   zipTestzTestsWithSourceFile.zipTest'   sT   _Q[11 	+U "S^^3I((+FFIY'' + +zC/;;; 0 000 $ 0 03N NIE)$%,/N< < < < N((***+	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+$ _Q[11 		+UY'' + +  J,<!=!=tyIII 0 000 $ 0 03N NIE)$%,/N< < < < N((***+		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+ 		+s%   CC77C;>C;B4GG!Gc                    t                      5 }|                     |t          j                   |                     |j                   d d d            n# 1 swxY w Y   |                     t          t          j                   d S N)r   r9   r&   
ZIP_STOREDassertFalseclosedTESTFN2r   r3   s     r   
testStoredzTestsWithSourceFile.testStoredF   s     __ 	'LLG.///QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	Wg011111   ;AAAc                    t                      5 }|                     |t          j                   |                     |j                   d d d            n# 1 swxY w Y   |                     t          t          j                   d S r;   )r   r9   r&   ZIP_DEFLATEDr=   r>   r?   r@   s     r   testDeflatedz TestsWithSourceFile.testDeflatedN   s     __ 	'LLG0111QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	Wg233333rB   c                     t           t          fD ]5}t          j                            |          rt          j        |           6d S r;   )r   r?   ospathexistsremove)r   fnames     r   tearDownzTestsWithSourceFile.tearDownW   sF    W_ 	! 	!Ew~~e$$ !	%   	! 	!r   N)	__name__
__module____qualname__r!   r9   rA   r   rE   rL   r   r   r   r   r      sq             + + +>2 2 2 ]__4 4 _4! ! ! ! !r   r   c                        e Zd Zd Zd Zd ZdS )
OtherTestsc                    t          j        t          dd          5 }d|_        d}t	          |          D ]$}|                    d|z  d|dz  d	z  z             %|                     t          |                                          |           d d d            n# 1 swxY w Y   t          j        t          d
          5 }|                     t          |                                          |           t	          |          D ]L}|	                    d|z            
                    d          }|                     |d|dz  d	z  z             M	 d d d            d S # 1 swxY w Y   d S )Nr#   Tmode
allowZip64d     foo%08d%d   9   r%   rT   r   )r&   r'   r   debugr   r,   r1   r(   namelistr2   decode)r   zipfnumfilesr   zipf2contents         r   testMoreThan64kFileszOtherTests.testMoreThan64kFiles^   s    _V#$??? 	=4DJ'H8__ A Ai!mTQTBY-?@@@@S118<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= _V#... 	>%S!1!122H===8__ > >**Y]33::7CC  $!Q$)*<====>	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s%   A3BB #B BE""E&)E&c                    t          j        t          dd          5 }d|_        d}t	          |          D ]$}|                    d|z  d|dz  d	z  z             %|                     t          |                                          |           | 	                    t           j
                  5  |                    d|z  d
           d d d            n# 1 swxY w Y   |                     t          |                                          |           d d d            n# 1 swxY w Y   t          j        t          dd          5 }d|_        |                     t          |                                          |           | 	                    t           j
                  5  |                    d|z  d
           d d d            n# 1 swxY w Y   |                     t          |                                          |           d d d            n# 1 swxY w Y   t          j        t          dd          5 }d|_        |                     t          |                                          |           d}t	          ||          D ]$}|                    d|z  d|dz  d	z  z             %|                     t          |                                          |           d d d            n# 1 swxY w Y   t          j        t          d          5 }|                     t          |                                          |           t	          |          D ]L}|                    d|z                                d          }|                     |d|dz  d	z  z             M	 d d d            d S # 1 swxY w Y   d S )Nr#   FrS   rV   i  rX   rY   rZ   r[   r   aTrW   r%   r\   r   )r&   r'   r   r]   r   r,   r1   r(   r^   assertRaisesLargeZipFiler2   r_   )r   r`   ra   r   	numfiles2rb   rc   s          r   testMoreThan64kFilesAppendz%OtherTests.testMoreThan64kFilesAppendn   s   _V#%@@@ 	=DDJ$H8__ A Ai!mTQTBY-?@@@@S118<<<""7#788 9 9i(2C8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9S118<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= _V#%@@@ 	=DDJS118<<<""7#788 9 9i(2C8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9S118<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= _V#$??? 	>4DJS118<<<(I8Y// A Ai!mTQTBY-?@@@@S119===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> _V#... 	>%S!1!122I>>>9%% > >**Y]33::7CC  $!Q$)*<====>	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   BD!/C	D!C	D!C	8D!!D%(D%AH$G
>H
G	HG	8HHH=B)K22K69K6BN88N<?N<c                 j    t          j        t                     t          j        t                     d S r;   )r   unlinkr   r?   )r   s    r   rL   zOtherTests.tearDown   s*       !!!!!r   N)rM   rN   rO   rd   rj   rL   r   r   r   rQ   rQ   ]   sB        > > > > > >@" " " " "r   rQ   __main__)testr   requiresr&   rG   unittestr)   r.   tempfiler   test.supportr   r   r   r?   r+   TestCaser   rQ   rM   mainr   r   r   <module>ru      sA        
  H  
              



 " " " " " " " " " " " " & & & & & &		
3, ! =! =! =! =! =!(+ =! =! =!@3" 3" 3" 3" 3"" 3" 3" 3"j zHMOOOOO r   