
    z%i                     l   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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jP                  e#d      Z) G d de'ejP                  e#d      Z* ejV                  ejX                  d       G d dejP                               Z- G d d      Z. G d de.ejP                  e#d      Z/ G d de.ejP                  e#d      Z0 ej$                   e1ed       d!       G d" d#             Z2 G d$ d%e2ejP                  e#d      Z3 G d& d'e2ejP                  e#d      Z4e5d(k(  r ejl                          yy# eef$ r dZY Qw xY w))    N)mock
skipUnless)_cleanup_tests)ProcessPoolExecutor)_check_system_limitsTF)support)	os_helper)script_helper)without_source_date_epoch)SourceDateEpochTestMetac                 L    |sd}t         j                  j                  | |      S )N optimization)	importlibutilcache_from_sourcescriptopts     H/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/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    r7   r8   r3   bad_source_pathr;   r<   rC   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!   r9   st_mtimestructpackr   r   MAGIC_NUMBER)rD   rE   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)rN   rN   z0filesystem doesn't support timestamps near 2**32r    utimer9   OverflowErrorOSErrorskipTest
contextlibredirect_stdoutioStringIO
assertTrue
compileallcompile_filerD   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)         rj   z+filesystem doesn't support large timestampsrZ   rf   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rh   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 setrK   NwbFTforcequiet)r    environgetunittestSkipTest
py_compilecompiler9   assertEqualrX   r;   r:   rO   lenr<   assertNotEqualrd   compile_dirr3   rc   )rD   metadatarE   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 )NrM   r   r   )r~   rR   rS   r   r   rT   rf   s    r   
test_mtimezCompileallTestsBase.test_mtimey   s.    fkk'9>>3N3N*+Q0 	1r   c                 &    | j                  d       y )Ns       )r~   rf   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)NFTro   r   )r:   r>   r    unlinkrc   rd   re   r9   r7   isfiler{   r3   rI   assertFalserH   )rD   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                  | 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    r7   r   r:   r   captured_stdoutrc   rd   re   pathlibPathr9   assertRegexgetvalue)rD   stdouts     r   test_compile_file_pathlikez.CompileallTestsBase.test_compile_file_pathlike   s    56$$& 	U&OOJ33GLLAQAQ4RST	U*,UVt||45	U 	Us   AC00C9c                    | j                  t        j                  j                  | j                               | j                  t        j                  t        j                  | j                        t        j                  d      d             | j                  t        j                  j                  | j                               y )N	ddir_pathr   )ddirrq   r   r    r7   r   r:   rc   rd   re   r   r   r9   rf   s    r   test_compile_file_pathlike_ddirz3CompileallTestsBase.test_compile_file_pathlike_ddir   sy    56
//T=M=M0N5<\\+5N679 	: 	t||45r   c                    | j                  t        j                  j                  | j                               | j                  t        j                  t        j                  | j                        t        j                  d      d             | j                  t        j                  j                  | j                               y Nstripdir_pathr   )stripdirrq   r   rf   s    r   #test_compile_file_pathlike_stripdirz7CompileallTestsBase.test_compile_file_pathlike_stripdir   sy    56
//T=M=M0N9@o9V679 	: 	t||45r   c                    | j                  t        j                  j                  | j                               | j                  t        j                  t        j                  | j                        t        j                  d      d             | j                  t        j                  j                  | j                               y Nprependdir_pathr   )
prependdirrq   r   rf   s    r   %test_compile_file_pathlike_prependdirz9CompileallTestsBase.test_compile_file_pathlike_prependdir   sz    56
//T=M=M0N;B<<HY;Z67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r7   r   rq   FT)skip_curdirrp   rq   )
testtest_importlibr   import_stater3   rc   rd   compile_pathrI   r   rf   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)NrU   rE   rn   __pycache__)
r    r7   r8   r3   rA   r;   rd   re   r   exists)rD   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)	rI   r_   r`   ra   rb   r   rd   re   rH   rf   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   rq   optimizer   )rd   r{   r3   r   r   r   r9   rc   r    r7   r   r=   rB   )rD   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                  | 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    r7   r   r:   r   r   rd   r{   r   r   r3   r   
splitlinesr   rc   )rD   r   lines      r   test_compile_dir_pathlikez-CompileallTestsBase.test_compile_dir_pathlike   s    56$$& 	A&""7<<#?@	A ++-a0FGt||45		A 	As   3C44C=c                    | j                  t        j                  j                  | j                               | j                  t        j                  t        j                  | j                        t        j                  d      d             | j                  t        j                  j                  | j                               y r   r   r    r7   r   r:   rc   rd   r{   r   r   r3   rf   s    r   "test_compile_dir_pathlike_stripdirz6CompileallTestsBase.test_compile_dir_pathlike_stripdir   sw    56
..w||DNN/K8?_8U568 	9 	t||45r   c                    | j                  t        j                  j                  | j                               | j                  t        j                  t        j                  | j                        t        j                  d      d             | j                  t        j                  j                  | j                               y r   r   rf   s    r   $test_compile_dir_pathlike_prependdirz8CompileallTestsBase.test_compile_dir_pathlike_prependdir   sx    56
..w||DNN/K:A,,GX:Y568 	9 	t||45r   requires multiprocessingz&concurrent.futures.ProcessPoolExecutorc                 ~    t        j                  | j                  dd       | j                  |j                         y NT   rq   workersrd   r{   r3   rc   calledrD   	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
ValueErrorrd   r{   r3   rf   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)rd   r{   r3   rx   	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   )rd   r{   r3   r   r   rc   )rD   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   )rD   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)rq   	maxlevels)r3   ranger    r7   r8   rA   r5   r?   r9   r   r   r   rd   r{   r   r   rc   )rD   depthr7   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   )rq   r   r   N")r3   r    r7   r8   rA   r
   make_scriptappendr4   multiprocessing_cleanup_testsrd   r{   rc   
startswithr   r   r   ry   sepassert_python_failurer   r   get_code_from_pycrx   co_filenameassertInfsdecode)rD   r   r   fullpathr7   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   rf   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  rf   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  rf   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  rf   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realr7   r   1 / 0r   T)rq   r   r.   r    r7   r8   r3   makedirsr
   r   r   r   r   rd   r{   r   r   strsysgetdefaultencodingassertNotIn)
rD   r   r7   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)rq   r   r.   )r    r7   r8   r3   r  r
   r   r   r   r   rd   r{   r   r   r  r  r  )
rD   r   r7   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)rq   r   r   r.   r  rD   r   r7   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  r7   r   r   r  Tz/barr  )rq   r   r   r   )r    r7   r8   r3   r  r
   r   assertRaisesr   rd   r{   )rD   r   r7   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   r3   r   r   r   r   rd   re   rc   r    r7   r   r   	Exception)rD   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)rq   limit_sl_dest)r    r7   r8   r3   r  r
   r   symlinkr   r   r   rd   r{   rc   r   r   
rD   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__rF   rI   rX   rg   rk   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_symlinkrC   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rD  rE  rF  rJ  r   r   rL  rL         	r   rL  )	metaclasssource_date_epochc                       e Zd Zy)!CompileallTestsWithoutSourceEpochNrM  rJ  r   r   rR  rR    rN  r   rR  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                 2   t        j                         | _        t        j                  j                  | j                  d      | _        t        | j                  dd      5 }|j                  d       |j                  d       d d d        y # 1 sw Y   y xY w)Nr+   r,   r-   r.   z# -*- coding: utf-8 -*-
u   print u"€"
)	r1   r2   r3   r    r7   r8   r9   r;   r<   rC   s     r   rF   zEncodingTest.setUp  sp    !))+77<<
C$""C': 	,dJJ23JJ*+	, 	, 	,s   !#BBc                 B    t        j                  | j                         y r   )r5   r6   r3   rf   s    r   tearDownzEncodingTest.tearDown  s    dnn%r   c                     	 t         j                  }t        j                  t        j                         d      t         _        t        j                  | j                         |t         _        y # t         _        w xY w)Nasciir.   )r  r   ra   TextIOWrapperBytesIOrd   r{   r3   )rD   orig_stdouts     r   
test_errorzEncodingTest.test_error  sK    	%**K))"**,HCJ""4>>2$CJCJs   A!A/ /A<N)rD  rE  rF  __doc__rF   rW  r]  rJ  r   r   rT  rT    s    ,&%r   rT  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)r1   r2   r3   r4   r	   r6   r    r7   r8   pkgdirrA   pkgdir_cachedirr
   r   initfnbarfnrf   s    r   rF   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    r7   r8   r3   )rD   
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-mrd   )r   !optim_args_from_interpreter_flags)rD   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_okrs  rx   rD   rr  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 )Nru  r-   )r
   r   rs  rw  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   rc   r    r7   r   rD   r   r7   s      r   assertCompiledz#CommandLineTestsBase.assertCompiled  s/    ~~//3t,-r   c                     t         j                  j                  |      }| j                  t        j
                  j                  |             y r   )r   r   r   r   r    r7   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   rJ  )	r
   r   r3   rn  ry  r~  r  re  rf  )rD   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   rJ  )-f)r
   r   r3   rn  ry  r   r   r   r    r[   timer!   rQ   rx   rz   )rD   r  r  pycpathrV   mtime2s         r    test_no_args_respects_force_flagz5CommandLineTestsBase.test_no_args_respects_force_flag-  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 rJ  )-q)r
   r   r3   rn  ry  r   r  )rD   r  noisyrq   s       r    test_no_args_respects_quiet_flagz5CommandLineTestsBase.test_no_args_respects_quiet_flag@  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 )Nrp  rd   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>U  s2      K"& #kk#*<*<*F*FL Ks   47)z__init__.{}.{}z	bar.{}.{})r
   rv  rc  rc   r    r7   r   rd  sortedrx   listdirr   endswith)rD   r  switchexpectedr   s    `   r   fzCommandLineTestsBase.fP  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)
ry  rc  r   r    r7   r   rd  r  rx   r  )rD   r  s     r   test_legacy_pathsz&CommandLineTestsBase.test_legacy_paths]  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   )	ry  rc  rc   r    r7   r   rd  r8   r   )rD   cachecachedirs     r   test_multiple_runsz'CommandLineTestsBase.test_multiple_runsg  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  )ry  rc  r   r   r   rf  r    r[   r  r!   rQ   rx   rz   )rD   r  rV   r  s       r   
test_forcezCommandLineTestsBase.test_forcet  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    r7   r8   rc  rA   r
   r   ry  r  r   r   r~  )rD   
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    r7   r8   rc  r
   make_pkgr   ry  r  r   r   r~  )	rD   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    r7   r8   rc  r
   r  r8  ry  r~  )rD   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   )ry  rc  rz   rx   )rD   r  rq   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   rc  r{  rz   rx   )rD   r   rq   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[^\\/]*$)ry  rc  r  rf  r~  re  rf   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    r7   r8   r3   rA   r
   r   ry  rc  r~  re  rf  )rD   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   rc  r{  r   rD   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   rc  ry  r   r   r   r    renamer7   r8   remover   r   )rD   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    r7   r8   r3   rc  r   assertNotRegexr   r   r   r   r   rd  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   rc  r;   r    r7   r8   r3   r<   linesepry  r~  r  rD   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   rc  r;   r    r7   r8   r3   r<   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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  rJ  r  -rY  )r
   r   rc  spawn_pythonrs  stdinr<   r    r  encodekill_pythonr  r~  )rD   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   rc  r{  re  rf  r   r  r~  )rD   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')ry  r   )rD   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-hashrK         littler   z"--invalidation-mode=unchecked-hashr   )r
   r   rc  r   r   r   r    r7   r8   ry  r;   rO   rx   rP   
from_bytes)rD   r  fprU   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   r3   r   r    r7   r8   r  rA   r   ry  r~  )rD   r  filessuffixrc  r   rE   s          r   test_workersz!CommandLineTestsBase.test_workers6  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   rH  r  
executabler3   rd   mainrc   r   rx   r   )rD   r{   s     r   test_workers_available_coresz1CommandLineTestsBase.test_workers_available_coresE  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    r7   r8   r3   r  r
   r   r   r   r   ry  r   r   r  r  r  r  r   s              r   r!  z+CommandLineTestsBase.test_strip_and_prependM  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>p  s     $LqTCF]$Ls   )r    r7   r8   r3   r  r
   r   r   r   r   r   ry  rc   r   rP   r   r)  )rD   r7   r   r}   r*  r+  r,  s          r   r-  z6CommandLineTestsBase.test_multiple_optimization_levelsa  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/  r0  r1  r2  r3  r'  r4  r5  r6  z-e)r    r7   r8   r3   r  r
   r   r8  r   r   r   ry  rc   r   r   r9  s
             r   rC  z4CommandLineTestsBase.test_ignore_symlink_destinationx  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{  r3   rf   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   )
r1   TemporaryDirectorysubTestr
   r   r   r   ry  rx   r'   )rD   r  r7   r   pycsrr  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)8rD  rE  rF  r^  rF   r_   contextmanagerrn  rs  ry  r{  r~  r  r  r   r   requires_resourcer  r  namer  r  r  localsr  r  r  r  r  r	   rI  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rG  r  r   rH  r  r!  r-  rC  r  r"  rJ  r   r   r`  r`    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   r`  c                       e Zd Zy)CommandLineTestsWithSourceEpochNrM  rJ  r   r   r(  r(    rN  r   r(  c                       e Zd Zy)CommandLineTestsNoSourceEpochNrM  rJ  r   r   r*  r*    rN  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   rf   s    r   rF   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   )r1   r  r7   )rD   r7   s     r   temporary_directoryz*HardlinkDedupTestsBase.temporary_directory  s;     ((* 	dDIJDI	 	 	s   ?3	?<?c                 D    t        j                  | j                  ||      S r   )r
   r   r7   )rD   coder%  s      r   r   z"HardlinkDedupTestsBase.make_script  s    ((D$??r   Tr   F)r  r   rp   c                L    t        j                  | j                  d|||       y )NT)rq   r   hardlink_dupesrp   )rd   r{   r7   )rD   r  r   rp   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   )rq   r   r4  )r0  r   r#  r   rd   r{   r7   rf   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   r8   )rD   	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=  )rD   r:  r;  r2  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)Nr?  Fr  r   r   r   )r@  r   r0  r   r   r{   r   r'   )rD   r2  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   rx   r'   )rD   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)Nr?  )r@  r   r0  r   r{   rD  )rD   r2  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   r0  r   r=  r{   r   rc   r'   )rD   rG  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   rH  r   r   )r0  r   r=  r{   r   rc   r'   )rD   r   rI  rJ  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   rp   r   shallow)r0  r   r{   rD  r   r    r!   r"   rx   rc   r'   rz   r   filecmpcmprD   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   rO  r  z-czimport moduleF)r  ri  r   r   TrP  )r0  r   r=  r{   rD  r   r    r!   r"   r
   rv  r7   rx   r   r'   rR  rS  rT  s       r   test_importz"HardlinkDedupTestsBase.test_import=  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)rD  rE  rF  rF   r_   r#  r0  r   r{   r7  r=  r@  rB  rD  r"  rK  rM  rV  rY  rJ  r   r   r-  r-    sl      @ $()5 B< 3
D(G=
5J2Jr   r-  c                       e Zd Zy)!HardlinkDedupTestsWithSourceEpochNrM  rJ  r   r   r[  r[  Y  rN  r   r[  c                       e Zd Zy)HardlinkDedupTestsNoSourceEpochNrM  rJ  r   r   r]  r]  `  rN  r   r]  __main__)7rd   r_   rR  importlib.utilr   ra   r    r   rv   r5   rR   r  r1   test.test_importlib.utilr   r  rt   r   r   multiprocessing.utilr   r   concurrent.futuresr   concurrent.futures.processr   rG  NotImplementedErrorModuleNotFoundErrorr   test.supportr	   r
   test.test_py_compiler   r   r   r   r'   r)   TestCaserL  rR  skipIfis_wasirT  r`  r(  r*  hasattrr-  r[  r]  rD  r  rJ  r   r   <module>rl     s       	 	     
     %	" U6?   " & : 8F7N8 N8b	%8%-%6%6/F7;		(;(0(9(92I:?	 "DE%8$$ % F%.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 [" 	01 "!"s   F& &	F32F3