Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_compileall.cpython-39.opt-1.pyc

a

��g ��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlmZmZzddlmZdZWney�dZYn0ddlmZddlmZddlmZdd	lmZd
d�Zdd
�Zdd�ZGdd�d�Z Gdd�de ej!edd�Z"Gdd�de ej!edd�Z#Gdd�dej!�Z$Gdd�d�Z%Gdd�de%ej!edd�Z&Gdd�de%ej!edd�Z'Gdd �d �Z(Gd!d"�d"e(ej!edd�Z)Gd#d$�d$e(ej!edd�Z*e+d%k�r�e�,�dS)&�N)�mock�
skipUnless)�ProcessPoolExecutorTF)�support)�
script_helper)�without_source_date_epoch)�SourceDateEpochTestMetacCs|sd}tjj||d�S)N���optimization)�	importlib�util�cache_from_source)�script�opt�r�0/usr/local/lib/python3.9/test/test_compileall.py�get_pycsrcs�fdd�dD�S)Ncsg|]}t�|��qSr)r)�.0r�rrr�
<listcomp>&�zget_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)Z	filename1�	filename2Zinode1Zinode2rrr�is_hardlink)sr c@sheZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Ze�d#�d$d%��Zd&d'�Ze�d#�d(d)��Ze�d#�e�d*�d+d,���Zejd#d-d.�e�d*�d/d0���Zd1d2�Zd3d4�d5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%e&j'dIdJ��Z(d-S)K�CompileallTestsBasecCs�t��|_tj�|jd�|_tj�	|j�|_
t|jd��}|�d�Wd�n1sX0Ytj�|jd�|_
tj�	|j
�|_t�|j|j
�tj�|jd�|_t�|j�tj�|jd�|_t�|j|j�dS)N�_test.py�wzx = 123
z	_test2.pyZ_subdirz	_test3.py)�tempfile�mkdtemp�	directoryr�path�join�source_pathrr
r�bc_path�open�write�source_path2�bc_path2�shutil�copyfileZsubdirectory�mkdir�source_path3��self�filerrr�setUp2s
(zCompileallTestsBase.setUpcCst�|j�dS�N�r/�rmtreer&�r4rrr�tearDown@szCompileallTestsBase.tearDowncCsLtj�|jd�|_t|jd��}|�d�Wd�n1s>0YdS)Nz_test_bad.pyr#zx (
)rr'r(r&�bad_source_pathr+r,r3rrr�add_bad_source_fileCsz'CompileallTestsBase.add_bad_source_filecCsht|jd��}|�d�}Wd�n1s,0Ytt�|j�j�}t�	dt
jjd|d@�}||fS)N�rb��<4sLLr���)
r+r*�read�intrrr)�st_mtime�struct�packrr
�MAGIC_NUMBER)r4r5�data�mtimeZcomparerrr�timestamp_metadataHs(�z&CompileallTestsBase.timestamp_metadatac	Csxzt�|jd�Wn ttfy2|�d�Yn0t�t�	���"|�
t�|j��Wd�n1sj0YdS)N)rArAz0filesystem doesn't support timestamps near 2**32�
r�utimer)�
OverflowError�OSErrorZskipTest�
contextlib�redirect_stdout�io�StringIO�
assertTrue�
compileall�compile_filer:rrr� test_year_2038_mtime_compilationPsz4CompileallTestsBase.test_year_2038_mtime_compilationc	Csxzt�|jd�Wn ttfy2|�d�Yn0t�t�	���"|�
t�|j��Wd�n1sj0YdS)N)� rWz+filesystem doesn't support large timestampsrKr:rrr�test_larger_than_32_bit_timesZsz1CompileallTestsBase.test_larger_than_32_bit_timescCs�tj�d�rt�d��t�|j�|j|�	��t
|jd��$}|��t
|�d�}Wd�n1sf0Yt
|jd��$}|�|�|�|�Wd�n1s�0Y|j|�	��tj|jddd�|j|�	��dS)	zOCheck that compileall recreates bytecode when the new metadata is
        used.�SOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setr>N�wbFT��force�quiet)r�environ�get�unittestZSkipTest�
py_compile�compiler)�assertEqualrJr+r*rB�lenr,�assertNotEqualrT�compile_dirr&rS)r4�metadatar5�bcrrr�recreation_checkds
2
(z$CompileallTestsBase.recreation_checkcCs|�t�dtjjdd��dS)Nr@rr)rirErFrr
rGr:rrr�
test_mtimets�zCompileallTestsBase.test_mtimecCs|�d�dS)Ns)rir:rrr�test_magic_numberysz%CompileallTestsBase.test_magic_numbercCs|j|jfD] }zt�|�WqYq0q|�tj|jddd��|�tj�	|j�oftj�	|j��t�|j�|�tj
|jddd��|�tj�	|j�o�tj�	|j��t�|j�t�|j�|��|�
tj|jddd��|�
tj
|jddd��dS)NFTr[r)r*r.r�unlinkrSrTrUr)r'�isfilerfr&r=�assertFalser<)r4�fnrrr�test_compile_files}s6������z&CompileallTestsBase.test_compile_filescCs||�tj�|j��t���(}|�t�	t
�|j���Wd�n1sJ0Y|�
|��d�|�tj�|j��dS)Nz&Compiling ([^WindowsPath|PosixPath].*))rnrr'rmr*r�captured_stdoutrSrTrU�pathlib�Pathr)�assertRegex�getvalue)r4�stdoutrrr�test_compile_file_pathlike�s

6z.CompileallTestsBase.test_compile_file_pathlikecCsP|�tj�|j��|�tjt�	|j
�t�	d�dd��|�tj�|j��dS)NZ	ddir_pathr)�ddirr])rnrr'rmr*rSrTrUrrrsr)r:rrr�test_compile_file_pathlike_ddir�s�z3CompileallTestsBase.test_compile_file_pathlike_ddircCs�tjjj|jgd��"|�tjdd��Wd�n1s<0Ytjjj|jgd��.|��|�	tjdddd��Wd�n1s�0YdS)N�r'r�r]FT)�skip_curdirr\r])
�test�test_importlibr
Zimport_stater&rSrT�compile_pathr=rnr:rrr�test_compile_path�s0
�z%CompileallTestsBase.test_compile_pathcCs|tj�|jd�}tj�|d�}t�|�t|d��Wd�n1sH0Yt�|�|�tj�	tj�|d���dS)NrHr5r#�__pycache__)
rr'r(r&r1r+rTrUrn�exists)r4Zdata_dirZ	data_filerrr�test_no_pycache_in_non_package�s

z2CompileallTestsBase.test_no_pycache_in_non_packagecCsL|��t�t����"|�t�|j��Wd�n1s>0YdSr7)	r=rOrPrQrRrnrTrUr<r:rrr�#test_compile_file_encoding_fallback�sz7CompileallTestsBase.test_compile_file_encoding_fallbackcCs�drdnd\}}tj|jd|d�tjj|j|d�}|�tj	�
|��tjj|j|d�}|�tj	�
|��tjj|j|d�}|�tj	�
|��dS)NF)rr)rr	T�r]�optimizer
)
rTrfr&rr
rr)rSrr'rmr-r2)r4r�r�cachedZcached2Zcached3rrr�
test_optimize�s
�
�
�z!CompileallTestsBase.test_optimizecCs�|�tj�|j��t���"}t�t	�
|j��Wd�n1sD0Y|���
�d}|�|d�|�tj�|j��dS)Nrz$Listing ([^WindowsPath|PosixPath].*))rnrr'rmr*rrqrTrfrrrsr&ru�
splitlinesrtrS)r4rv�linerrr�test_compile_dir_pathlike�s
0z-CompileallTestsBase.test_compile_dir_pathlikez&concurrent.futures.ProcessPoolExecutorcCs"tj|jddd�|�|j�dS�NT��r]�workers�rTrfr&rS�called�r4�	pool_mockrrr�test_compile_pool_called�sz,CompileallTestsBase.test_compile_pool_calledcCs@|�td�� tj|jdd�Wd�n1s20YdS)Nz%workers must be greater or equal to 0���)r�)ZassertRaisesRegex�
ValueErrorrTrfr&r:rrr�!test_compile_workers_non_positive�s�z5CompileallTestsBase.test_compile_workers_non_positivecCs,tj|jddd�|�|jddd�dS)NTrr�r�max_workers)rTrfr&rc�	call_argsr�rrr�test_compile_workers_cpu_count�sz2CompileallTestsBase.test_compile_workers_cpu_countzcompileall.compile_filecCs,tj|jdd�|�|j�|�|j�dS)NTr{)rTrfr&rnr�rS)r4�compile_file_mockr�rrr�test_compile_one_worker�sz+CompileallTestsBase.test_compile_one_workerN��newcCs"tj|jddd�|�|j�dSr�r�)r4r�rrr�$test_compile_missing_multiprocessing�sz8CompileallTestsBase.test_compile_missing_multiprocessingcCs�d}|j}td|d�D]>}tj�|d|���}tj�|d�}t�|�t�|j|�qt	j
�|�}tj
|jd|dd�|�tj�|��tj
|jd|d�|�tj�|��dS)N�rZdir_z	script.pyT)r]�	maxlevels)r&�rangerr'r(r1r/r0r)rr
rrTrfrnrmrS)r4�depthr'�i�sourceZpyc_filenamerrr�test_compile_dir_maxlevels�s
z.CompileallTestsBase.test_compile_dir_maxlevelsT)�parallelcCsddg}|j}g}|D]>}tj�||�}t�|�t�|dd�|�t�|dd��qtj	|jd||rjdnd	d
�|�
|�|D]�}|�
|�|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)r]rxr�N�")r&rr'r(r1r�make_script�appendrTrfrS�
startswithrr
rrd�sep�assert_python_failurer}r~Zget_code_from_pycrc�co_filename�assertIn�fsdecode)r4rxr��fullpathr'ZmodsZsubdirr�Zmodcode�modpath�_�err�expected_inZmod_code_objrrr�_test_ddir_onlys0
�
�
z#CompileallTestsBase._test_ddir_onlycCs|jddd�S)�=Recursive compile_dir ddir= contains package paths; bpo39769.�
<a prefix>F�rxr��r�r:rrr�test_ddir_only_one_workersz-CompileallTestsBase.test_ddir_only_one_workercCs|jddd�S)r�r�Tr�r�r:rrr�test_ddir_multiple_workers#sz.CompileallTestsBase.test_ddir_multiple_workerscCs|jddd�S)�?Recursive compile_dir ddir='' contains package paths; bpo39769.r	Fr�r�r:rrr�test_ddir_empty_only_one_worker'sz3CompileallTestsBase.test_ddir_empty_only_one_workercCs|jddd�S)r�r	Tr�r�r:rrr� test_ddir_empty_multiple_workers+sz4CompileallTestsBase.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)r]�stripdir��encoding�rr'r(r&�makedirsrr�rr
rrTrfr�r��str�sys�getdefaultencoding�assertNotIn)
r4r�r'rrhr��rc�outr�r�rrr�test_strip_only/s"
��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)r]�
prependdirr�)rr'r(r&r�rr�rr
rrTrfr�r�r�r�r�)
r4r�r'rrhr�r�r�r�r�rrr�test_prepend_onlyBs
�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�rr�T)r]r�r�r�r��r4r�r'rrhr�r�r�r�r�r�rrr�test_strip_and_prependQs(
���z*CompileallTestsBase.test_strip_and_prependcCsxgd�}tjj|jg|�R�}t�|�t�|dd�|�t��$t	j
|ddddd�Wd�n1sj0YdS)N)r}r�r�r'rxr}r�Tz/barr�)r]rxr�r�)rr'r(r&r�rr��assertRaisesr�rTrf)r4r�r'rrr�test_strip_prepend_and_ddirfs

�z/CompileallTestsBase.test_strip_prepend_and_ddirc
Cs�t�|jdd�}g}dD]}|�tjj||d��qddgddgddggd�g}|D]Z}tj|d	|d
�|D]@}|�	t
j�||��zt
�
||�Wqlty�Yql0qlqTdS)N�test_optimization�a = 0�r	rrr�r
rrrrTr�)rr�r&r�rr
rrTrUrSrr'rmrl�	Exception)r4rrh�	opt_level�test_combinations�opt_combinationrrr�!test_multiple_optimization_levelsos(��
�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)r]�
limit_sl_dest)rr'r(r&r�rr��symlinkrr
rrTrfrSrmrn�
r4Zallowed_pathZ
symlinks_pathZprohibited_pathZallowed_scriptZprohibited_scriptZallowed_symlinkZprohibited_symlinkZ
allowed_bcZ
prohibited_bcrrr�test_ignore_symlink_destination�s"


z3CompileallTestsBase.test_ignore_symlink_destination))�__name__�
__module__�__qualname__r6r;r=rJrVrXrirjrkrprwryr�r�r�r�r�r�patchr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�skip_unless_symlinkr�rrrrr!0sR

	


	r!c@seZdZdS)�CompileallTestsWithSourceEpochN�r�r�r�rrrrr��sr�)�	metaclassZsource_date_epochc@seZdZdS)�!CompileallTestsWithoutSourceEpochNr�rrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�EncodingTestzTIssue 6716: compileall should escape source code when printing errors
    to stdout.cCsdt��|_tj�|jd�|_t|jddd��$}|�d�|�d�Wd�n1sV0YdS)Nr"r#�utf-8r�z# -*- coding: utf-8 -*-
u
print u"€"
)	r$r%r&rr'r(r)r+r,r3rrrr6�s


zEncodingTest.setUpcCst�|j�dSr7r8r:rrrr;�szEncodingTest.tearDowncCs>z0tj}tjt��dd�t_t�|j�W|t_n|t_0dS)N�asciir�)r�rvrQ�
TextIOWrapper�BytesIOrTrfr&)r4Zorig_stdoutrrr�
test_error�s
zEncodingTest.test_errorN)r�r�r��__doc__r6r;r�rrrrr��sr�c@s�eZdZdZdd�Zejdd��Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
edd��Zdd�ZddgfdddgfdddgffD]&\ZZZeefdd�Zee�d e<q�d!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	Zbar)r$r%r&Z
addCleanupr/r9rr'r(�pkgdirr1�pkgdir_cachedirrr��initfn�barfnr:rrrr6�s
zCommandLineTestsBase.setUpccsBtj}tj�|jd�}z|t_|j|d�VW|t_n|t_0dS)z&Adjust and restore sys.pycache_prefix.Z
__testcache__)�
PYTHONPATHZPYTHONPYCACHEPREFIXN)r��pycache_prefixrr'r(r&)r4Z
old_prefix�
new_prefixrrr�temporary_pycache_prefix�s�
z-CommandLineTestsBase.temporary_pycache_prefixcCsgt���d�d�d�|�S)Nz-S�-mrT)rZ!optim_args_from_interpreter_flags)r4�argsrrr�
_get_run_args�s
����z"CommandLineTestsBase._get_run_argscOs4tj|�|�i|�ddi��\}}}|�d|�|S)N�PYTHONIOENCODINGr�r)r�assert_python_okr	rc�r4rZenv_varsr�r�r�rrr�assertRunOK�s���z CommandLineTestsBase.assertRunOKcOs.tj|�|�i|�ddi��\}}}|||fS)Nr
r�)rr�r	rrrr�assertRunNotOK�s���z#CommandLineTestsBase.assertRunNotOKcCs"tj�|�}|�tj�|��dSr7)rr
rrSrr'r��r4ror'rrr�assertCompiled�sz#CommandLineTestsBase.assertCompiledcCs"tj�|�}|�tj�|��dSr7)rr
rrnrr'r�rrrr�assertNotCompiled�sz&CommandLineTestsBase.assertNotCompiledcCsnt�|jdd�}|���B}|jfi|��|�|�|�|j�|�|j�Wd�n1s`0YdS)N�bazr	)	rr�r&rr
rrrr)r4�bazfn�envrrr�test_no_args_compiles_path�s

z/CommandLineTestsBase.test_no_args_compiles_pathcCs�t�|jdd�}|���,}|jfi|��tj�|�}Wd�n1sJ0Yt�	|t
�
�dfd�t�|�j}|jfi|��t�|�j}|�
||�|jdi|��t�|�j}|�||�dS)Nrr	�<r�-f)r)rr�r&rr
rr
rrrL�timerrDrcre)r4rr�pycpathrI�mtime2rrr� test_no_args_respects_force_flag�s
*z5CommandLineTestsBase.test_no_args_respects_force_flagcCstt�|jdd�|��� }|jfi|��}Wd�n1s>0Y|�d|�|jdi|��}|�d|�dS)Nrr	sListing �-q)r)rr�r&rr
r�r�)r4r�noisyr]rrr� test_no_args_respects_quiet_flags
.z5CommandLineTestsBase.test_no_args_respects_quiet_flagZnormal�pycr�z	opt-1.pyc�-OZdoubleoptimizez	opt-2.pycz-OOcs~tj|ddd|jg�|�tj�|j��t�fdd�dD��}|�	tt�
|j��|�|��fdd�t�
|j�D��dS)	NrrTrc3s|]}|�tjj��VqdSr7)�formatr��implementation�	cache_tag)r�base��extrr�	<genexpr>%s�z)CommandLineTestsBase.f.<locals>.<genexpr>)z__init__.{}.{}z	bar.{}.{}csg|]}|���r|�qSr)�endswith)rror%rrr)s
�z*CommandLineTestsBase.f.<locals>.<listcomp>)rrr�rSrr'r�r�sortedrc�listdirrn)r4r&�switch�expectedrr%r�f s��zCommandLineTestsBase.fZtest_pep3147_paths_cCsL|�dd|j�|�tj�|j��tgd��}|�tt�	|j��|�dS)Nz-br)�__init__.pyz__init__.pyczbar.pyzbar.pyc)
r
r�rnrr'r�rr)rcr*)r4r,rrr�test_legacy_paths-sz&CommandLineTestsBase.test_legacy_pathscCs||�d|j�|�tj�|j��tj�|jd�}|�tj�|��|�d|j�|�tj�|j��|�tj�|��dS)Nrr�)	r
r�rSrr'r�rr(rn)r4Z
cachecachedirrrr�test_multiple_runs7sz'CommandLineTestsBase.test_multiple_runscCs�|�d|j�tj�|j�}t�|t��dfd�t�	|�j
}|�d|j�t�	|�j
}|�||�|�dd|j�t�	|�j
}|�||�dS)Nrrrr)
r
r�rr
rrrrLrrrDrcre)r4rrIrrrr�
test_forceDszCommandLineTestsBase.test_forcecCs�tj�|jd�}t�|�t�|dd�}t�|dd�}|�dd|j�|�|�|�	tj�
tj�|d���|�d|j�|�|�|�|�dS)N�spamr�r	�hamrz-lr�)rr'r(r�r1rr�r
rrnr�r)r4�
subpackage�	subinitfn�hamfnrrr�test_recursion_controlTs


z+CommandLineTestsBase.test_recursion_controlc	CsVtj�|jd�}tj�|d�}tj�|d�}|||fD]}t�|�q6tj�|d�}t�|dd�}t�|dd�}t�|dd�}|�dd|j�|�|�|�	tj�
tj�|d	���|�dd
|j�|�|�|�|�|�|�|�dd|j�|�|�|�|�|�|�|�|�|�dd|j�|�|�|�|�|�|�|�|�dS)
Nr2r3Zeggsr.r	Zeggrz-r 0r�z-r 1z-r 2z-r 5)rr'r(r�r�make_pkgr�r
rrnr�r)	r4r4Zsubpackage2Zsubpackage3�pkgr5r6ZspamfnZeggfnrrr�test_recursion_limit`s8
�









z)CommandLineTestsBase.test_recursion_limitc	Csttj�|jd�}t�|�t�dtj�|d��t�dtj�|d��|�d|j�|�tj�|jdddd��dS)Nr2�.ZevilZevil2rr.)	rr'r(r�rr8r�r
r)r4r9rrr�test_symlink_loop�s

�z&CommandLineTestsBase.test_symlink_loopcCs6|�|j�}|�d|j�}|�d|�|�d|�dS)Nrr)r
r�rerc)r4rr]rrr�
test_quiet�szCommandLineTestsBase.test_quietcCsTt�|jdd�|�d|j�\}}}|�d|j�\}}}|�d|�|�d|�dS)N�crunchyfrog�
bad(syntaxrz-qqr)rr�r�rrerc)r4r�r]Zsilentrrr�test_silent�s
z CommandLineTestsBase.test_silentcCs.|�ddd|j�|�|j�|�|j�dS)Nrz-xz
ba[^\\/]*$)r
r�rrrrr:rrr�test_regexp�sz CommandLineTestsBase.test_regexpcCsvtj�|jd�}t�|�t�|dd�}t�|dd�}|�d|j|�|�	|j
�|�	|j�|�	|�|�	|�dS)NZfoo2r�r	�bar2r)rr'r(r&r1rr�r
r�rrr)r4Zpkgdir2Zinit2fn�bar2fnrrr�test_multiple_dirs�s

z'CommandLineTestsBase.test_multiple_dirscCs8t�|jdd�|�ddd|j�\}}}|�|d�dS)Nr>r?r�-d�dinsdale�File "dinsdale)rr�r�rrt�r4r�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)Nrzraise ExceptionrrErF�bingz
import bazzbaz.pycF)�
__isolatedrG)rr�r�r
rr
rr�renamer'r(�remover�rt)r4rrorr�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)rrr'r(r&r�rtZassertNotRegexrnr�rr
rrrHrrr�test_include_bad_file�s�
�z*CommandLineTestsBase.test_include_bad_filecCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}ttj�|jd�d��H}|�tj�|jd�tj	�|�tj�|jd	�tj	�Wd�n1s�0Y|�
d
tj�|jd�|�|�|�|�|�|�|�|�|�dS)N�f1r	�f2�f3�f4�l1r#�f1.py�f2.pyrO)
rr�r�r+rr'r(r&r,�linesepr
rr�r4rRrSrTrUrVrrr�test_include_file_with_arg�s:


z/CommandLineTestsBase.test_include_file_with_argcCs�t�|jdd�}t�|jdd�}t�|jdd�}t�|jdd�}ttj�|jd�d��,}|�tj�|jd�tj	�Wd�n1s�0Y|�
d	tj�|jd��|�|�|�|�|�|�|�|�dS)
NrRr	rSrTrUrVr#rXrO)
rr�r�r+rr'r(r&r,rYr
rrrZrrr�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)
NrRr	rSrTrUrrO�-r�)
rr�r�Zspawn_pythonr	�stdinr,rrY�encodeZkill_pythonrr)r4rRrSrTrU�prrr�test_include_on_stdin�s



z*CommandLineTestsBase.test_include_on_stdincCs\t�|jdd�}|�d|j||j�\}}}|�|d�|�|�|�|j�|�|j�dS)NrJzsyntax(errorrPsrror)	rr�r�rrrrtrr)r4Zbingfnr�r�r�rrr�!test_compiles_as_much_as_possible�s
�

z6CommandLineTestsBase.test_compiles_as_much_as_possiblecCs|�d�}|�|d�dS)NZbadfilenamesCan't list 'badfilename')r
rt)r4r�rrr�!test_invalid_arg_produces_message�s
z6CommandLineTestsBase.test_invalid_arg_produces_messagecCs�t�|jdd�tj�tj�|jd��}|�	d|j�t
|d��}|��}Wd�n1s^0Y|�t
�|dd�d�d	�|�	d
|j�t
|d��}|��}Wd�n1s�0Y|�t
�|dd�d�d�dS)NrRr	rWz --invalidation-mode=checked-hashr>���littler�z"--invalidation-mode=unchecked-hashr)rr�r�rr
rrr'r(r
r+rBrcrC�
from_bytes)r4r�fprHrrr�test_pyc_invalidation_mode�s�&&z/CommandLineTestsBase.test_pyc_invalidation_modezrequires multiprocessingcCs�t�|jdd�}g}td�D]F}tj�|jd�|��}t�|�t�|dd�}|�	t�|dd��q|�
|jdd�|�|�|D]}|�|�q�dS)NrBr	r�zfoo{}r�z-j�0)rr�r&r�rr'r(r!r1r�r
r)r4rC�files�suffixr�ror5rrr�test_workerss

z!CommandLineTestsBase.test_workerszcompileall.compile_dircCsftjdtj|jdgd��:t��|�|j�|�	|j
ddd�Wd�n1sX0YdS)Nzsys.argvz-j0r�r�r�r)rr�r��
executabler&rT�mainrSr�rcr�)r4rfrrr�test_workers_available_coress�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�rr�z-sz-pr�)rr'r(r&r�rr�rr
rr
r�r�r�r�r�r�r�rrrr�s$
��z+CommandLineTestsBase.test_strip_and_prependc
Cs�tj�|jd�}t�|�t�|dd�}g}dD]}|�tj	j
||d��q0ddgddgddggd	�g}|D]j}|j|gd
d�|D��R�|D]D}|�tj�
|t|���zt�||�Wq�ty�Yq�0q�qldS)NZ
optimizationsr�r�r�r
rj�1�2)rjrqrrcss|]}dt|�VqdS)z-oN)r�)r�nrrrr'@rzICommandLineTestsBase.test_multiple_optimization_levels.<locals>.<genexpr>)rr'r(r&r�rr�r�rr
rr
rSrmrCrlr�)r4r'rrhr�r�r�rrrr�1s0
��
�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}r�r�r�r�r�r�r�r�r�z-e)rr'r(r&r�rr�r�rr
rr
rSrmrnr�rrrr�Hs"


z4CommandLineTestsBase.test_ignore_symlink_destinationcCs|�|jdd�dS)N�-o 1�--hardlink-dupes)rr&r:rrr�test_hardlink_bad_argsasz+CommandLineTestsBase.test_hardlink_bad_argsc
Cs�dD]�}t����}|j|d���t�|dd�}t|�}gd�}|rL|�d�|j|g|�R�|�t	|d|d�|�|�t	|d|d	�|�|�t	|d|d	�|�Wd�n1s�0YWd�q1s�0YqdS)
N)TF��deduprr�)rz-o 0rtz-o 2rurrr)
r$�TemporaryDirectory�subTestrr�rr�r
rcr )r4rxr'r�pycsrrrr�
test_hardlinkfs

z"CommandLineTestsBase.test_hardlinkN)6r�r�r�r�r6rO�contextmanagerrr	r
rrrrrrr�namer&r+r-�localsr/r0r1r7r:rr�r<r=r@rArDrIrNrQr[r\rarbrcrir�_have_multiprocessingrmrr�rpr�r�r�rvr|rrrrr��sd


	


�


"




	



r�c@seZdZdS)�CommandLineTestsWithSourceEpochNr�rrrrr�|sr�c@seZdZdS)�CommandLineTestsNoSourceEpochNr�rrrrr��sr�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|_dSr7rzr:rrrr6�szHardlinkDedupTestsBase.setUpccs>t���"}||_|Vd|_Wd�n1s00YdSr7)r$ryr')r4r'rrr�temporary_directory�s
z*HardlinkDedupTestsBase.temporary_directoryrcCst�|j||�Sr7)rr�r')r4�coder~rrrr��sz"HardlinkDedupTestsBase.make_scriptTrF)rxr�r\cCstj|jd|||d�dS)NT)r]r��hardlink_dupesr\)rTrfr')r4rxr�r\rrrrf�s�z"HardlinkDedupTestsBase.compile_dirc	Cs�|����|�d�|�t��$tj|jdddd�Wd�n1sH0Y|�t��(tj|jdddgdd�Wd�n1s�0YWd�n1s�0YdS)N�passTr)r]r�r�)r�r�r�r�rTrfr'r:rrr�
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�r()r4�	docstring�	assertion�linesrrr�create_code�s


z"HardlinkDedupTestsBase.create_codeccs2dD](}dD]}|j||d�}|||fVqqdS)N)FT�r�r�)r�)r4r�r�r�rrr�
iter_codes�sz!HardlinkDedupTestsBase.iter_codesc
Cs�|��D]�\}}}|j||d���|���v|�|�}t|�}|jdd�|�t|d|d��|�t|d|d��|�t|d|d��Wd�n1s�0YWd�q1s�0YqdS)Nr�Frwrrr)r�rzr�r�rrfrnr )r4r�r�r�rr{rrr�
test_disabled�s

z$HardlinkDedupTestsBase.test_disabledcCsft|�}|�t|d|d�|�|�t|d|d�|oB|�|�t|d|d�|�dS)Nrrr)rrcr )r4rr�r�r{rrr�check_hardlinks�s�
��z&HardlinkDedupTestsBase.check_hardlinksc
Cs�|��D]�\}}}|j||d��X|���0|�|�}|��|�|||�Wd�n1s`0YWd�q1s~0YqdS)Nr�)r�rzr�r�rfr�)r4r�r�r�rrrrr|�s

z$HardlinkDedupTestsBase.test_hardlinkc
Cs�dD]�}|j|d��~|���V|�|���}|j|d�t||d�}t||d�}|�t||��Wd�n1sz0YWd�q1s�0YqdS)N))rr)rr)rr)�opts�r�rr)rzr�r�r�rfrrSr )r4r�r�pyc1�pyc2rrr�test_only_two_levels�s
z+HardlinkDedupTestsBase.test_only_two_levelscCsn|���R|�|���}|jgd�d�t|d�}t|d�}|�t||��Wd�n1s`0YdS)N)rrrrr�rr)r�r�r�rfrrSr )r4rr�r�rrr�test_duplicated_levels�s


z-HardlinkDedupTestsBase.test_duplicated_levelscCs�|����|�d�}|��|�|�t|�}t�|d�j}|�d�}|jddgdd�|�|t�|d�j�|�	t
|d|d��|�|t�|d�j�|�t
j|d|ddd��Wd�n1s�0YdS)	Nr�r�print(0)rT)r�r\r��shallow)r�r�rfr�rrrrrcrSr rern�filecmp�cmp�r4rr{�inoderrr�test_recompilation�s



z)HardlinkDedupTestsBase.test_recompilationcCs�|����|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�n1s�0YdS)N�module)r~rr�r z-cz
import moduleF)rKrrrTr�)r�r�r�rfr�rrrrrrr'rcrnr r�r�r�rrr�test_imports

�z"HardlinkDedupTestsBase.test_importN)r)FF)FF)r�r�r�r6rOr}r�r�rfr�r�r�r�r�r|r�r�r�r�rrrrr��s


	
		
r�c@seZdZdS)�!HardlinkDedupTestsWithSourceEpochNr�rrrrr�(sr�c@seZdZdS)�HardlinkDedupTestsNoSourceEpochNr�rrrrr�/sr��__main__)-rTrOr��importlib.utilrrQrrrrar/rEr�r$Ztest.test_importlib.utilr}rr`rr�concurrent.futuresrr��ImportErrorrZtest.supportrZtest.test_py_compilerrrrr r!ZTestCaser�r�r�r�r�r�r�r�r�r�rorrrr�<module>s�
n��>����


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists