
    5\h                     j   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
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mZ 	 d dlmZ d dlmZ d dlmZ  e             dZn# eef$ r dZY nw xY wd dlmZ d d	lmZ d d
lm Z  d dl!m"Z" d dl!m#Z# d Z$d Z%d Z& G d d          Z' G d de'ej(        e#d          Z) G d de'ej(        e#d          Z* ej+        ej,        d           G d dej(                              Z- G d d          Z. G d de.ej(        e#d          Z/ G d de.ej(        e#d          Z0 ej         e1ed           d!           G d" d#                      Z2 G d$ d%e2ej(        e#d          Z3 G d& d'e2ej(        e#d          Z4e5d(k    r ej6                     dS dS ))    N)mock
skipUnless)_cleanup_tests)ProcessPoolExecutor)_check_system_limitsTF)support)	os_helper)script_helper)without_source_date_epoch)SourceDateEpochTestMetac                 L    |sd}t           j                            | |          S )N optimization)	importlibutilcache_from_source)scriptopts     >/opt/python-3.11.14/usr/lib/python3.11/test/test_compileall.pyget_pycr   $   s*     >++F+EEE    c                        fddD             S )Nc                 0    g | ]}t          |          S  )r   ).0r   r   s     r   
<listcomp>zget_pycs.<locals>.<listcomp>,   s#    666SGFC  666r   r         r   r   s   `r   get_pycsr"   +   s    6666I6666r   c                 t    	 t          j        |           j        }t          j        |          j        }||k    S N)osstatst_ino)	filename1	filename2inode1inode2s       r   is_hardlinkr,   /   s4    BWY&FWY&FVr   c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z eed           ej        d          d                         Zd Z eed           ej        d          d                         Z eed           ej        d           ej        d          d                                     Z eed           ej        dd           ej        d          d                                     Zd Z d d!d"Z!d# Z" eed          d$             Z#d% Z$ eed          d&             Z%d' Z&d( Z'd) Z(d* Z)d+ Z*e+j,        d,             Z-dS )-CompileallTestsBasec                    t          j                    | _        |                     t          j        | j                   t          j                            | j        d          | _	        t          j                            | j	                  | _        t          | j	        dd          5 }|                    d           d d d            n# 1 swxY w Y   t          j                            | j        d          | _        t          j                            | j                  | _        t	          j        | j	        | j                   t          j                            | j        d          | _        t          j        | j                   t          j                            | j        d          | _        t	          j        | j	        | j                   d S )	N_test.pywutf-8encodingzx = 123
z	_test2.py_subdirz	_test3.py)tempfilemkdtemp	directory
addCleanupshutilrmtreer%   pathjoinsource_pathr   r   r   bc_pathopenwritesource_path2bc_path2copyfilesubdirectorymkdirsource_path3selffiles     r   setUpzCompileallTestsBase.setUp8   s   !)++t~6667<<
CC ~778HII$"C'::: 	$dJJ{###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$GLLEE!889JKK($*;<<<GLLCC
"###GLL):KHH($*;<<<<<s   (C

CCc                     t           j                            | j        d          | _        t          | j        dd          5 }|                    d           d d d            d S # 1 swxY w Y   d S )Nz_test_bad.pyr1   r2   r3   zx (
)r%   r<   r=   r8   bad_source_pathr@   rA   rH   s     r   add_bad_source_filez'CompileallTestsBase.add_bad_source_fileH   s    !w||DNNKK$&g>>> 	 $JJw	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   A%%A),A)c                 6   t          | j        d          5 }|                    d          }d d d            n# 1 swxY w Y   t          t	          j        | j                  j                  }t          j	        dt          j        j        d|dz            }||fS )Nrb   <4sLLr       )r@   r?   readintr%   r&   r>   st_mtimestructpackr   r   MAGIC_NUMBER)rI   rJ   datamtimecompares        r   timestamp_metadataz&CompileallTestsBase.timestamp_metadataM   s    $,%% 	!99R==D	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!BGD,--677+gy~'BA#k13 3W}s   8<<c                 j   	 t          j        | j        d           n,# t          t          f$ r |                     d           Y nw xY wt          j        t          j	                              5  | 
                    t          j        | j                             d d d            d S # 1 swxY w Y   d S )N)rS   rS   z0filesystem doesn't support timestamps near 2**32r%   utimer>   OverflowErrorOSErrorskipTest
contextlibredirect_stdoutioStringIO
assertTrue
compileallcompile_filerI   s    r    test_year_2038_mtime_compilationz4CompileallTestsBase.test_year_2038_mtime_compilationU   s   	NHT%'=>>>>w' 	N 	N 	NMMLMMMMM	N'66 	G 	GOOJ3D4DEEFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G!    &AA.-B((B,/B,c                 j   	 t          j        | j        d           n,# t          t          f$ r |                     d           Y nw xY wt          j        t          j	                              5  | 
                    t          j        | j                             d d d            d S # 1 swxY w Y   d S )N)         ro   z+filesystem doesn't support large timestampsr_   rk   s    r   test_larger_than_32_bit_timesz1CompileallTestsBase.test_larger_than_32_bit_times_   s   	IHT%~6666w' 	I 	I 	IMMGHHHHH	I'66 	G 	GOOJ3D4DEEFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Grm   c                    	 t           j                            d          rt          j        d          t          j        | j                    | j        | 	                                  t          | j        d          5 }|                                t          |          d          }d d d            n# 1 swxY w Y   t          | j        d          5 }|                    |           |                    |           d d d            n# 1 swxY w Y    | j        | 	                                  t!          j        | j        dd            | j        | 	                                  d S )NSOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setrP   wbFTforcequiet)r%   environgetunittestSkipTest
py_compilecompiler>   assertEqualr]   r@   r?   rT   lenrA   assertNotEqualri   compile_dirr8   rh   )rI   metadatarJ   bcs       r   recreation_checkz$CompileallTestsBase.recreation_checki   s   	:>>-.. 	@#$>???4+,,,$113344$,%% 	-S]]^^,B	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-$,%% 	JJx   JJrNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	T446677t~U$GGGG00223333s$   ?*B55B9<B9+DDDc                 x    |                      t          j        dt          j        j        dd                     d S )NrR   r   r   )r   rW   rX   r   r   rY   rk   s    r   
test_mtimezCompileallTestsBase.test_mtimey   s@    fk'9>3N*+Q0 0 	1 	1 	1 	1 	1r   c                 0    |                      d           d S )Ns       )r   rk   s    r   test_magic_numberz%CompileallTestsBase.test_magic_number~   s    k*****r   c                    | j         | j        fD ]}	 t          j        |           #  Y xY w|                     t          j        | j        dd                     |                     t          j        	                    | j                   o$t          j        	                    | j                              t          j        | j                    |                     t          j
        | j        dd                     |                     t          j        	                    | j                   o#t          j        	                    | j                             t          j        | j                    t          j        | j                   |                                  |                     t          j        | j        dd                     |                     t          j
        | j        dd                     d S )NFTrt   r    )r?   rC   r%   unlinkrh   ri   rj   r>   r<   isfiler   r8   rN   assertFalserM   )rI   fns     r   test_compile_filesz&CompileallTestsBase.test_compile_files   s   </ 	 	B	"
/0@6;4I I I 	J 	J 	Jt|44 :GNN4=999	; 	; 	;
	$,
.t~U59; ; ; 	< 	< 	<t|44 6t}55	7 	7 	7
	$,
	$-     """01E7<AG G G 	H 	H 	H/6;1F F F 	G 	G 	G 	G 	Gs   '+c                    |                      t          j                            | j                             t          j                    5 }|                     t          j	        t          j        | j                                       d d d            n# 1 swxY w Y   |                     |                                d           |                     t          j                            | j                             d S )Nz&Compiling ([^WindowsPath|PosixPath].*))r   r%   r<   r   r?   r   captured_stdoutrh   ri   rj   pathlibPathr>   assertRegexgetvalue)rI   stdouts     r   test_compile_file_pathlikez.CompileallTestsBase.test_compile_file_pathlike   s
   55666$&& 	U&OOJ3GLAQ4R4RSSTTT	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U**,UVVVt|4455555s   ?BBBc                    |                      t          j                            | j                             |                     t          j        t          j	        | j
                  t          j	        d          d                     |                     t          j                            | j                             d S )N	ddir_pathr    )ddirrv   r   r%   r<   r   r?   rh   ri   rj   r   r   r>   rk   s    r   test_compile_file_pathlike_ddirz3CompileallTestsBase.test_compile_file_pathlike_ddir   s    55666
/T=M0N0N5<\+5N5N679 9 9 	: 	: 	: 	t|4455555r   c                    |                      t          j                            | j                             |                     t          j        t          j	        | j
                  t          j	        d          d                     |                     t          j                            | j                             d S Nstripdir_pathr    )stripdirrv   r   rk   s    r   #test_compile_file_pathlike_stripdirz7CompileallTestsBase.test_compile_file_pathlike_stripdir   s    55666
/T=M0N0N9@o9V9V679 9 9 	: 	: 	: 	t|4455555r   c                    |                      t          j                            | j                             |                     t          j        t          j	        | j
                  t          j	        d          d                     |                     t          j                            | j                             d S Nprependdir_pathr    )
prependdirrv   r   rk   s    r   %test_compile_file_pathlike_prependdirz9CompileallTestsBase.test_compile_file_pathlike_prependdir   s    55666
/T=M0N0N;B<HY;Z;Z679 9 9 	: 	: 	: 	t|4455555r   c                    t           j        j                            | j        g          5  |                     t          j        d                     d d d            n# 1 swxY w Y   t           j        j                            | j        g          5  |                                  | 	                    t          j        ddd                     d d d            d S # 1 swxY w Y   d S )Nr<   r    rv   FT)skip_curdirru   rv   )
testtest_importlibr   import_stater8   rh   ri   compile_pathrN   r   rk   s    r   test_compile_pathz%CompileallTestsBase.test_compile_path   s    %228H2II 	> 	>OOJ3!<<<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>  %228H2II 	K 	K$$&&&Z4;?qJ J J K K K	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	Ks#   )A!!A%(A%?C##C'*C'c                    t           j                            | j        d          }t           j                            |d          }t          j        |           t          |d          5  	 d d d            n# 1 swxY w Y   t          j        |           |                     t           j        	                    t           j                            |d                               d S )NrZ   rJ   rs   __pycache__)
r%   r<   r=   r8   rF   r@   ri   rj   r   exists)rI   data_dir	data_files      r   test_no_pycache_in_non_packagez2CompileallTestsBase.test_no_pycache_in_non_package   s     7<<77GLL622	
)T"" 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 		***X}(M(MNNOOOOOs   *A88A<?A<c                    |                                   t          j        t          j                              5  |                     t          j        | j                             d d d            d S # 1 swxY w Y   d S r$   )	rN   rd   re   rf   rg   r   ri   rj   rM   rk   s    r   #test_compile_file_encoding_fallbackz7CompileallTestsBase.test_compile_file_encoding_fallback   s      """'66 	L 	LZ4T5IJJKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   -A44A8;A8c                 X   d\  }}t          j        | j        d|           t          j                            | j        |          }|                     t          j	        
                    |                     t          j                            | j        |          }|                     t          j	        
                    |                     t          j                            | j        |          }|                     t          j	        
                    |                     d S )NF)r   r   )r   r   Trv   optimizer   )ri   r   r8   r   r   r   r>   rh   r%   r<   r   rB   rG   )rI   r   r   cachedcached2cached3s         r   test_optimizez!CompileallTestsBase.test_optimize   s     29#t~THMMMM11$2B?B 2 D Dv..///.2243D@C 3 E Ew//000.2243D@C 3 E Ew//00000r   c                    |                      t          j                            | j                             t          j                    5 }t          j        t          j
        | j                             d d d            n# 1 swxY w Y   |                                                                d         }|                     |d           |                     t          j                            | j                             d S )Nr   z$Listing ([^WindowsPath|PosixPath].*))r   r%   r<   r   r?   r   r   ri   r   r   r   r8   r   
splitlinesr   rh   )rI   r   lines      r   test_compile_dir_pathlikez-CompileallTestsBase.test_compile_dir_pathlike   s   55666$&& 	A&"7<#?#?@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A  ++--a0FGGGt|4455555s   ,BB
Bc                    |                      t          j                            | j                             |                     t          j        t          j	        | j
                  t          j	        d          d                     |                     t          j                            | j                             d S r   r   r%   r<   r   r?   rh   ri   r   r   r   r8   rk   s    r   "test_compile_dir_pathlike_stripdirz6CompileallTestsBase.test_compile_dir_pathlike_stripdir   s    55666
.w|DN/K/K8?_8U8U568 8 8 	9 	9 	9 	t|4455555r   c                    |                      t          j                            | j                             |                     t          j        t          j	        | j
                  t          j	        d          d                     |                     t          j                            | j                             d S r   r   rk   s    r   $test_compile_dir_pathlike_prependdirz8CompileallTestsBase.test_compile_dir_pathlike_prependdir   s    55666
.w|DN/K/K:A,GX:Y:Y568 8 8 	9 	9 	9 	t|4455555r   requires multiprocessingz&concurrent.futures.ProcessPoolExecutorc                 r    t          j        | j        dd           |                     |j                   d S NT   rv   workersri   r   r8   rh   calledrI   	pool_mocks     r   test_compile_pool_calledz,CompileallTestsBase.test_compile_pool_called   s9     	t~T1EEEE	()))))r   c                     |                      t          d          5  t          j        | j        d           d d d            d S # 1 swxY w Y   d S )Nz%workers must be greater or equal to 0)r   )assertRaisesRegex
ValueErrorri   r   r8   rk   s    r   !test_compile_workers_non_positivez5CompileallTestsBase.test_compile_workers_non_positive   s    ##J$KM M 	? 	?"4>2>>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   AA	A	c                     t          j        | j        dd           |                     |j        d         d         d            d S )NTr   r   r   max_workers)ri   r   r8   r}   	call_argsr   s     r   test_compile_workers_cpu_countz2CompileallTestsBase.test_compile_workers_cpu_count  sG     	t~T1EEEE,Q/>EEEEEr   zcompileall.compile_filec                     t          j        | j        d           |                     |j                   |                     |j                   d S )NTr   )ri   r   r8   r   r   rh   )rI   compile_file_mockr   s      r   test_compile_one_workerz+CompileallTestsBase.test_compile_one_worker  sO     	t~T::::)***)011111r   Nnewc                 r    t          j        | j        dd           |                     |j                   d S r   r   )rI   r   s     r   $test_compile_missing_multiprocessingz8CompileallTestsBase.test_compile_missing_multiprocessing  s:     	t~T1EEEE)011111r   c                    d}| j         }t          d|dz             D ]s}t          j                            |d|           }t          j                            |d          }t          j        |           t          j        | j        |           tt          j
                            |          }t          j        | j         d|dz
             |                     t          j                            |                     t          j        | j         d|           |                     t          j                            |                     d S )N   r   dir_z	script.pyT)rv   	maxlevels)r8   ranger%   r<   r=   rF   r:   rD   r>   r   r   r   ri   r   r   r   rh   )rI   depthr<   isourcepyc_filenames         r   test_compile_dir_maxlevelsz.CompileallTestsBase.test_compile_dir_maxlevels  s   ~q%!)$$ 	6 	6A7<<jQjj11DW\\$44FHTNNNOD,f5555 ~77??t~TUQYOOOO55666t~TUKKKK|4455555r   T)parallelc                   	 ddg}| j         }g }|D ]u}t          j                            ||          }t          j        |           t          j        |dd           |                    t          j        |dd                     v|r|                     t                     t          j        | j         d||rdnd	
           |                     |           |D ]}|                     |                    | j                   |           t          j                            |          }|t#          | j         t          j        z             d          }	t          j        |          \  }
}
}t          j                            ||	          }t(          j        j                            |          }|                     |j        |           |                     d| dt          j        |                     d S )Nr   foo__init__r   modzdef fn(): 1/0
fn()
Tr    r   )rv   r   r   ")r8   r%   r<   r=   rF   r
   make_scriptappendr9   multiprocessing_cleanup_testsri   r   rh   
startswithr   r   r   r~   sepassert_python_failurer   r   get_code_from_pycr}   co_filenameassertInfsdecode)rI   r   r   fullpathr<   modssubdirr   modcodemodpath_errexpected_inmod_code_objs                 r   _test_ddir_onlyz#CompileallTestsBase._test_ddir_only+  s   NE?~ 	L 	LF7<<f--DHTNNN%dJ;;;KK1$2IK K L L L L  	;OO9:::d%,1	. 	. 	. 	. 	 	@ 	@COOCNN4>::C@@@n66s;;G#dnRV344556G%;GDDIAq#',,tW55K.3EEgNNL\5{CCCMM,k,,,bk#.>.>????	@ 	@r   c                 2    	 |                      dd          S )N
<a prefix>Fr   r   r  rk   s    r   test_ddir_only_one_workerz-CompileallTestsBase.test_ddir_only_one_workerH  s    K###FFFr   c                 2    	 |                      dd          S )Nr  Tr  r  rk   s    r   test_ddir_multiple_workersz.CompileallTestsBase.test_ddir_multiple_workersL  s    K###EEEr   c                 2    	 |                      dd          S )Nr   Fr  r  rk   s    r   test_ddir_empty_only_one_workerz3CompileallTestsBase.test_ddir_empty_only_one_workerQ  s    M##e#<<<r   c                 2    	 |                      dd          S )Nr   Tr  r  rk   s    r    test_ddir_empty_multiple_workersz4CompileallTestsBase.test_ddir_empty_multiple_workersU  s    M##d#;;;r   c                    g d}t          j        j        | j        g|R  }t          j        |           t          j        |dd          }t          j        	                    |          }t          j        j        | j        g|d d         R  }t          j        |d|           t          j        |          \  }}}t          j        j        |dd           }	|                     |	t          |t          j                                         |                     |t          |t          j                                         d S )Nr   buildrealr<   r   1 / 0r    T)rv   r   r3   r%   r<   r=   r8   makedirsr
   r   r   r   r   ri   r   r   r   strsysgetdefaultencodingassertNotIn)
rI   r   r<   r   r   r   rcoutr  r  s
             r   test_strip_onlyz#CompileallTestsBase.test_strip_onlyZ  s:   444w|DN6X666
D*4AA^--f557<>"1">>>t4(CCCC$:2>>CglHQRRL1c466777	
 	
 	
 	c466777	
 	
 	
 	
 	
r   c                    g d}t          j        j        | j        g|R  }t          j        |           t          j        |dd          }t          j        	                    |          }d}t          j        |d|           t          j        |          \  }}}t          j        j        || j        g|R  }	|                     |	t          |t          j                                         d S )Nr  r   r  /fooT)rv   r   r3   )r%   r<   r=   r8   r  r
   r   r   r   r   ri   r   r   r   r  r  r  )
rI   r   r<   r   r   r   r  r  r  r  s
             r   test_prepend_onlyz%CompileallTestsBase.test_prepend_onlym  s    444w|DN6X666
D*4AA^--f55
t4JGGGG$:2>>Cgl:t~IIIIc466777	
 	
 	
 	
 	
r   c                    g d}t          j        j        | j        g|R  }t          j        |           t          j        |dd          }t          j        	                    |          }t          j        j        | j        g|d d         R  }d}t          j        |d||           t          j        |          \  }}}	t          j        j        |g|dd          R  }
|                     |
t          |	t          j                                         |                     |t          |	t          j                                         d S )	Nr  r   r  r    r  T)rv   r   r   r3   r  rI   r   r<   r   r   r   r   r  r  r  r  s              r   test_strip_and_prependz*CompileallTestsBase.test_strip_and_prepend|  sY   444w|DN6X666
D*4AA^--f557<>"1">>>
t4(0Z	I 	I 	I 	I$:2>>Cgl:====c466777	
 	
 	
 	c466777	
 	
 	
 	
 	
r   c                 2   g d}t          j        j        | j        g|R  }t          j        |           t          j        |dd           |                     t                    5  t          j
        |dddd           d d d            d S # 1 swxY w Y   d S )N)r   r  r  r<   r   r   r  Tz/barr  )rv   r   r   r   )r%   r<   r=   r8   r  r
   r   assertRaisesr   ri   r   )rI   r   r<   s      r   test_strip_prepend_and_ddirz/CompileallTestsBase.test_strip_prepend_and_ddir  s   <<<w|DN6X666
D!$888z** 	G 	G"4t&,2vG G G G	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   %BBBc                    t          j        | j        dd          }g }dD ]6}|                    t          j                            ||                     7ddgddgddgg dg}|D ]}t          j        |d	|
           |D ]e}| 	                    t          j                            ||                              	 t          j        ||                    V# t          $ r Y bw xY wd S )Ntest_optimizationa = 0r   r   r    r   r   r   r   r    r   Tr   )r
   r   r8   r   r   r   r   ri   rj   rh   r%   r<   r   r   	Exception)rI   r   r   	opt_leveltest_combinationsopt_combinations         r   !test_multiple_optimization_levelsz5CompileallTestsBase.test_multiple_optimization_levels  sB   *4>+>+24 4 $ 	P 	PIIIin66vDM 7 O O P P P PVaVaVYYY?0 	 	O#F$-<> > > >,  	r)} = =>>>Ibm,,,,    D		 	s   =C
C%$C%c                    t           j                            | j        ddd          }t           j                            | j        ddd          }t           j                            | j        ddd          }t          j        |           t          j        |           t          j        |           t          j        |dd          }t          j        |dd          }t           j                            |d	          }t           j                            |d
          }t          j        ||           t          j        ||           t          j	        
                    |          }t          j	        
                    |          }	t          j        |d|           |                     t           j                            |                     |                     t           j                            |	                     d S )Nr   dirallowedsymlinks
prohibitedtest_allowedr)  test_prohibitedtest_allowed.pytest_prohibited.pyT)rv   limit_sl_dest)r%   r<   r=   r8   r  r
   r   symlinkr   r   r   ri   r   rh   r   r   
rI   allowed_pathsymlinks_pathprohibited_pathallowed_scriptprohibited_scriptallowed_symlinkprohibited_symlink
allowed_bcprohibited_bcs
             r   test_ignore_symlink_destinationz3CompileallTestsBase.test_ignore_symlink_destination  s    w||DNFE9MMT^VUJOO',,t~vulSS
L!!!
M"""
O$$$ '2<QXYY)5oGXZabb',,}6GHHW\\-9MNN

>?333

$&8999^55oFF
!889KLL}DUUUUz223336677777r   ).__name__
__module____qualname__rK   rN   r]   rl   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _have_multiprocessingr   patchr   r   r   r   r   r   r  r	  r  r  r  r  r   r#  r&  r/  r	   skip_unless_symlinkrE  r   r   r   r.   r.   6   s       = = =      
  G G GG G G4 4 4 1 1 1
+ + +G G G26 6 66 6 66 6 66 6 6K K K
P 
P 
PL L L1 1 16 6 66 6 66 6 6 Z%'ABBTZ899* * :9 CB*? ? ?
 Z%'ABBTZ899F F :9 CBF Z%'ABBTZ899TZ)**2 2 +* :9 CB2
 Z%'ABBTZ8dCCCTZ)**2 2 +* DC CB26 6 6" 15 @ @ @ @ @:G G G Z%'ABBF F CBF= = = Z%'ABB< < CB<
 
 
&
 
 

 
 
*G G G  & "8 8 #"8 8 8r   r.   c                       e Zd ZdS )CompileallTestsWithSourceEpochNrF  rG  rH  r   r   r   rM  rM             	Dr   rM  )	metaclasssource_date_epochc                       e Zd ZdS )!CompileallTestsWithoutSourceEpochNrN  r   r   r   rS  rS    rO  r   rS  z tempdir is not encodable on WASIc                   "    e Zd Z	 d Zd Zd ZdS )EncodingTestc                 >   t          j                    | _        t          j                            | j        d          | _        t          | j        dd          5 }|                    d           |                    d           d d d            d S # 1 swxY w Y   d S )Nr0   r1   r2   r3   z# -*- coding: utf-8 -*-
u   print u"€"
)	r6   r7   r8   r%   r<   r=   r>   r@   rA   rH   s     r   rK   zEncodingTest.setUp  s    !)++7<<
CC$"C'::: 	,dJJ2333JJ*+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   +BBBc                 8    t          j        | j                   d S r$   )r:   r;   r8   rk   s    r   tearDownzEncodingTest.tearDown  s    dn%%%%%r   c                     	 t           j        }t          j        t          j                    d          t           _        t          j        | j                   |t           _        d S # |t           _        w xY w)Nasciir3   )r  r   rf   TextIOWrapperBytesIOri   r   r8   )rI   orig_stdouts     r   
test_errorzEncodingTest.test_error  s\    	%*K)"*,,HHHCJ"4>222$CJJJCJ$$$$s   AA& &A4N)rF  rG  rH  rK   rX  r^  r   r   r   rU  rU    sF        , , ,& & &% % % % %r   rU  c                   X   e Zd Z	 d Zej        d             Zd Zd Zd Z	d Z
d Zd Ze ej        d	          d
                         Z ej        d	          d             Zddg fdddgfdddgffD ]\  ZZZeefdZe e            dez   <   d Zd Zed             Zd Zd Zej        d             Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z(d& Z)d' Z*d( Z+ e,e-d)          d*             Z. e/j0        d+          d,             Z1d- Z2d. Z3ej        d/             Z4d0 Z5d1 Z6d2S )3CommandLineTestsBasec                    t          j                    | _        |                     t          j        | j                   t          j                            | j        d          | _	        t          j
        | j	                   t          j                            | j	        d          | _        t          j        | j	        dd          | _        t          j        | j	        dd          | _        d S )Nr   r   r   r   bar)r6   r7   r8   r9   r	   r;   r%   r<   r=   pkgdirrF   pkgdir_cachedirr
   r   initfnbarfnrk   s    r   rK   zCommandLineTestsBase.setUp  s    !)++	($.999gll4>599
!w||DKGG#/ZLL".t{E2FF


r   c              #      K   	 t           j        }t          j                            | j        d          }	 |t           _        | j        |dV  |t           _        d S # |t           _        w xY w)N__testcache__)
PYTHONPATHPYTHONPYCACHEPREFIX)r  pycache_prefixr%   r<   r=   r8   )rI   
old_prefix
new_prefixs      r   temporary_pycache_prefixz-CommandLineTestsBase.temporary_pycache_prefix  sz      4'
W\\$./BB
	,!+C"n'1    
 ",CC++++s   A A*c                 <    g t          j                    ddd|S )Nz-S-mri   )r   !optim_args_from_interpreter_flags)rI   argss     r   _get_run_argsz"CommandLineTestsBase._get_run_args
  s<    :<< ( 	r   c                     t          j        |                     |          i |ddi\  }}}|                     d|           |S )NPYTHONIOENCODINGr2   r   )r
   assert_python_okrs  r}   rI   rr  env_varsr  r  r  s         r   assertRunOKz CommandLineTestsBase.assertRunOK  sb    $5,,T2236>3 3*13 3 3C 	c"""
r   c                 d    t          j        |                     |          i |ddi\  }}}|||fS )Nru  r2   )r
   r   rs  rw  s         r   assertRunNotOKz#CommandLineTestsBase.assertRunNotOK  sS    $:++D1125=2 2)02 2 2C 3|r   c                     t           j                            |          }|                     t          j                            |                     d S r$   )r   r   r   rh   r%   r<   r   rI   r   r<   s      r   assertCompiledz#CommandLineTestsBase.assertCompiled  s=    ~//33t,,-----r   c                     t           j                            |          }|                     t          j                            |                     d S r$   )r   r   r   r   r%   r<   r   r}  s      r   assertNotCompiledz&CommandLineTestsBase.assertNotCompiled   s?    ~//33--.....r   c                 B   t          j        | j        dd          }|                                 5 } | j        di | |                     |           |                     | j                   |                     | j                   d d d            d S # 1 swxY w Y   d S )Nbazr   r   )	r
   r   r8   rn  ry  r~  r  re  rf  )rI   bazfnenvs      r   test_no_args_compiles_pathz/CommandLineTestsBase.test_no_args_compiles_path$  s    )$.%DD**,, 	/D##s###&&&""4;///""4:...		/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   ABBBcpuc                 h   t          j        | j        dd          }|                                 5 } | j        di | t
          j                            |          }d d d            n# 1 swxY w Y   t          j	        |t          j
                    dz
  fdz             t          j        |          j        } | j        di | t          j        |          j        }|                     ||            | j        di | t          j        |          j        }|                     ||           d S )Nr  r   <   r    -fr   )r  )r
   r   r8   rn  ry  r   r   r   r%   r`   timer&   rV   r}   r   )rI   r  r  pycpathr[   mtime2s         r    test_no_args_respects_force_flagz5CommandLineTestsBase.test_no_args_respects_force_flag-  sl    )$.%DD**,, 	>D##s###n66u==G	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	49;;r>+A-...  )3!!*'''%%%%%!!*E6*****s   -A))A-0A-c                     t          j        | j        dd           |                                 5 } | j        di |}d d d            n# 1 swxY w Y   |                     d|            | j        di |}|                     d|           d S )Nr  r   s   Listing -qr   )r  )r
   r   r8   rn  ry  r   r  )rI   r  noisyrv   s       r    test_no_args_respects_quiet_flagz5CommandLineTestsBase.test_no_args_respects_quiet_flag@  s    !$.%<<<**,, 	,$D$++s++E	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,k5)))  ----e,,,,,s   A

AAnormalpycr   z	opt-1.pyc-Odoubleoptimizez	opt-2.pycz-OOc                    t          j        |ddd| j        gz     |                     t          j                            | j                             t          fddD                       }| 	                    t          t	          j
        | j                            |           |                     fdt	          j
        | j                  D                        d S )Nrp  ri   r  c              3   b   K   | ])}|                     t          j        j                  V  *d S r$   )formatr  implementation	cache_tag)r   baseexts     r   	<genexpr>z)CommandLineTestsBase.f.<locals>.<genexpr>U  sS       K K"& #kk#*<*FLL K K K K K Kr   )z__init__.{}.{}z	bar.{}.{}c                 >    g | ]}|                               |S r   )endswith)r   r   r  s     r   r   z*CommandLineTestsBase.f.<locals>.<listcomp>Y  s9     3 3 3R!#S!1!13b 3 3 3r   )r
   rv  rc  rh   r%   r<   r   rd  sortedr}   listdirr   )rI   r  switchexpecteds    `  r   fzCommandLineTestsBase.fP  s	   *V|T4;7.8 : : OOBGNN4+?@@AAA K K K K*IK K K K KHVBJt/C$D$DEExPPP 3 3 3 32:dk+B+B 3 3 3 4 4 4 4 4r   test_pep3147_paths_c                 B   |                      dd| j                   |                     t          j                            | j                             t          g d          }|                     t          t          j	        | j                            |           d S )Nz-br  )__init__.pyz__init__.pyczbar.pyzbar.pyc)
ry  rc  r   r%   r<   r   rd  r  r}   r  )rI   r  s     r   test_legacy_pathsz&CommandLineTestsBase.test_legacy_paths]  s     	tT[111(<==>>> & & & ' '
4; 7 788(CCCCCr   c                 `   |                      d| j                   |                     t          j                            | j                             t          j                            | j        d          }|                     t          j                            |                     |                      d| j                   |                     t          j                            | j                             |                     t          j                            |                     d S )Nr  r   )	ry  rc  rh   r%   r<   r   rd  r=   r   )rI   cachecachedirs     r   test_multiple_runsz'CommandLineTestsBase.test_multiple_runsg  s     	t{+++t';<<===T%9=II66777t{+++t';<<===6677777r   c                 :   |                      d| j                   t          j                            | j                  }t          j        |t          j                    dz
  fdz             t          j	        |          j
        }|                      d| j                   t          j	        |          j
        }|                     ||           |                      dd| j                   t          j	        |          j
        }|                     ||           d S )Nr  r  r    r  )ry  rc  r   r   r   rf  r%   r`   r  r&   rV   r}   r   )rI   r  r[   r  s       r   
test_forcezCommandLineTestsBase.test_forcet  s    t{+++.224:>>
49;;r>+A-...  )t{+++!!*'''tT[111!!*E6*****r   c                 \   t           j                            | j        d          }t          j        |           t          j        |dd          }t          j        |dd          }|                     dd| j                   |                     |           | 	                    t           j        
                    t           j                            |d                               |                     d| j                   |                     |           |                     |           d S )Nspamr   r   hamr  z-lr   )r%   r<   r=   rc  rF   r
   r   ry  r  r   r   r~  )rI   
subpackage	subinitfnhamfns       r   test_recursion_controlz+CommandLineTestsBase.test_recursion_control  s    W\\$+v66

!-j*bII	)*eR@@tT[111y)))Z(O(OPPQQQt{+++I&&&E"""""r   c                 D   t           j                            | j        d          }t           j                            |d          }t           j                            |d          }|||fD ]}t	          j        |           t           j                            |d          }t	          j        |dd          }t	          j        |dd          }t	          j        |dd          }|                     dd| j                   |                     |           | 	                    t           j        
                    t           j                            |d	                               |                     dd
| j                   |                     |           |                     |           |                     |           |                     dd| j                   |                     |           |                     |           |                     |           |                     |           |                     dd| j                   |                     |           |                     |           |                     |           |                     |           d S )Nr  r  eggsr  r   eggr  z-r 0r   z-r 1z-r 2z-r 5)r%   r<   r=   rc  r
   make_pkgr   ry  r  r   r   r~  )	rI   r  subpackage2subpackage3pkgr  r  spamfneggfns	            r   test_recursion_limitz)CommandLineTestsBase.test_recursion_limit  sZ   W\\$+v66
gll:u55gll;77[9 	( 	(C"3''''GLL];;	)*eR@@*;CC)+ubAAvt{333y)))GNN27<<
MBBCC	E 	E 	E 	vt{333I&&&E"""v&&&vt{333I&&&E"""F###u%%%vt{333I&&&E"""F###E"""""r   c           	         t           j                            | j        d          }t	          j        |           t          j        dt           j                            |d                     t          j        dt           j                            |d                     |                     d| j                   |                     t           j                            | j        dddd                     d S )Nr  .evilevil2r  r  )	r%   r<   r=   rc  r
   r  r:  ry  r~  )rI   r  s     r   test_symlink_loopz&CommandLineTestsBase.test_symlink_loop  s    
 gll4;//s###

3S&11222

3S'22333t{+++BGLLK-
 
 	 	 	 	 	r   c                     |                      | j                  }|                      d| j                  }|                     d|           |                     d|           d S )Nr  r   )ry  rc  r   r}   )rI   r  rv   s      r   
test_quietzCommandLineTestsBase.test_quiet  s`      --  t{33C'''e$$$$$r   c                    t          j        | j        dd           |                     d| j                  \  }}}|                     d| j                  \  }}}|                     d|           |                     d|           d S )Ncrunchyfrog
bad(syntaxr  z-qqr   )r
   r   rc  r{  r   r}   )rI   r   rv   silents       r   test_silentz CommandLineTestsBase.test_silent  s    !$+}lKKK))$<<5!**5$+>>61C'''f%%%%%r   c                     |                      ddd| j                   |                     | j                   |                     | j                   d S )Nr  z-xz
ba[^\\/]*$)ry  rc  r  rf  r~  re  rk   s    r   test_regexpz CommandLineTestsBase.test_regexp  sP    t]DK@@@tz***DK(((((r   c                    t           j                            | j        d          }t          j        |           t          j        |dd          }t          j        |dd          }|                     d| j        |           | 	                    | j
                   | 	                    | j                   | 	                    |           | 	                    |           d S )Nfoo2r   r   bar2r  )r%   r<   r=   r8   rF   r
   r   ry  rc  r~  re  rf  )rI   pkgdir2init2fnbar2fns       r   test_multiple_dirsz'CommandLineTestsBase.test_multiple_dirs  s    ',,t~v66
+GZDD*7FB??t{G444DK(((DJ'''G$$$F#####r   c                     t          j        | j        dd           |                     ddd| j                  \  }}}|                     |d           d S )Nr  r  r  -ddinsdale   File "dinsdale)r
   r   rc  r{  r   rI   r  r  r  s       r   test_d_compile_errorz)CommandLineTestsBase.test_d_compile_error  sW    !$+}lKKK**4z4;OOC/00000r   c                    t          j        | j        dd          }|                     ddd| j                   t          j        | j        dd          }t          j                            |          }t          j        |t          j	        
                    | j        d                     t          j        |           t          j        |d	
          \  }}}|                     |d           d S )Nr  zraise Exceptionr  r  r  bingz
import bazzbaz.pycF)
__isolatedr  )r
   r   rc  ry  r   r   r   r%   renamer<   r=   remover   r   )rI   r  r   r  r  r  r  s          r   test_d_runtime_errorz)CommandLineTestsBase.test_d_runtime_error  s    )$+u>OPPtZ===&t{FLIIn..u55
	#rw||DK;;<<<
	%$:2%PPPC/00000r   c                    |                      dt          j                            | j        d          | j                  \  }}}|                     |d           |                     |d           |                     t          j        	                    t          j                            | j                                       d S )N-i
nosuchfiles   rror.*nosuchfiles	   Traceback)r{  r%   r<   r=   r8   rc  r   assertNotRegexr   r   r   r   r   rd  r  s       r   test_include_bad_filez*CommandLineTestsBase.test_include_bad_file  s    **"',,t~|<<dkK KC1222C...	(H(H,0,@)B )B C C 	D 	D 	D 	D 	Dr   c                    t          j        | j        dd          }t          j        | j        dd          }t          j        | j        dd          }t          j        | j        dd          }t          t          j                            | j        d          dd	          5 }|                    t          j                            | j        d
          t          j	        z              |                    t          j                            | j        d          t          j	        z              d d d            n# 1 swxY w Y   | 
                    dt          j                            | j        d          |           |                     |           |                     |           |                     |           |                     |           d S )Nf1r   f2f3f4l1r1   r2   r3   f1.pyf2.pyr  )r
   r   rc  r@   r%   r<   r=   r8   rA   linesepry  r~  r  rI   r  r  r  r  r  s         r   test_include_file_with_argz/CommandLineTestsBase.test_include_file_with_arg  s   &t{D"==&t{D"==&t{D"==&t{D"=="',,t~t44cGLLL 	DPRHHRW\\$+w77
BCCCHHRW\\$+w77
BCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	rw||DNDAA2FFFBBr"""Bs   "BD99D= D=c                    t          j        | j        dd          }t          j        | j        dd          }t          j        | j        dd          }t          j        | j        dd          }t          t          j                            | j        d          dd	          5 }|                    t          j                            | j        d
          t          j	        z              d d d            n# 1 swxY w Y   | 
                    dt          j                            | j        d                     |                     |           |                     |           |                     |           |                     |           d S )Nr  r   r  r  r  r  r1   r2   r3   r  r  )r
   r   rc  r@   r%   r<   r=   r8   rA   r  ry  r  r~  r  s         r   test_include_file_no_argz-CommandLineTestsBase.test_include_file_no_arg  s   &t{D"==&t{D"==&t{D"==&t{D"=="',,t~t44cGLLL 	DPRHHRW\\$+w77
BCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Drw||DNDAABBBr"""Br"""r"""""s   "AC44C8;C8c                 n   t          j        | j        dd          }t          j        | j        dd          }t          j        | j        dd          }t          j        | j        dd          }t          j        |                     d          ddgz    }|j                            |t          j        z   	                    d	                     t          j
        |           |                     |           |                     |           |                     |           |                     |           d S )
Nr  r   r  r  r  r   r  -rZ  )r
   r   rc  spawn_pythonrs  stdinrA   r%   r  encodekill_pythonr  r~  )rI   r  r  r  r  ps         r   test_include_on_stdinz*CommandLineTestsBase.test_include_on_stdin  s   &t{D"==&t{D"==&t{D"==&t{D"==&););B)?)?4+)MO	r"*},,W55666!!$$$r"""r"""Br"""""r   c                 F   t          j        | j        dd          }|                     d| j        || j                  \  }}}|                     |d           |                     |           |                     | j                   |                     | j                   d S )Nr  zsyntax(errorr  s   rror)	r
   r   rc  r{  re  rf  r   r  r~  )rI   bingfnr  r  r  s        r   !test_compiles_as_much_as_possiblez6CommandLineTestsBase.test_compiles_as_much_as_possible  s    *4;OO**<+14:? ?Cg&&&v&&&DK(((DJ'''''r   c                 \    |                      d          }|                     |d           d S )Nbadfilenames   Can't list 'badfilename')ry  r   )rI   r  s     r   !test_invalid_arg_produces_messagez6CommandLineTestsBase.test_invalid_arg_produces_message%  s2    }--9:::::r   c                    t          j        | j        dd           t          j                            t          j                            | j        d                    }| 	                    d| j                   t          |d          5 }|                                }d d d            n# 1 swxY w Y   |                     t                              |dd         d          d	           | 	                    d
| j                   t          |d          5 }|                                }d d d            n# 1 swxY w Y   |                     t                              |dd         d          d           d S )Nr  r   r  z --invalidation-mode=checked-hashrP         littler   z"--invalidation-mode=unchecked-hashr   )r
   r   rc  r   r   r   r%   r<   r=   ry  r@   rT   r}   rU   
from_bytes)rI   r  fprZ   s       r   test_pyc_invalidation_modez/CommandLineTestsBase.test_pyc_invalidation_mode)  s   !$+tR888n..GLLg..0 0;T[III#t__ 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	QqS	8<<dCCC=t{KKK#t__ 	7799D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	QqS	8<<dCCCCCs$   	B**B.1B.D88D<?D<r   c                    t          j        | j        dd          }g }t          d          D ]}t          j                            | j        d                    |                    }t	          j        |           t          j        |dd          }|	                    t          j        |dd                     | 
                    | j        dd           |                     |           |D ]}|                     |           d S )Nr  r   r   zfoo{}r   z-j0)r
   r   r8   r   r%   r<   r=   r  rF   r   ry  r~  )rI   r  filessuffixrc  r   rJ   s          r   test_workersz!CommandLineTestsBase.test_workers6  s    *4>62FFAhh 	H 	HFW\\$.'..2H2HIIFHV*6:rBBBLL2662FFGGGGs333F### 	& 	&D%%%%	& 	&r   zcompileall.compile_dirc                 0   t          j        dt          j        | j        dg          5  t          j                     |                     |j                   | 	                    |j
        d         d         d           d d d            d S # 1 swxY w Y   d S )Nzsys.argvz-j0r   r   r   r   )r   rJ  r  
executabler8   ri   mainrh   r   r}   r   )rI   r   s     r   test_workers_available_coresz1CommandLineTestsBase.test_workers_available_coresE  s    Z
 ^T^UCE E E 	F 	FOOOK.///[226yA1EEE		F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	Fs   ABBBc                    g d}t          j        j        | j        g|R  }t          j        |           t          j        |dd          }t          j        	                    |          }t          j        j        | j        g|d d         R  }d}| 
                    d|d||           t          j        |          \  }}}	t          j        j        |g|dd          R  }
|                     |
t          |	t          j                                         |                     |t          |	t          j                                         d S )	Nr  r   r  r    r  z-sz-pr3   )r%   r<   r=   r8   r  r
   r   r   r   r   ry  r   r   r  r  r  r  r"  s              r   r#  z+CommandLineTestsBase.test_strip_and_prependM  sN   444w|DN6X666
D*4AA^--f557<>"1">>>
xz4@@@$:2>>Cgl:====c466777	
 	
 	
 	c466777	
 	
 	
 	
 	
r   c           
      Z   t           j                            | j        d          }t          j        |           t          j        |dd          }g }dD ]6}|                    t          j	        
                    ||                     7ddgddgddgg d	g}|D ]} | j        |gd
 |D             R   |D ]r}|                     t           j                            |t          |                                        	 t          j        ||                    c# t           $ r Y ow xY wd S )Noptimizationsr(  r)  r*  r   r  12)r  r  r  c              3   :   K   | ]}d t          |          z   V  dS )z-oN)r  )r   ns     r   r  zICommandLineTestsBase.test_multiple_optimization_levels.<locals>.<genexpr>p  s,      $L$LqTCFF]$L$L$L$L$L$Lr   )r%   r<   r=   r8   r  r
   r   r   r   r   r   ry  rh   r   rU   r   r+  )rI   r<   r   r   r,  r-  r.  s          r   r/  z6CommandLineTestsBase.test_multiple_optimization_levelsa  s~   w||DNO<<
D*4+>+24 4 $ 	P 	PIIIin66vDM 7 O O P P P P!3Z!3Z!3Z,__.  1 	 	ODTM$L$LO$L$L$LMMMM,  	r#i../A B BCCCIbm,,,,    D		 	s   ?D
D'&D'c                    t           j                            | j        ddd          }t           j                            | j        ddd          }t           j                            | j        ddd          }t          j        |           t          j        |           t          j        |           t          j        |dd          }t          j        |dd          }t           j                            |d	          }t           j                            |d
          }t          j        ||           t          j        ||           t          j	        
                    |          }t          j	        
                    |          }	|                     |d|           |                     t           j                            |                     |                     t           j                            |	                     d S )Nr   r1  r2  r3  r4  r5  r)  r6  r7  r8  z-e)r%   r<   r=   r8   r  r
   r   r:  r   r   r   ry  rh   r   r   r;  s
             r   rE  z4CommandLineTestsBase.test_ignore_symlink_destinationx  s    w||DNFE9MMT^VUJOO',,t~vulSS
L!!!
M"""
O$$$ '2<QXYY)5oGXZabb',,}6GHHW\\-9MNN

>?333

$&8999^55oFF
!889KLLl;;;z223336677777r   c                 >    |                      | j        dd           d S )N-o 1--hardlink-dupes)r{  r8   rk   s    r   test_hardlink_bad_argsz+CommandLineTestsBase.test_hardlink_bad_args  s%     	DNF4FGGGGGr   c           
         dD ]:}t          j                    5 }|                     |          5  t          j        |dd          }t          |          }g d}|r|                    d            | j        |g|R   |                     t          |d         |d                   |           |                     t          |d         |d	                   |           |                     t          |d         |d	                   |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   <d S )
N)TFdedupr   r)  )r  z-o 0r  z-o 2r  r   r   r    )
r6   TemporaryDirectorysubTestr
   r   r"   r   ry  r}   r,   )rI   r  r<   r   pycsrr  s         r   test_hardlinkz"CommandLineTestsBase.test_hardlink  s    # 	K 	KE,.. K$\\\.. K K*6tXwOOF#F++D999D 8$6777$D$T1D1111$$[a$q'%B%BEJJJ$$[a$q'%B%BEJJJ$$[a$q'%B%BEJJJK K K K K K K K K K K K K K KK K K K K K K K K K K K K K K	K 	Ks5   D2CDD2DD2"D#D22D6	9D6	N)7rF  rG  rH  rK   rd   contextmanagerrn  rs  ry  r{  r~  r  r  r   r   requires_resourcer  r  namer  r  r  localsr  r  r  r  r  r	   rK  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rI  r  r   rJ  r  r#  r/  rE  r  r"  r   r   r   r`  r`    so        G G G , , ,  
    . . ./ / // / / Wu%%+ + &% +" Wu%%- - &%- 
5"	[4&)	;0 3 3c6
 F 
	4 
	4 
	4 
	4 23&-..D D D8 8 8 + + +
# 
# 
# #  #  #D "  #"% % %& & &) ) )
	$ 	$ 	$1 1 1
1 1 1D D D     # # ## # #( ( (; ; ;D D D Z%'ABB& & CB& TZ())F F *)F
 
 
(  . "8 8 #"80H H H
K K K K Kr   r`  c                       e Zd ZdS )CommandLineTestsWithSourceEpochNrN  r   r   r   r(  r(    rO  r   r(  c                       e Zd ZdS )CommandLineTestsNoSourceEpochNrN  r   r   r   r*  r*    rO  r   r*  linkzrequires os.linkc                       e Zd Zd Zej        d             ZddZddddd	Zd
 Z	ddZ
d Zd ZddZd Zd Zd Zd Zd ZdS )HardlinkDedupTestsBasec                     d | _         d S r$   r   rk   s    r   rK   zHardlinkDedupTestsBase.setUp  s    			r   c              #      K   t          j                    5 }|| _        |V  d | _        d d d            d S # 1 swxY w Y   d S r$   )r6   r  r<   )rI   r<   s     r   temporary_directoryz*HardlinkDedupTestsBase.temporary_directory  s      (** 	dDIJJJDI	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   6::r   c                 8    t          j        | j        ||          S r$   )r
   r   r<   )rI   coder%  s      r   r   z"HardlinkDedupTestsBase.make_script  s    (D$???r   Tr   F)r  r   ru   c                B    t          j        | j        d|||           d S )NT)rv   r   hardlink_dupesru   )ri   r   r<   )rI   r  r   ru   s       r   r   z"HardlinkDedupTestsBase.compile_dir  s9    tyx.35	B 	B 	B 	B 	B 	Br   c                    |                                  5  |                     d           |                     t                    5  t	          j        | j        ddd           d d d            n# 1 swxY w Y   |                     t                    5  t	          j        | j        dddgd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NpassTr   )rv   r   r4  )r0  r   r%  r   ri   r   r<   rk   s    r   test_bad_argsz$HardlinkDedupTestsBase.test_bad_args  s    %%'' 		< 		<V$$$"":.. < <&tyq6:< < < << < < < < < < < < < < < < < < "":.. < < &ty1v6:< < < << < < < < < < < < < < < < < <		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		< 		<sY   0CA/#C/A3	3C6A3	7C C 4C C	CC	CCCc                     g }|r|                     d           |                     d           |r|                     d           d                    |          S )Nz'module docstring'zx = 1zassert x == 1
)r   r=   )rI   	docstring	assertionliness       r   create_codez"HardlinkDedupTestsBase.create_code  s`     	/LL-...W 	*LL)))yyr   c              #   Z   K   dD ]%}dD ] }|                      ||          }|||fV  !&d S )N)FTr:  r;  )r=  )rI   r:  r;  r2  s       r   
iter_codesz!HardlinkDedupTestsBase.iter_codes  sa      & 	3 	3I* 3 3	'')y'QQY	222223	3 	3r   c           
         |                                  D ])\  }}}|                     ||          5  |                                 5  |                     |          }t	          |          }|                     d           |                     t          |d         |d                              |                     t          |d         |d                              |                     t          |d         |d                              d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   +d S )Nr?  Fr  r   r   r    )r@  r   r0  r   r"   r   r   r,   )rI   r2  r:  r;  r   r!  s         r   test_disabledz$HardlinkDedupTestsBase.test_disabled  s   *.//*;*; 	D 	D&D)Y	YGG D D--// D D!--d33F#F++D$$5$111$$[a$q'%B%BCCC$$[a$q'%B%BCCC$$[a$q'%B%BCCCD D D D D D D D D D D D D D DD D D D D D D D D D D D D D D	D 	Ds6   D3CDD3D  D3#D $D33D7	:D7	c                 P   t          |          }|                     t          |d         |d                   |            |                     t          |d         |d                   | o|            |                     t          |d         |d                   |            d S )Nr   r   r    )r"   r}   r,   )rI   r   r:  r;  r!  s        r   check_hardlinksz&HardlinkDedupTestsBase.check_hardlinks  s    T!Wd1g66&	( 	( 	(T!Wd1g66&8y=	: 	: 	:T!Wd1g66&	( 	( 	( 	( 	(r   c                 r   |                                  D ]\  }}}|                     ||          5  |                                 5  |                     |          }|                                  |                     |||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )Nr?  )r@  r   r0  r   r   rD  )rI   r2  r:  r;  r   s        r   r"  z$HardlinkDedupTestsBase.test_hardlink  sb   *.//*;*; 	G 	G&D)Y	YGG G G--// G G!--d33F$$&&&((IFFFG G G G G G G G G G G G G G GG G G G G G G G G G G G G G G	G 	Gs6   B+ABB+BB+BB++B/	2B/	c           	         dD ]}|                      |          5  |                                 5  |                     |                                           }|                     |           t          ||d                   }t          ||d                   }|                     t          ||                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )N))r   r   )r   r    )r   r    )optsr   r   r   )r   r0  r   r=  r   r   rh   r,   )rI   rG  r   pyc1pyc2s        r   test_only_two_levelsz+HardlinkDedupTestsBase.test_only_two_levels  sf   , 		= 		=D4(( = =--// = = "--d.>.>.@.@AAF$$d$333"64733D"64733DOOKd$;$;<<<= = = = = = = = = = = = = = == = = = = = = = = = = = = = =		= 		=s5   C BC	=C 	CC CC  C$	'C$	c                 d   |                                  5  |                     |                                           }|                     g d           t	          |d          }t	          |d          }|                     t          ||                     d d d            d S # 1 swxY w Y   d S )N)r   r   r   r   rH  r   r   )r0  r   r=  r   r   rh   r,   )rI   r   rI  rJ  s       r   test_duplicated_levelsz-HardlinkDedupTestsBase.test_duplicated_levels  s     %%'' 	5 	5 %%d&6&6&8&899Flll33361%%D61%%DOOKd33444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   BB%%B),B)c                 *   |                                  5  |                     d          }|                                  |                     |           t	          |          }t          j        |d                   j        }|                     d          }|                     ddgd           |                     |t          j        |d                   j                   | 	                    t          |d         |d                              |                     |t          j        |d                   j                   |                     t          j        |d         |d         d                     d d d            d S # 1 swxY w Y   d S )	Nr)  r   print(0)r    T)r   ru   r   shallow)r0  r   r   rD  r"   r%   r&   r'   r}   rh   r,   r   r   filecmpcmprI   r   r!  inodes       r   test_recompilationz)HardlinkDedupTestsBase.test_recompilation$  s    %%'' 	J 	J%%g..F  (((F##DGDG$$+E %%j11F q!fD999 UBGDG$4$4$;<<<OOKQa99:::rwtAw'7'7'>???W[a$q'4HHHIII)	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Js   E&FFFc                 `   |                                  5  |                     |                                 d          }|                                  |                     |           t          |          }t          j        |d                   j        }|                     dd          }t          j
        dddd| j        	           |                     |t          j        |d                   j                   |                     |t          j        |d
                   j                   |                     t          |d         |d
                              |                     t          j        |d         |d
         d                     d d d            d S # 1 swxY w Y   d S )Nmodule)r%  r   rO  r  z-czimport moduleF)r  ri  r    r   TrP  )r0  r   r=  r   rD  r"   r%   r&   r'   r
   rv  r<   r}   r   r,   rR  rS  rT  s       r   test_importz"HardlinkDedupTestsBase.test_import=  s    %%'' 	J 	J%%d&6&6&8&8x%HHF  (((F##DGDG$$+E %%jx%@@F *dO$)   
 UBGDG$4$4$;<<<UBGDG$4$4$;<<<[a$q'::;;;W[a$q'4HHHIII-	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Js   FF##F'*F'Nr!   )FF)rF  rG  rH  rK   rd   r#  r0  r   r   r7  r=  r@  rB  rD  r"  rK  rM  rV  rY  r   r   r   r-  r-    s/            @ @ @ @ $()5 B B B B B< < <       3 3 3
D 
D 
D( ( ( (G G G= = =
5 
5 
5J J J2J J J J Jr   r-  c                       e Zd ZdS )!HardlinkDedupTestsWithSourceEpochNrN  r   r   r   r[  r[  Y  rO  r   r[  c                       e Zd ZdS )HardlinkDedupTestsNoSourceEpochNrN  r   r   r   r]  r]  `  rO  r   r]  __main__)7ri   rd   rR  importlib.utilr   rf   r%   r   r{   r:   rW   r  r6   test.test_importlib.utilr   r  ry   r   r   multiprocessing.utilr   r   concurrent.futuresr   concurrent.futures.processr   rI  NotImplementedErrorModuleNotFoundErrorr   test.supportr	   r
   test.test_py_compiler   r   r   r"   r,   r.   TestCaserM  rS  skipIfis_wasirU  r`  r(  r*  hasattrr-  r[  r]  rF  r  r   r   r   <module>rl     sh                				 				        



        % % % % % % % %	" UTTTTT666666?????? 01 " " "!"       " " " " " " & & & & & & : : : : : : 8 8 8 8 8 8F F F7 7 7  N8 N8 N8 N8 N8 N8 N8 N8b	 	 	 	 	%8%-%6/F7;	 	 	 		 	 	 	 	(;(0(92I:?	 	 	 	 "DEE% % % % %8$ % % FE%.zK zK zK zK zK zK zK zKz	 	 	 	 	&:'/'81H9=	 	 	 		 	 	 	 	$8%-%6/F7<	 	 	 	 WWR((*<==ZJ ZJ ZJ ZJ ZJ ZJ ZJ >=ZJz	 	 	 	 	(>(0(92I:>	 	 	 		 	 	 	 	&<&.&70G8=	 	 	 	 zHMOOOOO s   A% %	A10A1