
    daf#                     "   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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&                          yy)    )supportextralargefilez>test requires loads of disk-space bytes and a long time to runN)TemporaryFile)	os_helper)requires_zlib2<   c                   >    e Zd Zd Zd Zd Z e       d        Zd Zy)TestsWithSourceFilec                 r    d t        d      D        }dj                  |      j                  d      | _        y )Nc              3   &   K   | ]	  }d |z    yw)zTest of zipfile line %d.N ).0is     ./root/Python-3.12.4/Lib/test/test_zipfile64.py	<genexpr>z,TestsWithSourceFile.setUp.<locals>.<genexpr>    s     Kq.2Ks   i@B 
ascii)rangejoinencodedata)selfline_gens     r   setUpzTestsWithSourceFile.setUp   s+    KE'NKIIh'..w7	    c                    t        j                  |d|      5 }dt        | j                        z  }t	        j
                         t        z   }t        |      D ]  }|j                  d|z  | j                         |t	        j
                         k  s:t	        j
                         t        z   }t        d||fz  t        j                         t        j                  j                           	 d d d        t        j                  |d|      5 }t              D ]  }| j                  |j                  d|z        | j                         t	        j
                         k  sIt	        j
                         t        z   }t        d||fz  t        j                         t        j                  j                           | j                  |j!                                d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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assertIsNonetestzip)r   fcompressionzipfp	filecount	next_timenums          r   zipTestzTestsWithSourceFile.zipTest#   s   __Q[1 	+U "S^3I(+FFIY' +zC/; 00 $ 03N NIE)$%,/NN< NN((*+	+$ __Q[1 	/UY' +  J,<!=tyyI 00 $ 03N NIE)$%,/NN< NN((*+ emmo.	/ 	/%	+ 	+$	/ 	/s'   A8G$AG$AG0!A:G0$G-0G9c                     t               5 }| j                  |t        j                         | j	                  |j
                         d d d        | j                  t        t        j                         y # 1 sw Y   .xY wN)r   r6   r!   
ZIP_STOREDassertFalseclosedTESTFN2r   r0   s     r   
testStoredzTestsWithSourceFile.testStoredE   s\     _ 	'LLG../QXX&	' 	Wg001	' 	'   <A44A=c                     t               5 }| j                  |t        j                         | j	                  |j
                         d d d        | j                  t        t        j                         y # 1 sw Y   .xY wr8   )r   r6   r!   ZIP_DEFLATEDr:   r;   r<   r=   s     r   testDeflatedz TestsWithSourceFile.testDeflatedM   s\     _ 	'LLG001QXX&	' 	Wg223	' 	'r?   c                 6    t        j                  t               y r8   )r   unlinkr<   r   s    r   tearDownzTestsWithSourceFile.tearDownV   s    !r   N)	__name__
__module____qualname__r   r6   r>   r   rB   rF   r   r   r   r   r      s-    8
 /D2 _4 4"r   r   c                       e Zd Zd Zd Zd Zy)
OtherTestsc                 v   t        j                  t        dd      5 }d|_        d}t	        |      D ]   }|j                  d|z  d|dz  d	z  z         " | j                  t        |j                               |       d d d        t        j                  t        d
      5 }| j                  t        |j                                      t	        |      D ]@  }|j                  d|z        j                  d      }| j                  |d|dz  d	z  z         B 	 d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   Tmode
allowZip64d     foo%08d%d   9   r    rN   r   )r!   r"   TESTFNdebugr   r'   r,   r#   namelistr-   decode)r   zipfnumfilesr   zipf2contents         r   testMoreThan64kFileszOtherTests.testMoreThan64kFiles[   s    __V#$? 	=4DJ'H8_ Ai!mTQTBY-?@AS18<	= __V#. 	>%S!12H=8_ >**Y]3::7C  $!Q$)*<=>	> 	>	= 	=	> 	>s   A!D#!A8D/#D,/D8c                 ~   t        j                  t        dd      5 }d|_        d}t	        |      D ]   }|j                  d|z  d|dz  d	z  z         " | j                  t        |j                               |       | j                  t         j                        5  |j                  d|z  d
       d d d        | j                  t        |j                               |       d d d        t        j                  t        dd      5 }d|_        | j                  t        |j                                      | j                  t         j                        5  |j                  d|z  d
       d d d        | j                  t        |j                               |       d d d        t        j                  t        dd      5 }d|_        | j                  t        |j                                      d}t	        ||      D ]   }|j                  d|z  d|dz  d	z  z         " | j                  t        |j                               |       d d d        t        j                  t        d      5 }| j                  t        |j                                      t	        |      D ]@  }|j                  d|z        j                  d      }| j                  |d|dz  d	z  z         B 	 d d d        y # 1 sw Y   BxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   }xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr   FrM   rP   i  rR   rS   rT   rU   r   aTrQ   r    rV   r   )r!   r"   rW   rX   r   r'   r,   r#   rY   assertRaisesLargeZipFiler-   rZ   )r   r[   r\   r   	numfiles2r]   r^   s          r   testMoreThan64kFilesAppendz%OtherTests.testMoreThan64kFilesAppendk   s   __V#%@ 	=DDJ$H8_ Ai!mTQTBY-?@AS18<""7#7#78 9i(2C89S18<	= __V#%@ 	=DDJS18<""7#7#78 9i(2C89S18<	= __V#$? 	>4DJS18<(I8Y/ Ai!mTQTBY-?@AS19=	> __V#. 	>%S!12I>9% >**Y]3::7C  $!Q$)*<=>	> 	>'9 9	= 	=9 9	= 	=	> 	>	> 	>sc   B L K331L ALL.1LBL'1A8L33K=	8L  L
L	LL$'L03L<c                 h    t        j                  t               t        j                  t               y r8   )r   rD   rW   r<   rE   s    r   rF   zOtherTests.tearDown   s     !r   N)rG   rH   rI   r_   re   rF   r   r   r   rK   rK   Z   s    > >@"r   rK   __main__)testr   requiresr!   unittestr$   r)   tempfiler   test.supportr   r   rW   r<   r&   TestCaser   rK   rG   mainr   r   r   <module>ro      s    
   H
   
 " " &			
3, ! :"(++ :"z3""" 3"j zHMMO r   