
    daf                     p   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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 dl#m$Z$ d Z%d Z&d Z' G d d      Z( G d de(ejR                  e"d      Z* G d de(ejR                  e"d      Z+ ejX                  ejZ                  d       G d dejR                               Z. G d d      Z/ G d de/ejR                  e"d      Z0 G d d e/ejR                  e"d      Z1 ej"                   e2ed!      d"       G d# d$             Z3 G d% d&e3ejR                  e"d      Z4 G d' d(e3ejR                  e"d      Z5e6d)k(  r ejn                          yy# eef$ r dZY Ww xY w)*    N)mock
skipUnless)_cleanup_tests)ProcessPoolExecutor)_check_system_limitsTF)support)	os_helper)script_helper)without_source_date_epoch)SourceDateEpochTestMeta)FakePathc                 L    |sd}t         j                  j                  | |      S )N optimization)	importlibutilcache_from_sourcescriptopts     //root/Python-3.12.4/Lib/test/test_compileall.pyget_pycr   $   s$    >>++F+EE    c                 @    dD cg c]  }t        | |       c}S c c}w )Nr         )r   r   s     r   get_pycsr   +   s    ,56SGFC 666s   c                     t        j                  |       j                  }t        j                  |      j                  }||k(  S )z8Returns True if two files have the same inode (hardlink))osstatst_ino)	filename1	filename2inode1inode2s       r   is_hardlinkr(   /   s5    WWY&&FWWY&&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j4                  d      d               Zd Z eed       ej4                  d      d               Z eed       ej4                  d       ej4                  d      d                      Z eed       ej4                  dd       ej4                  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+jX                  d,        Z-y)-CompileallTestsBasec                    t        j                         | _        | j                  t        j
                  | j                         t        j                  j                  | j                  d      | _	        t        j                  j                  | j                        | _        t        | j                  dd      5 }|j                  d       d d d        t        j                  j                  | j                  d      | _        t        j                  j                  | j                         | _        t	        j$                  | j                  | j                          t        j                  j                  | j                  d      | _        t        j(                  | j&                         t        j                  j                  | j&                  d      | _        t	        j$                  | j                  | j*                         y # 1 sw Y   9xY w)	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   sI   !))+t~~677<<
C ~~778H8HI$""C': 	$dJJ{#	$GGLLE!889J9JK(($*;*;<GGLLC
""#GGLL):):KH(($*;*;<	$ 	$s   9HHc                     t         j                  j                  | j                  d      | _        t        | j                  dd      5 }|j                  d       d d d        y # 1 sw Y   y xY w)Nz_test_bad.pyr-   r.   r/   zx (
)r!   r8   r9   r4   bad_source_pathr<   r=   rD   s     r   add_bad_source_filez'CompileallTestsBase.add_bad_source_fileH   sR    !ww||DNNNK$&&g> 	 $JJw	  	  	 s   A##A,c                 L   t        | j                  d      5 }|j                  d      }d d d        t        t	        j
                  | j                        j                        }t        j                  dt        j                  j                  d|dz        }|fS # 1 sw Y   rxY w)Nrb   <4sLLr       )r<   r;   readintr!   r"   r:   st_mtimestructpackr   r   MAGIC_NUMBER)rE   rF   datamtimecompares        r   timestamp_metadataz&CompileallTestsBase.timestamp_metadataM   s    $,,% 	!99R=D	!BGGD,,-667++gy~~'B'BA#k13W}	! 	!s   BB#c                 f   	 t        j                  | j                  d       t        j                  t        j                               5  | j                  t        j                  | j                               d d d        y # t        t        f$ r | j                  d       Y w xY w# 1 sw Y   y xY w)N)rO   rO   z0filesystem doesn't support timestamps near 2**32r!   utimer:   OverflowErrorOSErrorskipTest
contextlibredirect_stdoutioStringIO
assertTrue
compileallcompile_filerE   s    r    test_year_2038_mtime_compilationz4CompileallTestsBase.test_year_2038_mtime_compilationU   s    	NHHT%%'=> ''6 	GOOJ33D4D4DEF	G 	G w' 	NMMLM	N	G 	G    B 	/B' B$#B$'B0c                 f   	 t        j                  | j                  d       t        j                  t        j                               5  | j                  t        j                  | j                               d d d        y # t        t        f$ r | j                  d       Y w xY w# 1 sw Y   y xY w)N)         rk   z+filesystem doesn't support large timestampsr[   rg   s    r   test_larger_than_32_bit_timesz1CompileallTestsBase.test_larger_than_32_bit_times_   s    	IHHT%%~6 ''6 	GOOJ33D4D4DEF	G 	G w' 	IMMGH	I	G 	Gri   c                    t         j                  j                  d      rt        j                  d      t        j                  | j                          | j                  | j                           t        | j                  d      5 }|j                         t        |      d }ddd       t        | j                  d      5 }|j                  |       |j                         ddd        | j                  | j                           t!        j"                  | j$                  dd        | j&                  | j                           y# 1 sw Y   xY w# 1 sw Y   rxY w)	zOCheck that compileall recreates bytecode when the new metadata is
        used.SOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setrL   NwbFTforcequiet)r!   environgetunittestSkipTest
py_compilecompiler:   assertEqualrY   r<   r;   rP   lenr=   assertNotEqualre   compile_dirr4   rd   )rE   metadatarF   bcs       r   recreation_checkz$CompileallTestsBase.recreation_checki   s    ::>>-.##$>??4++,$1134$,,% 	-S]^,B	-$,,% 	JJx JJrN	 	T4467t~~U$G0023	- 	-	 	s   E
#E
EEc                     | j                  t        j                  dt        j                  j
                  dd             y )NrN   r   r   )r   rS   rT   r   r   rU   rg   s    r   
test_mtimezCompileallTestsBase.test_mtimey   s.    fkk'9>>3N3N*+Q0 	1r   c                 &    | j                  d       y )Ns       )r   rg   s    r   test_magic_numberz%CompileallTestsBase.test_magic_number~   s    k*r   c                 j   | j                   | j                  fD ]  }	 t        j                  |        | j	                  t        j                  | j                  dd             | j	                  t        j                  j                  | j                         xr* t        j                  j                  | j                                t        j                  | j                          | j	                  t        j                  | j                  dd             | j	                  t        j                  j                  | j                         xr) t        j                  j                  | j                               t        j                  | j                          t        j                  | j                         | j                          | j                  t        j                  | j                  dd             | j                  t        j                  | j                  dd             y #  Y xY w)NFTrp   r   )r;   r?   r!   unlinkrd   re   rf   r:   r8   isfiler|   r4   rJ   assertFalserI   )rE   fns     r   test_compile_filesz&CompileallTestsBase.test_compile_files   s   <</ 	B		"	
 	
//0@0@6;4I 	Jt||4 :GGNN4==99	;
		$,,
..t~~U59; 	<t||4 6t}}5	7
		$,,
		$--   "001E1E7<AG 	H//6;1F 	G#s   H--H2c                    | j                  t        j                  j                  | j                               t        j                         5 }| j                  t        j                  t        | j                                     d d d        | j                  j                         d       | j                  t        j                  j                  | j                               y # 1 sw Y   bxY w)Nz&Compiling ([^WindowsPath|PosixPath].*))r   r!   r8   r   r;   r   captured_stdoutrd   re   rf   r   r:   assertRegexgetvalue)rE   stdouts     r   test_compile_file_pathlikez.CompileallTestsBase.test_compile_file_pathlike   s    56$$& 	Q&OOJ33HT=M=M4NOP	Q*,UVt||45	Q 	Qs   8C&&C/c                 j   | j                  t        j                  j                  | j                               | j                  t        j                  t        | j                        t        d      d             | j                  t        j                  j                  | j                               y )N	ddir_pathr   )ddirrr   
r   r!   r8   r   r;   rd   re   rf   r   r:   rg   s    r   test_compile_file_pathlike_ddirz3CompileallTestsBase.test_compile_file_pathlike_ddir   sq    56
//9I9I0J5=k5J679 	: 	t||45r   c                 j   | j                  t        j                  j                  | j                               | j                  t        j                  t        | j                        t        d      d             | j                  t        j                  j                  | j                               y Nstripdir_pathr   )stripdirrr   r   rg   s    r   #test_compile_file_pathlike_stripdirz7CompileallTestsBase.test_compile_file_pathlike_stripdir   sq    56
//9I9I0J9A/9R679 	: 	t||45r   c                 j   | j                  t        j                  j                  | j                               | j                  t        j                  t        | j                        t        d      d             | j                  t        j                  j                  | j                               y Nprependdir_pathr   )
prependdirrr   r   rg   s    r   %test_compile_file_pathlike_prependdirz9CompileallTestsBase.test_compile_file_pathlike_prependdir   sr    56
//9I9I0J;CDU;V679 	: 	t||45r   c                    t         j                  j                  j                  | j                  g      5  | j                  t        j                  d             d d d        t         j                  j                  j                  | j                  g      5  | j                          | j                  t        j                  ddd             d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr8   r   rr   FT)skip_curdirrq   rr   )
testtest_importlibr   import_stater4   rd   re   compile_pathrJ   r   rg   s    r   test_compile_pathz%CompileallTestsBase.test_compile_path   s      %%228H2I 	>OOJ33!<=	>   %%228H2I 	K$$&Z44;?qJ K	K 	K	> 	>	K 	Ks   &C8C&C#&C/c                    t         j                  j                  | j                  d      }t         j                  j                  |d      }t        j                  |       t        |d      5  	 d d d        t        j                  |       | j                  t         j                  j                  t         j                  j                  |d                   y # 1 sw Y   kxY w)NrV   rF   ro   __pycache__)
r!   r8   r9   r4   rB   r<   re   rf   r   exists)rE   data_dir	data_files      r   test_no_pycache_in_non_packagez2CompileallTestsBase.test_no_pycache_in_non_package   s     77<<7GGLL62	
)T" 			*X}(MNO	 	s   ,CC!c                     | j                          t        j                  t        j                               5  | j                  t        j                  | j                               d d d        y # 1 sw Y   y xY wN)	rJ   r`   ra   rb   rc   r   re   rf   rI   rg   s    r   #test_compile_file_encoding_fallbackz7CompileallTestsBase.test_compile_file_encoding_fallback   sZ      "''6 	LZ44T5I5IJK	L 	L 	Ls   /A00A9c                 h   d\  }}t        j                  | j                  d|       t        j                  j                  | j                  |      }| j                  t        j                  j                  |             t        j                  j                  | j                  |      }| j                  t        j                  j                  |             t        j                  j                  | j                  |      }| j                  t        j                  j                  |             y )NT)r   r   rr   optimizer   )re   r|   r4   r   r   r   r:   rd   r!   r8   r   r>   rC   )rE   r   r   cachedcached2cached3s         r   test_optimizez!CompileallTestsBase.test_optimize   s     #t~~THM11$2B2B?B 2 Dv./..2243D3D@C 3 Ew/0..2243D3D@C 3 Ew/0r   c                    | j                  t        j                  j                  | j                               t        j                         5 }t        j                  t        | j                               d d d        j                         j                         d   }| j                  |d       | j                  t        j                  j                  | j                               y # 1 sw Y   uxY w)Nr   z$Listing ([^WindowsPath|PosixPath].*))r   r!   r8   r   r;   r   r   re   r|   r   r4   r   
splitlinesr   rd   )rE   r   lines      r   test_compile_dir_pathlikez-CompileallTestsBase.test_compile_dir_pathlike   s    56$$& 	=&""8DNN#;<	= ++-a0FGt||45		= 	=s   )C**C3c                 j   | j                  t        j                  j                  | j                               | j                  t        j                  t        | j                        t        d      d             | j                  t        j                  j                  | j                               y r   
r   r!   r8   r   r;   rd   re   r|   r   r4   rg   s    r   "test_compile_dir_pathlike_stripdirz6CompileallTestsBase.test_compile_dir_pathlike_stripdir   so    56
..x/G8@8Q568 	9 	t||45r   c                 j   | j                  t        j                  j                  | j                               | j                  t        j                  t        | j                        t        d      d             | j                  t        j                  j                  | j                               y r   r   rg   s    r   $test_compile_dir_pathlike_prependdirz8CompileallTestsBase.test_compile_dir_pathlike_prependdir   sp    56
..x/G:BCT:U568 	9 	t||45r   requires multiprocessingz&concurrent.futures.ProcessPoolExecutorc                 ~    t        j                  | j                  dd       | j                  |j                         y NT   rr   workersre   r|   r4   rd   calledrE   	pool_mocks     r   test_compile_pool_calledz,CompileallTestsBase.test_compile_pool_called   s,     	t~~T1E	(()r   c                     | j                  t        d      5  t        j                  | j                  d       d d d        y # 1 sw Y   y xY w)Nz%workers must be greater or equal to 0)r   )assertRaisesRegex
ValueErrorre   r|   r4   rg   s    r   !test_compile_workers_non_positivez5CompileallTestsBase.test_compile_workers_non_positive   s?    ##J$KM 	?""4>>2>	? 	? 	?s   "AAc                     t        j                  | j                  dd       | j                  |j                  d   d   d        y )NTr   r   r   max_workers)re   r|   r4   ry   	call_argsr   s     r   test_compile_workers_cpu_countz2CompileallTestsBase.test_compile_workers_cpu_count  s:     	t~~T1E,,Q/>Er   zcompileall.compile_filec                     t        j                  | j                  d       | j                  |j                         | j                  |j                         y )NTr   )re   r|   r4   r   r   rd   )rE   compile_file_mockr   s      r   test_compile_one_workerz+CompileallTestsBase.test_compile_one_worker  s?     	t~~T:))*)001r   Nnewc                 ~    t        j                  | j                  dd       | j                  |j                         y r   r   )rE   r   s     r   $test_compile_missing_multiprocessingz8CompileallTestsBase.test_compile_missing_multiprocessing  s-     	t~~T1E)001r   c                    d}| j                   }t        d|dz         D ]z  }t        j                  j	                  |d|       }t        j                  j	                  |d      }t        j
                  |       t        j                  | j                  |       | t        j                  j                        }t        j                  | j                   d|dz
         | j                  t        j                  j                  |             t        j                  | j                   d|       | j!                  t        j                  j                  |             y )N   r   dir_z	script.pyT)rr   	maxlevels)r4   ranger!   r8   r9   rB   r6   r@   r:   r   r   r   re   r|   r   r   rd   )rE   depthr8   isourcepyc_filenames         r   test_compile_dir_maxlevelsz.CompileallTestsBase.test_compile_dir_maxlevels  s    ~~q%!)$ 	6A77<<QCj1DWW\\$4FHHTNOOD,,f5		6
 !~~77?t~~TUQYO56t~~TUK|45r   T)parallelc                   ddg}| j                   }g }|D ]t  }t        j                  j                  ||      }t        j                  |       t        j                  |dd       |j                  t        j                  |dd             v |r| j                  t               t        j                  | j                   d||rdnd	
       | j                  |       |D ]  }| j                  |j                  | j                         |       t        j                  j!                  |      }|t#        | j                   t        j$                  z         d }	t        j&                  |      \  }
}
}t        j                  j                  ||	      }t(        j*                  j                  j-                  |      }| j/                  |j0                  |       | j3                  d| dt        j4                  |               y)z@Recursive compile_dir ddir must contain package paths; bpo39769.r   foo__init__r   modzdef fn(): 1/0
fn()
Tr   r   )rr   r   r   N")r4   r!   r8   r9   rB   r
   make_scriptappendr5   multiprocessing_cleanup_testsre   r|   rd   
startswithr   r   r   rz   sepassert_python_failurer   r   get_code_from_pycry   co_filenameassertInfsdecode)rE   r   r   fullpathr8   modssubdirr   modcodemodpath_errexpected_inmod_code_objs                 r   _test_ddir_onlyz#CompileallTestsBase._test_ddir_only+  s   E?~~ 	LF77<<f-DHHTN%%dJ;KK11$2IK L		L OO9:d%1	. 	 	@COOCNN4>>:C@nn66s;G#dnnRVV3456G%;;GDIAq#'',,tW5K..33EEgNL\55{CMMAk]!,bkk#.>?	@r   c                 (    | j                  dd      S )=Recursive compile_dir ddir= contains package paths; bpo39769.
<a prefix>Fr   r   r   rg   s    r   test_ddir_only_one_workerz-CompileallTestsBase.test_ddir_only_one_workerH  s    ###FFr   c                 (    | j                  dd      S )r  r  Tr  r  rg   s    r   test_ddir_multiple_workersz.CompileallTestsBase.test_ddir_multiple_workersL  s     ###EEr   c                 (    | j                  dd      S )?Recursive compile_dir ddir='' contains package paths; bpo39769.r   Fr  r  rg   s    r   test_ddir_empty_only_one_workerz3CompileallTestsBase.test_ddir_empty_only_one_workerQ  s    ##e#<<r   c                 (    | j                  dd      S )r	  r   Tr  r  rg   s    r    test_ddir_empty_multiple_workersz4CompileallTestsBase.test_ddir_empty_multiple_workersU  s     ##d#;;r   c                    g d}t        j                  j                  | j                  g| }t        j                  |       t        j                  |dd      }t        j                  j                  |      }t        j                  j                  | j                  g|d d  }t        j                  |d|       t        j                  |      \  }}}t        j                  j                  |dd   }	| j                  |	t        |t        j                                       | j#                  |t        |t        j                                       y )Nr   buildrealr8   r   1 / 0r   T)rr   r   r/   r!   r8   r9   r4   makedirsr
   r   r   r   r   re   r|   r   r   strsysgetdefaultencodingassertNotIn)
rE   r   r8   r   r~   r   rcoutr   r   s
             r   test_strip_onlyz#CompileallTestsBase.test_strip_onlyZ  s    4ww||DNN6X6
D**4A^^--f577<<>"1>t4(C$::2>CggllHQRL1c4467	
 	c4467	
r   c                    g d}t        j                  j                  | j                  g| }t        j                  |       t        j                  |dd      }t        j                  j                  |      }d}t        j                  |d|       t        j                  |      \  }}}t        j                  j                  || j                  g| }	| j                  |	t        |t        j                                       y )Nr  r   r  /fooT)rr   r   r/   )r!   r8   r9   r4   r  r
   r   r   r   r   re   r|   r   r   r  r  r  )
rE   r   r8   r   r~   r   r  r  r   r   s
             r   test_prepend_onlyz%CompileallTestsBase.test_prepend_onlym  s    4ww||DNN6X6
D**4A^^--f5
t4JG$::2>Cggll:t~~IIc4467	
r   c                    g d}t        j                  j                  | j                  g| }t        j                  |       t        j                  |dd      }t        j                  j                  |      }t        j                  j                  | j                  g|d d  }d}t        j                  |d||       t        j                  |      \  }}}	t        j                  j                  |g|dd   }
| j                  |
t        |	t        j                                       | j#                  |t        |	t        j                                       y )	Nr  r   r  r   r  T)rr   r   r   r/   r  rE   r   r8   r   r~   r   r   r  r  r   r   s              r   test_strip_and_prependz*CompileallTestsBase.test_strip_and_prepend|  s   4ww||DNN6X6
D**4A^^--f577<<>"1>
t4(0Z	I$::2>Cggll:==c4467	
 	c4467	
r   c                 @   g d}t        j                  j                  | j                  g| }t        j                  |       t        j                  |dd       | j                  t              5  t        j                  |dddd       d d d        y # 1 sw Y   y xY w)N)r   r  r  r8   r   r   r  Tz/barr  )rr   r   r   r   )r!   r8   r9   r4   r  r
   r   assertRaisesr   re   r|   )rE   r   r8   s      r   test_strip_prepend_and_ddirz/CompileallTestsBase.test_strip_prepend_and_ddir  s    <ww||DNN6X6
D!!$8z* 	G""4t&,2vG	G 	G 	Gs   0BBc                    t        j                  | j                  dd      }g }dD ]2  }|j                  t        j
                  j                  ||             4 ddgddgddgg dg}|D ]k  }t        j                  |d	|
       |D ]L  }| j                  t        j                  j                  ||                	 t        j                  ||          N m y # t        $ r Y ]w xY w)Ntest_optimizationa = 0r   r   r   r   r   r   r   r   r   Tr   )r
   r   r4   r   r   r   r   re   rf   rd   r!   r8   r   r   	Exception)rE   r   r~   	opt_leveltest_combinationsopt_combinations         r   !test_multiple_optimization_levelsz5CompileallTestsBase.test_multiple_optimization_levels  s    **4>>+>+24 $ 	PIIIinn66vDM 7 O P	P  VaVaVY?0 	O##F$-<>, 	r)} =>IIbm,	 ! s   =C	C&%C&c                 "   t         j                  j                  | j                  ddd      }t         j                  j                  | j                  ddd      }t         j                  j                  | j                  ddd      }t        j                  |       t        j                  |       t        j                  |       t        j                  |dd      }t        j                  |dd      }t         j                  j                  |d	      }t         j                  j                  |d
      }t        j                  ||       t        j                  ||       t        j                  j                  |      }t        j                  j                  |      }	t        j                  |d|       | j                  t         j                  j                  |             | j                  t         j                  j                  |	             y )Nr   dirallowedsymlinks
prohibitedtest_allowedr&  test_prohibitedtest_allowed.pytest_prohibited.pyT)rr   limit_sl_dest)r!   r8   r9   r4   r  r
   r   symlinkr   r   r   re   r|   rd   r   r   
rE   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  sb    ww||DNNFE9MT^^VUJO'',,t~~vulS
L!
M"
O$ '22<QXY)55oGXZab'',,}6GHWW\\-9MN


>?3


$&89^^55oF
!889KL}DUz2367r   ).__name__
__module____qualname__rG   rJ   rY   rh   rl   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_symlinkrB   r   r   r*   r*   6   s   =  
GG4 1
+G26666K
PL1666 %'ABTZZ89* : C*?
 %'ABTZZ89F : CF %'ABTZZ89TZZ)*2 + : C2
 %'ABTZZ8dCTZZ)*2 + D C26" 15 @:G %'ABF CF= %'AB< C<
&

*G& ""8 #8r   r*   c                       e Zd Zy)CompileallTestsWithSourceEpochNrC  rD  rE  rI  r   r   rK  rK         	r   rK  )	metaclasssource_date_epochc                       e Zd Zy)!CompileallTestsWithoutSourceEpochNrL  rI  r   r   rQ  rQ    rM  r   rQ  z tempdir is not encodable on WASIc                   "    e Zd ZdZd Zd Zd Zy)EncodingTestzTIssue 6716: compileall should escape source code when printing errors
    to stdout.c                    t        j                         | _        t        j                  j                  | j                  d      | _        t        | j                  dd      5 }|j                  d       d d d        y # 1 sw Y   y xY w)Nr,   r-   r.   r/   u   b"€")	r2   r3   r4   r!   r8   r9   r:   r<   r=   rD   s     r   rG   zEncodingTest.setUp  sd    !))+77<<
C$""C': 	$d JJ{#	$ 	$ 	$s   !A<<Bc                 B    t        j                  | j                         y r   )r6   r7   r4   rg   s    r   tearDownzEncodingTest.tearDown  s    dnn%r   c                    t        j                  t        j                         d      }t        j                  |      5  t        j                  | j                        }d d d        | j                         |j                  d       |j                         }| j                  d|       | j                  d|       y # 1 sw Y   `xY w)Nasciir/   r   z<SyntaxError: bytes can only contain ASCII literal charactersUnicodeEncodeError)rb   TextIOWrapperBytesIOr`   ra   re   r|   r4   r   seekrP   r   r  )rE   buffercompiledress       r   
test_errorzEncodingTest.test_error  s    !!"**,A''/ 	>!--dnn=H	>"AkkmJ	
 	-s3	> 	>s    B>>CN)rC  rD  rE  __doc__rG   rV  r`  rI  r   r   rS  rS    s    $&4r   rS  c                   D   e Zd 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/ e0jb                  d,      d-        Z2d. Z3d/ Z4ej<                  d0        Z5d1 Z6d2 Z7y3)4CommandLineTestsBasezTest compileall's CLI.c                    t        j                         | _        | j                  t        j
                  | j                         t        j                  j                  | j                  d      | _	        t        j                  | j                         t        j                  j                  | j                  d      | _        t        j                  | j                  dd      | _        t        j                  | j                  dd      | _        y )Nr   r   r   r   bar)r2   r3   r4   r5   r	   r7   r!   r8   r9   pkgdirrB   pkgdir_cachedirr
   r   initfnbarfnrg   s    r   rG   zCommandLineTestsBase.setUp  s    !))+	(($..9ggll4>>59
!ww||DKKG#//ZL"..t{{E2F
r   c              #      K   t         j                  }t        j                  j	                  | j
                  d      }	 |t         _        | j
                  |d |t         _        y# |t         _        w xY ww)z&Adjust and restore sys.pycache_prefix.__testcache__)
PYTHONPATHPYTHONPYCACHEPREFIXN)r  pycache_prefixr!   r8   r9   r4   )rE   
old_prefix
new_prefixs      r   temporary_pycache_prefixz-CommandLineTestsBase.temporary_pycache_prefix  s^      ''
WW\\$../B
	,!+C"nn'1 
 ",CCs   ;A6A& A6&A33A6c                 >    g t        j                         ddd|S )Nz-S-mre   )r   !optim_args_from_interpreter_flags)rE   argss     r   _get_run_argsz"CommandLineTestsBase._get_run_args  s<    ::< ( 	r   c                     t        j                  | j                  |      i |ddi\  }}}| j                  d|       |S )NPYTHONIOENCODINGr.   r   )r
   assert_python_okrv  ry   rE   ru  env_varsr  r  r   s         r   assertRunOKz CommandLineTestsBase.assertRunOK  sM    $55,,T236>3*13C 	c"
r   c                 d    t        j                  | j                  |      i |ddi\  }}}|||fS )Nrx  r.   )r
   r   rv  rz  s         r   assertRunNotOKz#CommandLineTestsBase.assertRunNotOK  sD    $::++D125=2)02C 3|r   c                     t         j                  j                  |      }| j                  t        j
                  j                  |             y r   )r   r   r   rd   r!   r8   r   rE   r   r8   s      r   assertCompiledz#CommandLineTestsBase.assertCompiled"  s/    ~~//3t,-r   c                     t         j                  j                  |      }| j                  t        j
                  j                  |             y r   )r   r   r   r   r!   r8   r   r  s      r   assertNotCompiledz&CommandLineTestsBase.assertNotCompiled&  s1    ~~//3-.r   c                 B   t        j                  | j                  dd      }| j                         5 } | j                  di | | j                  |       | j                  | j                         | j                  | j                         d d d        y # 1 sw Y   y xY w)Nbazr   rI  )	r
   r   r4   rq  r|  r  r  rh  ri  )rE   bazfnenvs      r   test_no_args_compiles_pathz/CommandLineTestsBase.test_no_args_compiles_path*  s    ))$..%D**, 	/D#s#&""4;;/""4::.		/ 	/ 	/s   ABBcpuc                    t        j                  | j                  dd      }| j                         5 } | j                  di | t
        j                  j                  |      }d d d        t        j                  t        j                         dz
  fdz         t        j                  |      j                  } | j                  di  t        j                  |      j                  }| j                  ||        | j                  di | t        j                  |      j                  }| j                  ||       y # 1 sw Y   xY w)Nr  r   <   r   rI  )-f)r
   r   r4   rq  r|  r   r   r   r!   r\   timer"   rR   ry   r{   )rE   r  r  pycpathrW   mtime2s         r    test_no_args_respects_force_flagz5CommandLineTestsBase.test_no_args_respects_force_flag3  s
    ))$..%D**, 	>D#s#nn66u=G	> 	499;r>+A-. ))3!**'%%!**E6*	> 	>s   2EE
c                     t        j                  | j                  dd       | j                         5 } | j                  di |}d d d        | j                  d        | j                  di }| j                  d|       y # 1 sw Y   @xY w)Nr  r   s   Listing rI  )-q)r
   r   r4   rq  r|  r   r  )rE   r  noisyrr   s       r    test_no_args_respects_quiet_flagz5CommandLineTestsBase.test_no_args_respects_quiet_flagF  s    !!$..%<**, 	,$D$$+s+E	,k5)   --e,		, 	,s   BBnormalpycr   z	opt-1.pyc-Odoubleoptimizez	opt-2.pycz-OOc                    t        j                  |ddd| j                  gz     | j                  t        j
                  j                  | j                               t        fddD              }| j                  t        t	        j                  | j                              |       | j                  t	        j                  | j                        D cg c]  }|j                        r| c}       y c c}w )Nrs  re   r  c              3   r   K   | ].  }|j                  t        j                  j                         0 y wr   )formatr  implementation	cache_tag).0baseexts     r   	<genexpr>z)CommandLineTestsBase.f.<locals>.<genexpr>[  s2      K"& #kk#*<*<*F*FL Ks   47)z__init__.{}.{}z	bar.{}.{})r
   ry  rf  rd   r!   r8   r   rg  sortedry   listdirr   endswith)rE   r  switchexpectedr   s    `   r   fzCommandLineTestsBase.fV  s    **V|T4;;7.8 : OOBGGNN4+?+?@A K*IK KHVBJJt/C/C$DExP2::dkk+B 3R!#S!1 ! 3 4 3s   C7test_pep3147_paths_c                 8   | j                  dd| j                         | j                  t        j                  j                  | j                               t        g d      }| j                  t        t        j                  | j                              |       y )Nz-br  )__init__.pyz__init__.pyczbar.pyzbar.pyc)
r|  rf  r   r!   r8   r   rg  r  ry   r  )rE   r  s     r   test_legacy_pathsz&CommandLineTestsBase.test_legacy_pathsc  sl     	tT[[1(<(<=> & '

4;; 78(Cr   c                 `   | j                  d| j                         | j                  t        j                  j                  | j                               t        j                  j                  | j                  d      }| j                  t        j                  j                  |             | j                  d| j                         | j                  t        j                  j                  | j                               | j                  t        j                  j                  |             y )Nr  r   )	r|  rf  rd   r!   r8   r   rg  r9   r   )rE   cachecachedirs     r   test_multiple_runsz'CommandLineTestsBase.test_multiple_runsm  s     	t{{+t';';<=T%9%9=I67t{{+t';';<=67r   c                 `   | j                  d| j                         t        j                  j	                  | j
                        }t        j                  |t        j                         dz
  fdz         t        j                  |      j                  }| j                  d| j                         t        j                  |      j                  }| j                  ||       | j                  dd| j                         t        j                  |      j                  }| j                  ||       y )Nr  r  r   r  )r|  rf  r   r   r   ri  r!   r\   r  r"   rR   ry   r{   )rE   r  rW   r  s       r   
test_forcezCommandLineTestsBase.test_forcez  s    t{{+..224::>
499;r>+A-. ))t{{+!**'tT[[1!**E6*r   c                 N   t         j                  j                  | j                  d      }t        j                  |       t        j                  |dd      }t        j                  |dd      }| j                  dd| j                         | j                  |       | j                  t         j                  j                  t         j                  j                  |d                   | j                  d| j                         | j                  |       | j                  |       y )Nspamr   r   hamr  z-lr   )r!   r8   r9   rf  rB   r
   r   r|  r  r   r   r  )rE   
subpackage	subinitfnhamfns       r   test_recursion_controlz+CommandLineTestsBase.test_recursion_control  s    WW\\$++v6

!--j*bI	))*eR@tT[[1y)Z(OPQt{{+I&E"r   c                    t         j                  j                  | j                  d      }t         j                  j                  |d      }t         j                  j                  |d      }|||fD ]  }t	        j
                  |        t         j                  j                  |d      }t	        j                  |dd      }t	        j                  |dd      }t	        j                  |dd      }| j                  dd| j                         | j                  |       | j                  t         j                  j                  t         j                  j                  |d	                   | j                  dd
| j                         | j                  |       | j                  |       | j                  |       | j                  dd| j                         | j                  |       | j                  |       | j                  |       | j                  |       | j                  dd| j                         | j                  |       | j                  |       | j                  |       | j                  |       y )Nr  r  eggsr  r   eggr  z-r 0r   z-r 1z-r 2z-r 5)r!   r8   r9   rf  r
   make_pkgr   r|  r  r   r   r  )	rE   r  subpackage2subpackage3pkgr  r  spamfneggfns	            r   test_recursion_limitz)CommandLineTestsBase.test_recursion_limit  s   WW\\$++v6
ggll:u5ggll;7[9 	(C""3'	( GGLL];	))*eR@**;C))+ubAvt{{3y)GGNN277<<
MBC	E 	vt{{3I&E"v&vt{{3I&E"F#u%vt{{3I&E"F#E"r   c           	         t         j                  j                  | j                  d      }t	        j
                  |       t        j                  dt         j                  j                  |d             t        j                  dt         j                  j                  |d             | j                  d| j                         | j                  t         j                  j                  | j                  dddd             y )Nr  .evilevil2r  r  )	r!   r8   r9   rf  r
   r  r7  r|  r  )rE   r  s     r   test_symlink_loopz&CommandLineTestsBase.test_symlink_loop  s    
 ggll4;;/s#


3S&12


3S'23t{{+BGGLLKK-
 	r   c                     | j                  | j                        }| j                  d| j                        }| j                  d|       | j                  d|       y )Nr  r   )r|  rf  r{   ry   )rE   r  rr   s      r   
test_quietzCommandLineTestsBase.test_quiet  sL      -  t{{3C'e$r   c                    t        j                  | j                  dd       | j                  d| j                        \  }}}| j                  d| j                        \  }}}| j	                  d|       | j                  d|       y )Ncrunchyfrog
bad(syntaxr  z-qqr   )r
   r   rf  r~  r{   ry   )rE   r   rr   silents       r   test_silentz CommandLineTestsBase.test_silent  sp    !!$++}lK))$<5!**5$++>61C'f%r   c                     | j                  ddd| j                         | j                  | j                         | j	                  | j
                         y )Nr  z-xz
ba[^\\/]*$)r|  rf  r  ri  r  rh  rg   s    r   test_regexpz CommandLineTestsBase.test_regexp  s>    t]DKK@tzz*DKK(r   c                    t         j                  j                  | j                  d      }t        j                  |       t        j                  |dd      }t        j                  |dd      }| j                  d| j                  |       | j                  | j                         | j                  | j                         | j                  |       | j                  |       y )Nfoo2r   r   bar2r  )r!   r8   r9   r4   rB   r
   r   r|  rf  r  rh  ri  )rE   pkgdir2init2fnbar2fns       r   test_multiple_dirsz'CommandLineTestsBase.test_multiple_dirs  s    '',,t~~v6
++GZD**7FB?t{{G4DKK(DJJ'G$F#r   c                     t        j                  | j                  dd       | j                  ddd| j                        \  }}}| j	                  |d       y )Nr  r  r  -ddinsdale   File "dinsdale)r
   r   rf  r~  r   rE   r  r  r   s       r   test_d_compile_errorz)CommandLineTestsBase.test_d_compile_error  sI    !!$++}lK**4z4;;OC/0r   c                    t        j                  | j                  dd      }| j                  ddd| j                         t        j                  | j                  dd      }t        j
                  j                  |      }t        j                  |t        j                  j                  | j                  d             t        j                  |       t        j                  |d	
      \  }}}| j                  |d       y )Nr  zraise Exceptionr  r  r  bingz
import bazzbaz.pycF)
__isolatedr  )r
   r   rf  r|  r   r   r   r!   renamer8   r9   remover   r   )rE   r  r   r  r  r  r   s          r   test_d_runtime_errorz)CommandLineTestsBase.test_d_runtime_error  s    ))$++u>OPtZ=&&t{{FLInn..u5
		#rww||DKK;<
		%$::2%PC/0r   c                    | j                  dt        j                  j                  | j                  d      | j
                        \  }}}| j                  |d       | j                  |d       | j                  t        j                  j                  t        j                  j                  | j                                     y )N-i
nosuchfiles   rror.*nosuchfiles	   Traceback)r~  r!   r8   r9   r4   rf  r   assertNotRegexr   r   r   r   r   rg  r  s       r   test_include_bad_filez*CommandLineTestsBase.test_include_bad_file  s    **"'',,t~~|<dkkKC12C.	(H(H,0,@,@)B C 	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                  | j                  d      dd	      5 }|j                  t        j
                  j                  | j                  d
      t        j                  z          |j                  t        j
                  j                  | j                  d      t        j                  z          d d d        | j                  dt        j
                  j                  | j                  d      |       | j                  |       | j                  |       | j                  |       | j                  |       y # 1 sw Y   xY w)Nf1r   f2f3f4l1r-   r.   r/   f1.pyf2.pyr  )r
   r   rf  r<   r!   r8   r9   r4   r=   linesepr|  r  r  rE   r  r  r  r  r  s         r   test_include_file_with_argz/CommandLineTestsBase.test_include_file_with_arg  sL   &&t{{D"=&&t{{D"=&&t{{D"=&&t{{D"="'',,t~~t4cGL 	DPRHHRWW\\$++w7

BCHHRWW\\$++w7

BC	D 	rww||DNNDA2FBBr"B	D 	Ds   ;BGG!c                 2   t        j                  | j                  dd      }t        j                  | j                  dd      }t        j                  | j                  dd      }t        j                  | j                  dd      }t        t        j
                  j                  | j                  d      dd	      5 }|j                  t        j
                  j                  | j                  d
      t        j                  z          d d d        | j                  dt        j
                  j                  | j                  d             | j                  |       | j                  |       | j                  |       | j                  |       y # 1 sw Y   xY w)Nr  r   r  r  r  r  r-   r.   r/   r  r  )r
   r   rf  r<   r!   r8   r9   r4   r=   r  r|  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4cGL 	DPRHHRWW\\$++w7

BC	Drww||DNNDABr"Br"r"	D 	Ds   ;AFFc                    t        j                  | j                  dd      }t        j                  | j                  dd      }t        j                  | j                  dd      }t        j                  | j                  dd      }t        j                  | j	                  d      ddgz    }|j
                  j                  |t        j                  z   j                  d	             t        j                  |       | j                  |       | j                  |       | j                  |       | j                  |       y )
Nr  r   r  r  r  rI  r  -rX  )r
   r   rf  spawn_pythonrv  stdinr=   r!   r  encodekill_pythonr  r  )rE   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6!!!$r"r"Br"r   c                 P   t        j                  | j                  dd      }| j                  d| j                  || j
                        \  }}}| j                  |d       | j                  |       | j                  | j                         | j                  | j
                         y )Nr  zsyntax(errorr  s   rror)	r
   r   rf  r~  rh  ri  r   r  r  )rE   bingfnr  r  r   s        r   !test_compiles_as_much_as_possiblez6CommandLineTestsBase.test_compiles_as_much_as_possible"  s    **4;;O**<+14::?Cg&v&DKK(DJJ'r   c                 J    | j                  d      }| j                  |d       y )Nbadfilenames   Can't list 'badfilename')r|  r   )rE   r  s     r   !test_invalid_arg_produces_messagez6CommandLineTestsBase.test_invalid_arg_produces_message+  s#    }-9:r   c                    t        j                  | j                  dd       t        j                  j                  t        j                  j                  | j                  d            }| j                  d| j                         t        |d      5 }|j                         }d d d        | j                  t        j                  dd d      d	       | j                  d
| j                         t        |d      5 }|j                         }d d d        | j                  t        j                  |dd d      d       y # 1 sw Y   xY w# 1 sw Y   ?xY w)Nr  r   r  z --invalidation-mode=checked-hashrL         littler   z"--invalidation-mode=unchecked-hashr   )r
   r   rf  r   r   r   r!   r8   r9   r|  r<   rP   ry   rQ   
from_bytes)rE   r  fprV   s       r   test_pyc_invalidation_modez/CommandLineTestsBase.test_pyc_invalidation_mode/  s   !!$++tR8nn..GGLLg.0;T[[I#t_ 	779D	Qq	8<dC=t{{K#t_ 	779D	Qq	8<dC	 		 	s   D>;E
>E
Er   c                    t        j                  | j                  dd      }g }t        d      D ]  }t        j
                  j                  | j                  dj                  |            }t	        j                  |       t        j                  |dd      }|j                  t        j                  |dd              | j                  | j                  dd       | j                  |       |D ]  }| j                  |        y )Nr  r   r   zfoo{}r   z-j0)r
   r   r4   r   r!   r8   r9   r  rB   r   r|  r  )rE   r  filessuffixrf  r   rF   s          r   test_workersz!CommandLineTestsBase.test_workers<  s    **4>>62FAh 	HFWW\\$..'..2HIFHHV**6:rBBLL22662FG		H 	s3F# 	&D%	&r   zcompileall.compile_dirc                 4   t        j                  dt        j                  | j                  dg      5  t        j                          | j                  |j                         | j                  |j                  d   d   d       d d d        y # 1 sw Y   y xY w)Nzsys.argvz-j0r   r   r   r   )r   rG  r  
executabler4   re   mainrd   r   ry   r   )rE   r|   s     r   test_workers_available_coresz1CommandLineTestsBase.test_workers_available_coresK  sx    ZZ
 ^^T^^UCE 	FOOOOK../[2226yA1E		F 	F 	Fs   ABBc                    g d}t        j                  j                  | j                  g| }t        j                  |       t        j                  |dd      }t        j                  j                  |      }t        j                  j                  | j                  g|d d  }d}| j                  d|d||       t        j                  |      \  }}}	t        j                  j                  |g|dd   }
| j                  |
t        |	t        j                                      | j!                  |t        |	t        j                                      y )	Nr  r   r  r   r  z-sz-pr/   )r!   r8   r9   r4   r  r
   r   r   r   r   r|  r   r   r  r  r  r  r  s              r   r   z+CommandLineTestsBase.test_strip_and_prependS  s   4ww||DNN6X6
D**4A^^--f577<<>"1>
xz4@$::2>Cggll:==c4467	
 	c4467	
r   c           
      R   t         j                  j                  | j                  d      }t        j                  |       t        j                  |dd      }g }dD ]2  }|j                  t        j                  j                  ||             4 ddgddgddgg d	g}|D ]v  } | j                  |gd
 |D          |D ]U  }| j                  t         j                  j                  |t        |                      	 t        j                  ||          W x y # t         $ r Y fw xY w)Noptimizationsr%  r&  r'  r   r  12)r  r  r  c              3   8   K   | ]  }d t        |      z     yw)z-oN)r  )r  ns     r   r  zICommandLineTestsBase.test_multiple_optimization_levels.<locals>.<genexpr>v  s     $LqTCF]$Ls   )r!   r8   r9   r4   r  r
   r   r   r   r   r   r|  rd   r   rQ   r   r(  )rE   r8   r   r~   r)  r*  r+  s          r   r,  z6CommandLineTestsBase.test_multiple_optimization_levelsg  s'   ww||DNNO<
D**4+>+24 $ 	PIIIinn66vDM 7 O P	P "3Z!3Z!3Z,.  1 	ODTM$LO$LM, 	r#i./A BCIIbm,	 ! s   =D	D&%D&c                    t         j                  j                  | j                  ddd      }t         j                  j                  | j                  ddd      }t         j                  j                  | j                  ddd      }t        j                  |       t        j                  |       t        j                  |       t        j                  |dd      }t        j                  |dd      }t         j                  j                  |d	      }t         j                  j                  |d
      }t        j                  ||       t        j                  ||       t        j                  j                  |      }t        j                  j                  |      }	| j                  |d|       | j                  t         j                  j                  |             | j                  t         j                  j                  |	             y )Nr   r.  r/  r0  r1  r2  r&  r3  r4  r5  z-e)r!   r8   r9   r4   r  r
   r   r7  r   r   r   r|  rd   r   r   r8  s
             r   rB  z4CommandLineTestsBase.test_ignore_symlink_destination~  sb    ww||DNNFE9MT^^VUJO'',,t~~vulS
L!
M"
O$ '22<QXY)55oGXZab'',,}6GHWW\\-9MN


>?3


$&89^^55oF
!889KLl;z2367r   c                 >    | j                  | j                  dd       y )N-o 1--hardlink-dupes)r~  r4   rg   s    r   test_hardlink_bad_argsz+CommandLineTestsBase.test_hardlink_bad_args  s     	DNNF4FGr   c           
         dD ]  }t        j                         5 }| j                  |      5  t        j                  |dd      }t        |      }g d}|r|j                  d        | j                  |g|  | j                  t        |d   |d         |       | j                  t        |d   |d	         |       | j                  t        |d   |d	         |       d d d        d d d         y # 1 sw Y   xY w# 1 sw Y   xY w)
N)TFdedupr   r&  )r  z-o 0r  z-o 2r  r   r   r   )
r2   TemporaryDirectorysubTestr
   r   r   r   r|  ry   r(   )rE   r!  r8   r   pycsru  s         r   test_hardlinkz"CommandLineTestsBase.test_hardlink  s    # 	KE,,. K$\\\. K*66tXwOF#F+D9D$67$D$$T1D1$$[a$q'%BEJ$$[a$q'%BEJ$$[a$q'%BEJKK K	KK KK Ks#   C?B3C3 C?3C<8C??D		N)8rC  rD  rE  ra  rG   r`   contextmanagerrq  rv  r|  r~  r  r  r  r   r   requires_resourcer  r  namer  r  r  localsr  r  r  r  r  r	   rH  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r   rF  r  r   rG  r  r   r,  rB  r  r%  rI  r   r   rc  rc    s    G , ,
.// Wu%+ & +" Wu%- &- 
5"	[4&)	;0 3c6
 F 
	4 23&-.!3$D8 + +
# #D "" #%&)
	$1
1D ##(;D %'AB& C& TZZ()F *F
(. ""8 #80H
Kr   rc  c                       e Zd Zy)CommandLineTestsWithSourceEpochNrL  rI  r   r   r+  r+    rM  r   r+  c                       e Zd Zy)CommandLineTestsNoSourceEpochNrL  rI  r   r   r-  r-    rM  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y)HardlinkDedupTestsBasec                     d | _         y r   r   rg   s    r   rG   zHardlinkDedupTestsBase.setUp  s	    	r   c              #      K   t        j                         5 }|| _        | d | _        d d d        y # 1 sw Y   y xY wwr   )r2   r"  r8   )rE   r8   s     r   temporary_directoryz*HardlinkDedupTestsBase.temporary_directory  s;     ((* 	dDIJDI	 	 	s   ?3	?<?c                 D    t        j                  | j                  ||      S r   )r
   r   r8   )rE   coder(  s      r   r   z"HardlinkDedupTestsBase.make_script  s    ((D$??r   Tr   F)r!  r   rq   c                L    t        j                  | j                  d|||       y )NT)rr   r   hardlink_dupesrq   )re   r|   r8   )rE   r!  r   rq   s       r   r|   z"HardlinkDedupTestsBase.compile_dir  s     tyyx.35	Br   c                    | j                         5  | j                  d       | j                  t              5  t	        j
                  | j                  ddd       d d d        | j                  t              5  t	        j
                  | j                  dddgd       d d d        d d d        y # 1 sw Y   UxY w# 1 sw Y   xY w# 1 sw Y   y xY w)NpassTr   )rr   r   r7  )r3  r   r"  r   re   r|   r8   rg   s    r   test_bad_argsz$HardlinkDedupTestsBase.test_bad_args  s     %%' 		<V$"":. <&&tyyq6:<< "":. < &&tyy1v6:<<		< 		<< << <		< 		<s:   'C$B0C9&B<C0B9	5C<C	CCc                     g }|r|j                  d       |j                  d       |r|j                  d       dj                  |      S )Nz'module docstring'zx = 1zassert x == 1
)r   r9   )rE   	docstring	assertionliness       r   create_codez"HardlinkDedupTestsBase.create_code  sA    LL-.WLL)yyr   c              #   \   K   dD ]#  }dD ]  }| j                  ||      }|||f  % y w)N)FTr=  r>  )r@  )rE   r=  r>  r5  s       r   
iter_codesz!HardlinkDedupTestsBase.iter_codes  sF     & 	3I* 3	'')y'QY	223	3s   *,c           
         | j                         D ]  \  }}}| j                  ||      5  | j                         5  | j                  |      }t	        |      }| j                  d       | j                  t        |d   |d                | j                  t        |d   |d                | j                  t        |d   |d                d d d        d d d         y # 1 sw Y   xY w# 1 sw Y   xY w)NrB  Fr   r   r   r   )rC  r#  r3  r   r   r|   r   r(   )rE   r5  r=  r>  r   r$  s         r   test_disabledz$HardlinkDedupTestsBase.test_disabled  s    *.//*; 	D&D)Y	YG D--/ D!--d3F#F+D$$5$1$$[a$q'%BC$$[a$q'%BC$$[a$q'%BCDD D	DD DD Ds#   C-BC!C-!C*&C--C6	c                     t        |      }| j                  t        |d   |d         |        | j                  t        |d   |d         | xr |        | j                  t        |d   |d         |        y )Nr   r   r   )r   ry   r(   )rE   r   r=  r>  r$  s        r   check_hardlinksz&HardlinkDedupTestsBase.check_hardlinks  s    T!Wd1g6&	(T!Wd1g6&8y=	:T!Wd1g6&	(r   c                 8   | j                         D ]o  \  }}}| j                  ||      5  | j                         5  | j                  |      }| j	                          | j                  |||       d d d        d d d        q y # 1 sw Y   xY w# 1 sw Y   xY w)NrB  )rC  r#  r3  r   r|   rG  )rE   r5  r=  r>  r   s        r   r%  z$HardlinkDedupTestsBase.test_hardlink  s    *.//*; 	G&D)Y	YG G--/ G!--d3F$$&((IFGG G	GG GG Gs"   B5B1BB	BB	c           	      ~   dD ]  }| j                  |      5  | j                         5  | j                  | j                               }| j	                  |       t        ||d         }t        ||d         }| j                  t        ||             d d d        d d d         y # 1 sw Y   xY w# 1 sw Y   xY w)N))r   r   )r   r   )r   r   )optsr   r   r   )r#  r3  r   r@  r|   r   rd   r(   )rE   rJ  r   pyc1pyc2s        r   test_only_two_levelsz+HardlinkDedupTestsBase.test_only_two_levels  s    , 		=D4( =--/ = "--d.>.>.@AF$$d$3"6473D"6473DOOKd$;<== =		== == =s#   B3A+B'B3'B0,B33B<	c                    | j                         5  | j                  | j                               }| j                  g d       t	        |d      }t	        |d      }| j                  t        ||             d d d        y # 1 sw Y   y xY w)N)r   r   r   r   rK  r   r   )r3  r   r@  r|   r   rd   r(   )rE   r   rL  rM  s       r   test_duplicated_levelsz-HardlinkDedupTestsBase.test_duplicated_levels  s|     %%' 	5 %%d&6&6&89Fl361%D61%DOOKd34	5 	5 	5s   A'BB
c                    | j                         5  | j                  d      }| j                          | j                  |       t	        |      }t        j                  |d         j                  }| j                  d      }| j                  ddgd       | j                  |t        j                  |d         j                         | j                  t        |d   |d                | j                  |t        j                  |d         j                         | j                  t        j                  |d   |d   d             d d d        y # 1 sw Y   y xY w)	Nr&  r   print(0)r   T)r   rq   r   shallow)r3  r   r|   rG  r   r!   r"   r#   ry   rd   r(   r{   r   filecmpcmprE   r   r$  inodes       r   test_recompilationz)HardlinkDedupTestsBase.test_recompilation*  s&    %%' 	J%%g.F  (F#DGGDG$++E %%j1F q!fD9 UBGGDG$4$;$;<OOKQa9:rwwtAw'7'>'>?W[[a$q'4HI)	J 	J 	Js   D8EEc                    | j                         5  | j                  | j                         d      }| j                          | j	                  |       t        |      }t        j                  |d         j                  }| j                  dd      }t        j                  dddd| j                  	       | j                  |t        j                  |d         j                         | j                  |t        j                  |d
         j                         | j                  t        |d   |d
                | j                  t        j                   |d   |d
   d             d d d        y # 1 sw Y   y xY w)Nmodule)r(  r   rR  r  z-czimport moduleF)r  rl  r   r   TrS  )r3  r   r@  r|   rG  r   r!   r"   r#   r
   ry  r8   ry   r   r(   rU  rV  rW  s       r   test_importz"HardlinkDedupTestsBase.test_importC  sA    %%' 	J%%d&6&6&8x%HF  (F#DGGDG$++E %%jx%@F **dO$))
 UBGGDG$4$;$;<UBGGDG$4$;$;<[a$q':;W[[a$q'4HI-	J 	J 	Js   EE33E<N)r   )FF)rC  rD  rE  rG   r`   r&  r3  r   r|   r:  r@  rC  rE  rG  r%  rN  rP  rY  r\  rI  r   r   r0  r0    sl      @ $()5 B< 3
D(G=
5J2Jr   r0  c                       e Zd Zy)!HardlinkDedupTestsWithSourceEpochNrL  rI  r   r   r^  r^  _  rM  r   r^  c                       e Zd Zy)HardlinkDedupTestsNoSourceEpochNrL  rI  r   r   r`  r`  f  rM  r   r`  __main__)8re   r`   rU  importlib.utilr   rb   r!   rw   r6   rS   r  r2   test.test_importlib.utilr   r  ru   r   r   multiprocessing.utilr   r   concurrent.futuresr   concurrent.futures.processr   rF  NotImplementedErrorModuleNotFoundErrorr   test.supportr	   r
   test.test_py_compiler   r   test.support.os_helperr   r   r   r(   r*   TestCaserK  rQ  skipIfis_wasirS  rc  r+  r-  hasattrr0  r^  r`  rC  r  rI  r   r   <module>rp     s       	 	    
     %	" U6?   " & : 8 +F7N8 N8b	%8%-%6%6/F7;		(;(0(9(92I:?	 "DE48$$ 4 F4:zK zKz	&:'/'8'81H9=		$8%-%6%6/F7<	 WR(*<=ZJ ZJ >ZJz	(>(0(9(92I:>		&<&.&7&70G8=	 zHMMO i" 	01 "!"s   F( (	F54F5