Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_compileall.cpython-310.pyc
o

�9j1��@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlmZmZddlmZz
ddlmZe�dZWneybdZYnwddlmZddlmZdd	lmZdd
lmZddlmZdd
�Z dd�Z!dd�Z"Gdd�d�Z#Gdd�de#ej$edd�Z%Gdd�de#ej$edd�Z&Gdd�dej$�Z'Gdd�d�Z(Gdd�de(ej$edd�Z)Gdd �d e(ej$edd�Z*Gd!d"�d"�Z+Gd#d$�d$e+ej$edd�Z,Gd%d&�d&e+ej$edd�Z-e.d'k�re�/�dSdS)(�N)�mock�
skipUnless)�ProcessPoolExecutor)�_check_system_limitsTF)�support)�	os_helper)�
script_helper)�without_source_date_epoch)�SourceDateEpochTestMetacCs|sd}tjj||d�S)N���optimization)�	importlib�util�cache_from_source)�script�opt�r�+/usr/lib/python3.10/test/test_compileall.py�get_pyc#srcs�fdd�dD�S)Ncsg|]}t�|��qSr)r)�.0r�rrr�
<listcomp>+szget_pycs.<locals>.<listcomp>�r��rrrrr�get_pycs*srcCs t�|�j}t�|�j}||kS)z8Returns True if two files have the same inode (hardlink))�os�stat�st_ino)�	filename1�	filename2�inode1�inode2rrr�is_hardlink.sr$c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zeed+�e�d,�d-d.���Zd/d0�Zeed+�e�d,�d1d2���Zeed+�e�d,�e�d3�d4d5����Zejd,d6d7�e�d3�d8d9���Z d:d;�Z!d<d=�d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+e,j-dRdS��Z.d6S)T�CompileallTestsBasecCs�t��|_tj�|jd�|_tj�	|j�|_
t|jddd��
}|�d�Wd�n1s.wYtj�|jd�|_
tj�	|j
�|_t�|j|j
�tj�|jd�|_t�|j�tj�|jd�|_t�|j|j�dS)	N�_test.py�w�utf-8��encodingzx = 123
z	_test2.py�_subdirz	_test3.py)�tempfile�mkdtemp�	directoryr�path�join�source_pathrrr�bc_path�open�write�source_path2�bc_path2�shutil�copyfile�subdirectory�mkdir�source_path3��self�filerrr�setUp7s
�zCompileallTestsBase.setUpcC�t�|j�dS�N�r7�rmtreer.�r=rrr�tearDownE�zCompileallTestsBase.tearDowncCsRtj�|jd�|_t|jddd��}|�d�Wd�dS1s"wYdS)Nz_test_bad.pyr'r(r)zx (
)rr/r0r.�bad_source_pathr3r4r<rrr�add_bad_source_fileHs"�z'CompileallTestsBase.add_bad_source_filecCsht|jd��
}|�d�}Wd�n1swYtt�|j�j�}t�	dt
jjd|d@�}||fS)N�rb��<4sLLr���)
r3r2�read�intrrr1�st_mtime�struct�packrr�MAGIC_NUMBER)r=r>�data�mtime�comparerrr�timestamp_metadataMs��z&CompileallTestsBase.timestamp_metadatac	C�zz	t�|jd�Wnttfy|�d�Ynwt�t�	���|�
t�|j��Wd�dS1s6wYdS)N)rLrLz0filesystem doesn't support timestamps near 2**32�
r�utimer1�
OverflowError�OSError�skipTest�
contextlib�redirect_stdout�io�StringIO�
assertTrue�
compileall�compile_filerDrrr� test_year_2038_mtime_compilationU��"�z4CompileallTestsBase.test_year_2038_mtime_compilationc	CrW)N)� rfz+filesystem doesn't support large timestampsrXrDrrr�test_larger_than_32_bit_times_rez1CompileallTestsBase.test_larger_than_32_bit_timescCs�tj�d�rt�d��t�|j�|j|�	��t
|jd��}|��t
|�d�}Wd�n1s3wYt
|jd��}|�|�|�|�Wd�n1sSwY|j|�	��tj|jddd�|j|�	��dS)	zOCheck that compileall recreates bytecode when the new metadata is
        used.�SOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setrIN�wbFT��force�quiet)r�environ�get�unittest�SkipTest�
py_compile�compiler1�assertEqualrVr3r2rM�lenr4�assertNotEqualrb�compile_dirr.ra)r=�metadatar>�bcrrr�recreation_checkis
�
�z$CompileallTestsBase.recreation_checkcCs|�t�dtjjdd��dS)NrKrr)ryrPrQrrrRrDrrr�
test_mtimeys
�zCompileallTestsBase.test_mtimecCs|�d�dS)Ns)ryrDrrr�test_magic_number~�z%CompileallTestsBase.test_magic_numbercCs|j|jfD]}zt�|�WqYq|�tj|jddd��|�tj�	|j�o1tj�	|j��t�|j�|�tj
|jddd��|�tj�	|j�oTtj�	|j��t�|j�t�|j�|��|�
tj|jddd��|�
tj
|jddd��dS)NFTrjr)r2r6r�unlinkrarbrcr1r/�isfilervr.rH�assertFalserG)r=�fnrrr�test_compile_files�s6������z&CompileallTestsBase.test_compile_filescCs||�tj�|j��t���}|�t�	t
�|j���Wd�n1s%wY|�
|��d�|�tj�|j��dS)Nz&Compiling ([^WindowsPath|PosixPath].*))rrr/r~r2r�captured_stdoutrarbrc�pathlib�Pathr1�assertRegex�getvalue)r=�stdoutrrr�test_compile_file_pathlike�s
�z.CompileallTestsBase.test_compile_file_pathlikecC�P|�tj�|j��|�tjt�	|j
�t�	d�dd��|�tj�|j��dS)N�	ddir_pathr)�ddirrl�rrr/r~r2rarbrcr�r�r1rDrrr�test_compile_file_pathlike_ddir���z3CompileallTestsBase.test_compile_file_pathlike_ddircCr��N�
stripdir_pathr)�stripdirrlr�rDrrr�#test_compile_file_pathlike_stripdir�r�z7CompileallTestsBase.test_compile_file_pathlike_stripdircCr��N�prependdir_pathr)�
prependdirrlr�rDrrr�%test_compile_file_pathlike_prependdir�r�z9CompileallTestsBase.test_compile_file_pathlike_prependdircCs�tjjj|jgd��|�tjdd��Wd�n1swYtjjj|jgd��|��|�	tjdddd��Wd�dS1sHwYdS)N�r/r�rlFT)�skip_curdirrkrl)
�test�test_importlibr�import_stater.rarb�compile_pathrHrrDrrr�test_compile_path�s�

�"�z%CompileallTestsBase.test_compile_pathcCs|tj�|jd�}tj�|d�}t�|�t|d��Wd�n1s$wYt�|�|�tj�	tj�|d���dS)NrSr>ri�__pycache__)
rr/r0r.r:r3rbrcr�exists)r=�data_dir�	data_filerrr�test_no_pycache_in_non_package�s
�
 z2CompileallTestsBase.test_no_pycache_in_non_packagecCsN|��t�t����|�t�|j��Wd�dS1s wYdSrA)	rHr]r^r_r`rrbrcrGrDrrr�#test_compile_file_encoding_fallback�s"�z7CompileallTestsBase.test_compile_file_encoding_fallbackcCs�d\}}tj|jd|d�tjj|j|d�}|�tj	�
|��tjj|j|d�}|�tj	�
|��tjj|j|d�}|�tj	�
|��dS)NT)rr)rr�rl�optimizer)
rbrvr.rrrr1rarr/r~r5r;)r=r�r�cached�cached2�cached3rrr�
test_optimize�s
�
�
�z!CompileallTestsBase.test_optimizecCs�|�tj�|j��t���}t�t	�
|j��Wd�n1s"wY|���
�d}|�|d�|�tj�|j��dS)Nrz$Listing ([^WindowsPath|PosixPath].*))rrr/r~r2rr�rbrvr�r�r.r��
splitlinesr�ra)r=r��linerrr�test_compile_dir_pathlike�s
�z-CompileallTestsBase.test_compile_dir_pathlikecCr�r��rrr/r~r2rarbrvr�r�r.rDrrr�"test_compile_dir_pathlike_stripdir�r�z6CompileallTestsBase.test_compile_dir_pathlike_stripdircCr�r�r�rDrrr�$test_compile_dir_pathlike_prependdir�r�z8CompileallTestsBase.test_compile_dir_pathlike_prependdir�requires multiprocessingz&concurrent.futures.ProcessPoolExecutorcC�"tj|jddd�|�|j�dS�NT��rl�workers�rbrvr.ra�called�r=�	pool_mockrrr�test_compile_pool_called��z,CompileallTestsBase.test_compile_pool_calledcCsB|�td��tj|jdd�Wd�dS1swYdS)Nz%workers must be greater or equal to 0���)r�)�assertRaisesRegex�
ValueErrorrbrvr.rDrrr�!test_compile_workers_non_positives
�"�z5CompileallTestsBase.test_compile_workers_non_positivecCs,tj|jddd�|�|jddd�dS)NTrr�r�max_workers)rbrvr.rs�	call_argsr�rrr�test_compile_workers_cpu_countsz2CompileallTestsBase.test_compile_workers_cpu_countzcompileall.compile_filecCs,tj|jdd�|�|j�|�|j�dS)NTr�)rbrvr.rr�ra)r=�compile_file_mockr�rrr�test_compile_one_workersz+CompileallTestsBase.test_compile_one_workerN��newcCr�r�r�)r=r�rrr�$test_compile_missing_multiprocessingr�z8CompileallTestsBase.test_compile_missing_multiprocessingcCs�d}|j}td|d�D]}tj�|d|���}tj�|d�}t�|�t�|j|�qt	j
�|�}tj
|jd|dd�|�tj�|��tj
|jd|d�|�tj�|��dS)N�r�dir_z	script.pyT)rl�	maxlevels)r.�rangerr/r0r:r7r8r1rrrrbrvrr~ra)r=�depthr/�i�source�pyc_filenamerrr�test_compile_dir_maxlevelss
z.CompileallTestsBase.test_compile_dir_maxlevelsT)�parallelcCsddg}|j}g}|D]}tj�||�}t�|�t�|dd�|�t�|dd��qtj	|jd||r5dnd	d
�|�
|�|D]H}|�
|�|j�|�tj
�|�}|t|jtj�d�}	t�|�\}
}
}tj�||	�}tjj
�|�}
|�|
j|�|�d|�d�t�|��q@dS)
z@Recursive compile_dir ddir must contain package paths; bpo39769.r��foo�__init__r�modzdef fn(): 1/0
fn()
Trr)rlr�r�N�")r.rr/r0r:r�make_script�appendrbrvra�
startswithrrrrt�sep�assert_python_failurer�r��get_code_from_pycrs�co_filename�assertIn�fsdecode)r=r�r��fullpathr/�mods�subdirr��modcode�modpath�_�err�expected_in�mod_code_objrrr�_test_ddir_only*s2
�
�
�z#CompileallTestsBase._test_ddir_onlycC�|jddd�S)�=Recursive compile_dir ddir= contains package paths; bpo39769.�
<a prefix>F�r�r��r�rDrrr�test_ddir_only_one_workerCr|z-CompileallTestsBase.test_ddir_only_one_workercCr�)r�r�Tr�r�rDrrr�test_ddir_multiple_workersGr|z.CompileallTestsBase.test_ddir_multiple_workerscCr�)�?Recursive compile_dir ddir='' contains package paths; bpo39769.rFr�r�rDrrr�test_ddir_empty_only_one_workerKr|z3CompileallTestsBase.test_ddir_empty_only_one_workercCr�)r�rTr�r�rDrrr� test_ddir_empty_multiple_workersOr|z4CompileallTestsBase.test_ddir_empty_multiple_workersc
Cs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}tjj|jg|dd��R�}t
j|d|d�t�|�\}}}tjj|dd��}	|�
|	t|t��d��|�|t|t��d��dS)N�r��build�realr/r��1 / 0rT)rlr�r)�rr/r0r.�makedirsrr�rrrrbrvr�r��str�sys�getdefaultencoding�assertNotIn)
r=r�r/rrxr��rc�outr�r�rrr�test_strip_onlySs"
��z#CompileallTestsBase.test_strip_onlyc
Cs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}d}t
j|d|d�t�|�\}}}tjj||jg|�R�}	|�
|	t|t��d��dS)Nr�r�r��/fooT)rlr�r))rr/r0r.r�rr�rrrrbrvr�r�r�r�r�)
r=r�r/rrxr�r�r�r�r�rrr�test_prepend_onlyfs
�z%CompileallTestsBase.test_prepend_onlycCs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}tjj|jg|dd��R�}d}t
j|d||d�t�|�\}}}	tjj|g|dd��R�}
|�
|
t|	t��d��|�|t|	t��d��dS)	Nr�r�r�rrT)rlr�r�r)r��r=r�r/rrxr�r�r�r�r�r�rrr�test_strip_and_prependus(
���z*CompileallTestsBase.test_strip_and_prependcCszgd�}tjj|jg|�R�}t�|�t�|dd�|�t��t	j
|ddddd�Wd�dS1s6wYdS)N)r�r�r�r/r�r�r�Tz/barr)rlr�r�r�)rr/r0r.r�rr��assertRaisesr�rbrv)r=r�r/rrr�test_strip_prepend_and_ddir�s

�"�z/CompileallTestsBase.test_strip_prepend_and_ddirc
Cs�t�|jdd�}g}dD]
}|�tjj||d��qddgddgddggd�g}|D],}tj|d	|d
�|D]}|�	t
j�||��z	t
�
||�Wq6tyUYq6wq*dS)N�test_optimization�a = 0�rrrr�rrrrrTr�)rr�r.r�rrrrbrcrarr/r~r}�	Exception)r=rrx�	opt_level�test_combinations�opt_combinationrrr�!test_multiple_optimization_levels�s.�
�����z5CompileallTestsBase.test_multiple_optimization_levelsc
Cs�tj�|jddd�}tj�|jddd�}tj�|jddd�}t�|�t�|�t�|�t�|dd�}t�|dd�}tj�|d	�}tj�|d
�}t�||�t�||�tj	�
|�}tj	�
|�}	tj|d|d�|�
tj�|��|�tj�|	��dS)
Nr��dir�allowed�symlinks�
prohibited�test_allowedr�test_prohibited�test_allowed.py�test_prohibited.pyT)rl�
limit_sl_dest)rr/r0r.r�rr��symlinkrrrrbrvrar~r�
r=�allowed_path�
symlinks_path�prohibited_path�allowed_script�prohibited_script�allowed_symlink�prohibited_symlink�
allowed_bc�
prohibited_bcrrr�test_ignore_symlink_destination�s"


z3CompileallTestsBase.test_ignore_symlink_destination)/�__name__�
__module__�__qualname__r?rErHrVrdrgryrzr{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�rrrrrr�skip_unless_symlinkr#rrrrr%5sb

	
	r%c@�eZdZdS)�CompileallTestsWithSourceEpochN�r$r%r&rrrrr+��r+)�	metaclass�source_date_epochc@r*)�!CompileallTestsWithoutSourceEpochNr,rrrrr0�r-r0c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�EncodingTestzTIssue 6716: compileall should escape source code when printing errors
    to stdout.cCsft��|_tj�|jd�|_t|jddd��}|�d�|�d�Wd�dS1s,wYdS)Nr&r'r(r)z# -*- coding: utf-8 -*-
u
print u"€"
)	r,r-r.rr/r0r1r3r4r<rrrr?�s

"�zEncodingTest.setUpcCr@rArBrDrrrrE�rFzEncodingTest.tearDowncCs<ztj}tjt��dd�t_t�|j�W|t_dS|t_w)N�asciir))r�r�r_�
TextIOWrapper�BytesIOrbrvr.)r=�orig_stdoutrrr�
test_error�s
zEncodingTest.test_errorN)r$r%r&�__doc__r?rEr6rrrrr1�s
r1c@s�eZdZdZdd�Zejdd��Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
edd��Zdd�ZddgfdddgfdddgffD]\ZZZeefdd�Zee�d e<qCd!d"�Zd#d$�Zed%d&��Zd'd(�Zd)d*�Zejd+d,��Zd-d.�Zd/d0�Zd1d2�Z d3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dCdD�Z)dEdF�Z*e+e,dG�dHdI��Z-e.�/dJ�dKdL��Z0dMdN�Z1dOdP�Z2ejdQdR��Z3dSdT�Z4dUdV�Z5dWS)X�CommandLineTestsBasezTest compileall's CLI.cCsrt��|_|�tj|j�tj�|jd�|_	t�
|j	�tj�|j	d�|_t�
|j	dd�|_t�
|j	dd�|_dS)Nr�r�r�r�bar)r,r-r.�
addCleanuprrCrr/r0�pkgdirr:�pkgdir_cachedirrr��initfn�barfnrDrrrr?�s
zCommandLineTestsBase.setUpccsB�tj}tj�|jd�}z|t_|j|d�VW|t_dS|t_w)z&Adjust and restore sys.pycache_prefix.�
__testcache__)�
PYTHONPATH�PYTHONPYCACHEPREFIXN)r��pycache_prefixrr/r0r.)r=�
old_prefix�
new_prefixrrr�temporary_pycache_prefix�s�
�z-CommandLineTestsBase.temporary_pycache_prefixcCsgt���d�d�d�|�S)Nz-S�-mrb)r�!optim_args_from_interpreter_flags)r=�argsrrr�
_get_run_argss
����z"CommandLineTestsBase._get_run_argscOs4tj|�|�i|�ddi��\}}}|�d|�|S)N�PYTHONIOENCODINGr(�)r�assert_python_okrIrs�r=rH�env_varsr�r�r�rrr�assertRunOKs���z CommandLineTestsBase.assertRunOKcOs.tj|�|�i|�ddi��\}}}|||fS)NrJr()rr�rIrMrrr�assertRunNotOKs���
z#CommandLineTestsBase.assertRunNotOKcC�"tj�|�}|�tj�|��dSrA)rrrrarr/r��r=r�r/rrr�assertCompiled�z#CommandLineTestsBase.assertCompiledcCrQrA)rrrrrr/r�rRrrr�assertNotCompiledrTz&CommandLineTestsBase.assertNotCompiledcCspt�|jdd�}|���"}|jdi|��|�|�|�|j�|�|j�Wd�dS1s1wYdS)N�bazrr)	rr�r.rErOrSrUr=r>)r=�bazfn�envrrr�test_no_args_compiles_paths

"�z/CommandLineTestsBase.test_no_args_compiles_pathcCs�t�|jdd�}|���}|jdi|��tj�|�}Wd�n1s%wYt�	|t
�
�dfd�t�|�j}|jdi|��t�|�j}|�
||�|jdi|��t�|�j}|�||�dS)NrVr�<r�-fr)r[)rr�r.rErOrrrrrY�timerrOrsru)r=rWrX�pycpathrT�mtime2rrr� test_no_args_respects_force_flag#s
�z5CommandLineTestsBase.test_no_args_respects_force_flagcCstt�|jdd�|���}|jdi|��}Wd�n1swY|�d|�|jdi|��}|�d|�dS)NrVrsListing �-qr)r`)rr�r.rErOr�r�)r=rX�noisyrlrrr� test_no_args_respects_quiet_flag5s
�z5CommandLineTestsBase.test_no_args_respects_quiet_flag�normal�pycr�z	opt-1.pyc�-O�doubleoptimizez	opt-2.pycz-OOcs~tj|ddd|jg�|�tj�|j��t�fdd�dD��}|�	tt�
|j��|�|��fdd�t�
|j�D��dS)	NrFrbr`c3s �|]}|�tjj��VqdSrA)�formatr��implementation�	cache_tag)r�base��extrr�	<genexpr>Is��z)CommandLineTestsBase.f.<locals>.<genexpr>)z__init__.{}.{}z	bar.{}.{}csg|]	}|���r|�qSr)�endswith)rr�rkrrrMs
�z*CommandLineTestsBase.f.<locals>.<listcomp>)rrLr;rarr/r�r<�sortedrs�listdirr)r=rl�switch�expectedrrkr�fDs��$zCommandLineTestsBase.f�test_pep3147_paths_cCsL|�dd|j�|�tj�|j��tgd��}|�tt�	|j��|�dS)Nz-br`)�__init__.pyz__init__.pyczbar.pyzbar.pyc)
rOr;rrr/r�r<rorsrp)r=rrrrr�test_legacy_pathsQsz&CommandLineTestsBase.test_legacy_pathscCs||�d|j�|�tj�|j��tj�|jd�}|�tj�|��|�d|j�|�tj�|j��|�tj�|��dS)Nr`r�)	rOr;rarr/r�r<r0r)r=�
cachecachedirrrr�test_multiple_runs[sz'CommandLineTestsBase.test_multiple_runscCs�|�d|j�tj�|j�}t�|t��dfd�t�	|�j
}|�d|j�t�	|�j
}|�||�|�dd|j�t�	|�j
}|�||�dS)Nr`rZrr[)
rOr;rrrr>rrYr\rrOrsru)r=r]rTr^rrr�
test_forcehszCommandLineTestsBase.test_forcecCs�tj�|jd�}t�|�t�|dd�}t�|dd�}|�dd|j�|�|�|�	tj�
tj�|d���|�d|j�|�|�|�|�dS)N�spamr�r�hamr`z-lr�)rr/r0r;r:rr�rOrUrr�rS)r=�
subpackage�	subinitfn�hamfnrrr�test_recursion_controlxs


z+CommandLineTestsBase.test_recursion_controlc	CsVtj�|jd�}tj�|d�}tj�|d�}|||fD]}t�|�qtj�|d�}t�|dd�}t�|dd�}t�|dd�}|�dd|j�|�|�|�	tj�
tj�|d	���|�dd
|j�|�|�|�|�|�|�|�dd|j�|�|�|�|�|�|�|�|�|�dd|j�|�|�|�|�|�|�|�|�dS)
Nrzr{�eggsrur�eggr`z-r 0r�z-r 1z-r 2z-r 5)rr/r0r;r�make_pkgr�rOrUrr�rS)	r=r|�subpackage2�subpackage3�pkgr}r~�spamfn�eggfnrrr�test_recursion_limit�s8
�









z)CommandLineTestsBase.test_recursion_limitc	Csttj�|jd�}t�|�t�dtj�|d��t�dtj�|d��|�d|j�|�tj�|jdddd��dS)Nrz�.�evil�evil2r`ru)	rr/r0r;rr�rrOrS)r=r�rrr�test_symlink_loop�s


�z&CommandLineTestsBase.test_symlink_loopcCs6|�|j�}|�d|j�}|�d|�|�d|�dS)Nr`rK)rOr;rurs)r=rarlrrr�
test_quiet�szCommandLineTestsBase.test_quietcCsTt�|jdd�|�d|j�\}}}|�d|j�\}}}|�d|�|�d|�dS)N�crunchyfrog�
bad(syntaxr`z-qqrK)rr�r;rPrurs)r=r�rl�silentrrr�test_silent�s
z CommandLineTestsBase.test_silentcCs.|�ddd|j�|�|j�|�|j�dS)Nr`z-xz
ba[^\\/]*$)rOr;rUr>rSr=rDrrr�test_regexp�sz CommandLineTestsBase.test_regexpcCsvtj�|jd�}t�|�t�|dd�}t�|dd�}|�d|j|�|�	|j
�|�	|j�|�	|�|�	|�dS)N�foo2r�r�bar2r`)rr/r0r.r:rr�rOr;rSr=r>)r=�pkgdir2�init2fn�bar2fnrrr�test_multiple_dirs�s

z'CommandLineTestsBase.test_multiple_dirscCs8t�|jdd�|�ddd|j�\}}}|�|d�dS)Nr�r�r`�-d�dinsdale�File "dinsdale)rr�r;rPr��r=r�r�r�rrr�test_d_compile_error�sz)CommandLineTestsBase.test_d_compile_errorcCs�t�|jdd�}|�ddd|j�t�|jdd�}tj�|�}t�|tj	�
|jd��t�|�tj|d	d
�\}}}|�
|d�dS)NrVzraise Exceptionr`r�r��bingz
import bazzbaz.pycF)�
__isolatedr�)rr�r;rOrrrr�renamer/r0�remover�r�)r=rWr�rdr�r�r�rrr�test_d_runtime_error�s
z)CommandLineTestsBase.test_d_runtime_errorcCsZ|�dtj�|jd�|j�\}}}|�|d�|�|d�|�tj�	t
j�|j
���dS)N�-i�
nosuchfilesrror.*nosuchfiles	Traceback)rPrr/r0r.r;r��assertNotRegexrr�rrrr<r�rrr�test_include_bad_file�s
��z*CommandLineTestsBase.test_include_bad_filecCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}ttj�|jd�ddd	��$}|�tj�|jd
�tj	�|�tj�|jd�tj	�Wd�n1sTwY|�
dtj�|jd�|�|�|�|�|�|�|�|�|�dS)
N�f1r�f2�f3�f4�l1r'r(r)�f1.py�f2.pyr�)
rr�r;r3rr/r0r.r4�lineseprOrSrU�r=r�r�r�r�r�rrr�test_include_file_with_arg�s�


z/CommandLineTestsBase.test_include_file_with_argcCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}ttj�|jd�ddd	��}|�tj�|jd
�tj	�Wd�n1sFwY|�
dtj�|jd��|�|�|�|�|�|�|�|�dS)Nr�rr�r�r�r�r'r(r)r�r�)
rr�r;r3rr/r0r.r4r�rOrUrSr�rrr�test_include_file_no_arg�s�


z-CommandLineTestsBase.test_include_file_no_argcCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}tj|�d�ddg�}|j�|tj�	d	��t�
|�|�|�|�|�|�|�|�|�dS)
Nr�rr�r�r�rr��-r2)
rr�r;�spawn_pythonrI�stdinr4rr��encode�kill_pythonrUrS)r=r�r�r�r��prrr�test_include_on_stdins



z*CommandLineTestsBase.test_include_on_stdincCs\t�|jdd�}|�d|j||j�\}}}|�|d�|�|�|�|j�|�|j�dS)Nr�zsyntax(errorr�srror)	rr�r;rPr=r>r�rUrS)r=�bingfnr�r�r�rrr�!test_compiles_as_much_as_possibles

�
z6CommandLineTestsBase.test_compiles_as_much_as_possiblecCs|�d�}|�|d�dS)N�badfilenamesCan't list 'badfilename')rOr�)r=r�rrr�!test_invalid_arg_produces_messages
z6CommandLineTestsBase.test_invalid_arg_produces_messagecCs�t�|jdd�tj�tj�|jd��}|�	d|j�t
|d��}|��}Wd�n1s/wY|�t
�|dd�d�d	�|�	d
|j�t
|d��}|��}Wd�n1s]wY|�t
�|dd�d�d�dS)Nr�rr�z --invalidation-mode=checked-hashrI���littler�z"--invalidation-mode=unchecked-hashr)rr�r;rrrrr/r0rOr3rMrsrN�
from_bytes)r=rd�fprSrrr�test_pyc_invalidation_modes�
�
� z/CommandLineTestsBase.test_pyc_invalidation_moder�cCs�t�|jdd�}g}td�D]#}tj�|jd�|��}t�|�t�|dd�}|�	t�|dd��q|�
|jdd�|�|�|D]}|�|�qAdS)Nr�rr�zfoo{}r�z-j�0)rr�r.r�rr/r0rgr:r�rOrS)r=r��files�suffixr;r�r>rrr�test_workers*s

�z!CommandLineTestsBase.test_workerszcompileall.compile_dircCshtjdtj|jdgd��t��|�|j�|�	|j
ddd�Wd�dS1s-wYdS)Nzsys.argvz-j0r�r�r�r)rr(r��
executabler.rb�mainrar�rsr�)r=rvrrr�test_workers_available_cores9s�"�z1CommandLineTestsBase.test_workers_available_corescCs�gd�}tjj|jg|�R�}t�|�t�|dd�}tj�	|�}tjj|jg|dd��R�}d}|�
d|d||�t�|�\}}}	tjj|g|dd��R�}
|�|
t
|	t��d��|�|t
|	t��d��dS)	Nr�r�r�rrz-sz-pr))rr/r0r.r�rr�rrrrOr�r�r�r�r�r�rrrrrAs$
��z+CommandLineTestsBase.test_strip_and_prependc
Cs�tj�|jd�}t�|�t�|dd�}g}dD]
}|�tj	j
||d��qddgddgddggd	�g}|D]4}|j|gd
d�|D��R�|D]!}|�tj�
|t|���z	t�||�WqHtyiYqHwq6dS)N�
optimizationsrrr	rr��1�2)r�r�r�css�|]	}dt|�VqdS)z-oN)r�)r�nrrrrmds�zICommandLineTestsBase.test_multiple_optimization_levels.<locals>.<genexpr>)rr/r0r.r�rr�r�rrrrOrar~rNr}r
)r=r/rrxrrr
rrrrUs6
�
�����z6CommandLineTestsBase.test_multiple_optimization_levelsc
Cs�tj�|jddd�}tj�|jddd�}tj�|jddd�}t�|�t�|�t�|�t�|dd�}t�|dd�}tj�|d	�}tj�|d
�}t�||�t�||�tj	�
|�}tj	�
|�}	|�|d|�|�tj�
|��|�tj�
|	��dS)Nr�rrrrrrrrrz-e)rr/r0r.r�rr�rrrrrOrar~rrrrrr#ls"


z4CommandLineTestsBase.test_ignore_symlink_destinationcCs|�|jdd�dS)N�-o 1�--hardlink-dupes)rPr.rDrrr�test_hardlink_bad_args�sz+CommandLineTestsBase.test_hardlink_bad_argsc
Cs�dD]r}t���d}|j|d��Nt�|dd�}t|�}gd�}|r&|�d�|j|g|�R�|�t	|d|d�|�|�t	|d|d	�|�|�t	|d|d	�|�Wd�n1s`wYWd�n1sowYqdS)
N)TF��deduprr)r`z-o 0r�z-o 2r�rrr)
r,�TemporaryDirectory�subTestrr�rr�rOrsr$)r=r�r/r�pycsrHrrr�
test_hardlink�s"

�����z"CommandLineTestsBase.test_hardlinkN)6r$r%r&r7r?r]�contextmanagerrErIrOrPrSrUrYr	r_rb�namerlrqrs�localsrvrxryrr�rr)r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr'r�rr(r�rrr#r�r�rrrrr8�sf


	


�

"




	


r8c@r*)�CommandLineTestsWithSourceEpochNr,rrrrr��r-r�c@r*)�CommandLineTestsNoSourceEpochNr,rrrrr��r-r�c@s�eZdZdd�Zejdd��Zd#dd�Zdd	d
d�dd
�Zdd�Z	d$dd�Z
dd�Zdd�Zd$dd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"S)%�HardlinkDedupTestsBasecCs
d|_dSrAr�rDrrrr?�s
zHardlinkDedupTestsBase.setUpccsB�t���}||_|Vd|_Wd�dS1swYdSrA)r,r�r/)r=r/rrr�temporary_directory�s�
"�z*HardlinkDedupTestsBase.temporary_directoryrcCst�|j||�SrA)rr�r/)r=�coder�rrrr��rFz"HardlinkDedupTestsBase.make_scriptTrF)r�r�rkcCstj|jd|||d�dS)NT)rlr��hardlink_dupesrk)rbrvr/)r=r�r�rkrrrrv�s
�z"HardlinkDedupTestsBase.compile_dirc	Cs�|���V|�d�|�t��tj|jdddd�Wd�n1s$wY|�t��tj|jdddgdd�Wd�n1sEwYWd�dSWd�dS1s]wYdS)N�passTr)rlr�r�)r�r�rr�rbrvr/rDrrr�
test_bad_args�s

�����"�z$HardlinkDedupTestsBase.test_bad_argscCs4g}|r	|�d�|�d�|r|�d�d�|�S)Nz'module docstring'zx = 1z
assert x == 1�
)r�r0)r=�	docstring�	assertion�linesrrr�create_code�s



z"HardlinkDedupTestsBase.create_codeccs4�dD]}dD]}|j||d�}|||fVqqdS)N)FT�r�r�)r�)r=r�r�r�rrr�
iter_codes�s���z!HardlinkDedupTestsBase.iter_codesc
Cs�|��D]c\}}}|j||d��O|���;|�|�}t|�}|jdd�|�t|d|d��|�t|d|d��|�t|d|d��Wd�n1sSwYWd�n1sbwYqdS)Nr�Fr�rrr)r�r�r�r�rrvrr$)r=r�r�r�rr�rrr�
test_disabled�s

�����z$HardlinkDedupTestsBase.test_disabledcCsft|�}|�t|d|d�|�|�t|d|d�|o!|�|�t|d|d�|�dS)Nrrr)rrsr$)r=rr�r�r�rrr�check_hardlinks�s�
��z&HardlinkDedupTestsBase.check_hardlinksc
Cs�|��D]@\}}}|j||d��,|���|�|�}|��|�|||�Wd�n1s0wYWd�n1s?wYqdS)Nr�)r�r�r�r�rvr�)r=r�r�r�rrrrr��s

�����z$HardlinkDedupTestsBase.test_hardlinkc
Cs�dD]O}|j|d��?|���+|�|���}|j|d�t||d�}t||d�}|�t||��Wd�n1s=wYWd�n1sLwYqdS)N))rr)rr)rr)�opts�r�rr)r�r�r�r�rvrrar$)r=r�r�pyc1�pyc2rrr�test_only_two_levels�s
�����z+HardlinkDedupTestsBase.test_only_two_levelscCsp|���*|�|���}|jgd�d�t|d�}t|d�}|�t||��Wd�dS1s1wYdS)N)rrrrr�rr)r�r�r�rvrrar$)r=rr�r�rrr�test_duplicated_levelss


"�z-HardlinkDedupTestsBase.test_duplicated_levelscCs�|���d|�d�}|��|�|�t|�}t�|d�j}|�d�}|jddgdd�|�|t�|d�j�|�	t
|d|d��|�|t�|d�j�|�t
j|d|ddd��Wd�dS1skwYdS)	Nrr�print(0)rT)r�rkr��shallow)r�r�rvr�rrrrrsrar$rur�filecmp�cmp�r=rr��inoderrr�test_recompilations



 "�z)HardlinkDedupTestsBase.test_recompilationcCs�|���l|j|��dd�}|��|�|�t|�}t�|d�j}|jddd�}t	j
dddd|jd	�|�|t�|d�j�|�|t�|d
�j�|�
t|d|d
��|�
tj|d|d
dd
��Wd�dS1sswYdS)N�module)r�rr�rez-cz
import moduleF)r�r@rrTr�)r�r�r�rvr�rrrrrrLr/rsrr$r�r�r�rrr�test_import0s

� "�z"HardlinkDedupTestsBase.test_importNr)FF)r$r%r&r?r]r�r�r�rvr�r�r�r�r�r�r�r�r�r�rrrrr��s 


	
		
r�c@r*)�!HardlinkDedupTestsWithSourceEpochNr,rrrrr�Lr-r�c@r*)�HardlinkDedupTestsNoSourceEpochNr,rrrrr�Sr-r��__main__)0rbr]r��importlib.utilrr_rr�rqr7rPr�r,�test.test_importlib.utilr�r\rorr�concurrent.futuresr�concurrent.futures.processrr'�NotImplementedErrorr�test.supportrr�test.test_py_compiler	r
rrr$r%�TestCaser+r0r1r8r�r�r�r�r�r$r�rrrr�<module>s����>����
�

Youez - 2016 - github.com/yon3zu
LinuXploit