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_embed.cpython-39.opt-2.pyc

a

��g���@sddlmZddlZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ejdkZejdkZdZdZdZdZdZdZd	Zd
d�Zdd
�ZGdd�d�ZGdd�deej�ZGdd�deej�ZGdd�deej�Ze dk�re�!�dS)�)�supportN)�
namedtuple�nt�darwin����cCs.tj�|�}tj�|�d}|���d���S)Nr�_d)�os�path�basename�splitext�casefold�endswith)Zprogram�name�r�+/usr/local/lib/python3.9/test/test_embed.py�debug_build"srcCs,ttj�}t|�D]}|�d�r||=q|S)NZPYTHON)�dictr�environ�list�
startswith)�env�keyrrr�remove_python_envvars(s


rc@s:eZdZdd�Zdd�Zdddddd�dd	�Zd
d�ZdS)�EmbeddingTestsMixincCs�tj�t�}tj�tj�tj�|���}d}tr^ttj�r>dndd}||7}tj�tj�}ntj�	|d�}tj�	||�|_
}tj�|�s�|�d|�t�
�|_t�|�dS)N�
_testembedr
�z.exeZProgramsz%r doesn't exist)rr�abspath�__file__�dirname�
MS_WINDOWSr�sys�
executable�join�test_exe�existsZskipTest�getcwd�oldcwd�chdir)�self�hereZbasepathZexename�extZexepathZexerrr�setUp2s
zEmbeddingTestsMixin.setUpcCst�|j�dS�N)rr*r)�r+rrr�tearDownEszEmbeddingTestsMixin.tearDownNr)r�timeout�
returncode�input�cwdcGs�|jg}|�|�|dur4tr4|��}tjd|d<tj|tjtjd||d�}z|j	||d�\}	}
Wn|�
�|���Yn0|j|kr�t
jr�td|�d��td|	���td|
���td	�|�|j|d
|j|
f�|	|
fS)NZ
SYSTEMROOTT)�stdout�stderr�universal_newlinesrr5)r4r2z--- z failed ---zstdout:
zstderr:
z------zbad returncode %d, stderr is %r)r&�extendr"�copyrr�
subprocess�Popen�PIPE�communicate�	terminate�waitr3r�verbose�print�assertEqual)r+rr2r3r4r5�args�cmd�p�out�errrrr�run_embedded_interpreterHs:
�
��z,EmbeddingTestsMixin.run_embedded_interpreterccs"|�d�\}}|�|d�d}tdd�}d}g}|��D]�}|d�|�krv|�t|�d�tjdkrlt|�|d7}q8|�	t|�d	�t
�||�}|dur�|�||�||�
��}	tjdkr�t|	�|�|	j�|�|	j�|�|	j�|�|	�t|�d	kr8|d}
|�|	|
�|Vg}q8dS)
NZ&test_repeated_init_and_subinterpretersrzS^interp (\d+) <(0x[\dA-F]+)>, thread state <(0x[\dA-F]+)>: id\(modules\) = ([\d]+)$�Interpzid interp tstate modulesrz--- Pass {} ---r�)rIrCr�
splitlines�format�lenrrArBZ
assertLess�re�matchZassertRegex�groupsZ
assertTrue�interp�tstate�modules�append)r+rGrHZ
interp_patrJZnumloopsZcurrent_run�linerPrR�mainrrr�%run_repeated_init_and_subinterpretersks:



z9EmbeddingTestsMixin.run_repeated_init_and_subinterpreters)�__name__�
__module__�__qualname__r.r1rIrXrrrrr1s�#rc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�EmbeddingTestsi�cCs(|��D]}|d}|�|jd�qdS)Nr�0)rXrC�id)r+�runrWrrr�test_subinterps_main�sz#EmbeddingTests.test_subinterps_maincCsT|��D]F}|�^}}}t|j�}t|�D]"\}}|�|jt||d��q*qdS)Nr)rX�intr^�	enumeraterC�str)r+r_rW�subs�_Zmainid�i�subrrr�test_subinterps_different_ids�s

z,EmbeddingTests.test_subinterps_different_idscCsj|��D]\}|�^}}}d|vr*t�d��|D]4}|�|j|j�|�|j|j�|�|j|j�q.qdS)NZ0x0zplatform prints pointers as 0x0)rX�unittestZSkipTestZassertNotEqualrRrSrT)r+r_rWrdrergrrr�test_subinterps_distinct_state�s
z-EmbeddingTests.test_subinterps_distinct_statecCsP|�d�\}}|�|d�dd�tdtd�D�}d�|�d}|�||�dS)N�test_repeated_init_and_inittabrcSsg|]}d|�d��qS)z	--- Pass z ---r)�.0rfrrr�
<listcomp>��zAEmbeddingTests.test_repeated_init_and_inittab.<locals>.<listcomp>r�
)rIrC�range�
INIT_LOOPSr%)r+rGrH�linesrrrrk�s
z-EmbeddingTests.test_repeated_init_and_inittabcCs�ttjdd�}|jd|d�\}}tjdkr@t�t|�t|�d}d}d�gd	��}|j|||d
�}d|_	|�
|��|�dS)Nzutf-8:surrogateescape)ZPYTHONIOENCODING�test_forced_io_encoding�rr�utf-8�surrogateescapero)z--- Use defaults ---�Expected encoding: default�Expected errors: defaultzstdin: {in_encoding}:{errors}zstdout: {out_encoding}:{errors}�'stderr: {out_encoding}:backslashreplacez--- Set errors only ---rwzExpected errors: ignorezstdin: {in_encoding}:ignorezstdout: {out_encoding}:ignoreryz--- Set encoding only ---�Expected encoding: iso8859-1rxzstdin: iso8859-1:{errors}zstdout: iso8859-1:{errors}�"stderr: iso8859-1:backslashreplacez--- Set encoding and errors ---rzzExpected errors: replacezstdin: iso8859-1:replacezstdout: iso8859-1:replacer{)Zin_encodingZout_encoding�errors)rrrrIrrArBr%rM�maxDiffrC�strip)r+rrGrHZexpected_stream_encodingZexpected_errors�expected_outputrrrrs�s 
�z&EmbeddingTests.test_forced_io_encodingcCspttjtj�tj�d�}|jd|d�\}}tr6|j	}ntj�t�
�d�}d|�d�}|�||�|�|d�dS)N)�
PYTHONPATH�test_pre_initialization_apirtZspamzsys.executable: ror)
rrr�pathsepr%r#rrIr"r&r(�assertInrC)r+rrGrHZ
expected_pathrrrrr��sz*EmbeddingTests.test_pre_initialization_apicCsJt�}tj�tj�|d<|jd|d�\}}d}|�||�|�|d�dS)Nr��#test_pre_initialization_sys_optionsrtz�sys.warnoptions: ['once', 'module', 'default']
sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}
warnings.filters[:3]: ['default', 'module', 'once']
r)	rrr�r%r#rrIr�rC)r+rrGrHrrrrr�s�
�z2EmbeddingTests.test_pre_initialization_sys_optionscCs*|�d�\}}|�|d�|�|d�dS)N�
test_bpo20891r�rIrC�r+rGrHrrrr�szEmbeddingTests.test_bpo20891cCs*|�d�\}}|�|d�|�|d�dS)N�test_initialize_twicerr�r�rrrr�!sz$EmbeddingTests.test_initialize_twicecCs.|�d�\}}|�|��d�|�|d�dS)N�test_initialize_pymainz6Py_Main() after Py_Initialize: sys.argv=['-c', 'arg2']r�rIrC�rstripr�rrrr�*sz%EmbeddingTests.test_initialize_pymaincCs.|�d�\}}|�|��d�|�|d�dS)N�
test_run_mainz%Py_RunMain(): sys.argv=['-c', 'arg2']rr�r�rrrr�2szEmbeddingTests.test_run_maincCs2d}|�d�\}}|�|d|�|�|d�dS)NrK�test_run_main_loopz&Py_RunMain(): sys.argv=['-c', 'arg2']
rr�)r+ZnlooprGrHrrrr�7sz!EmbeddingTests.test_run_main_loopN)rYrZr[r}r`rhrjrkrsr�r�r�r�r�r�r�rrrrr\�s+		r\c9@s"eZdZdZerdndZe�Ze�Ze	e
dddddd�ZerJe�ddi�e
eedeed�Ze
eeddddddd	�Zgd
�Ze	dddddddddddddeededdggggddeeeeeeeejddddddddddddeedddddd
dddd�8Ze�r
e�ddi�e
eeddd�Ze
eedddddddddd�Ze�rFded<dddd�ZdgZgd�Ze�rze�d�e�d�dZedd��Zdd�Zdd�Z dd�Z!dxdd �Z"d!d"�Z#d#d$�Z$d%d&�Z%dyddd'dd(�d)d*�Z&d+d,�Z'd-d.�Z(d/d0�Z)d1d2�Z*d3d4�Z+d5d6�Z,d7d8�Z-d9d:�Z.d;d<�Z/d=d>�Z0d?d@�Z1dAdB�Z2dCdD�Z3dEdF�Z4dGdH�Z5dIdJ�Z6dKdL�Z7dMdN�Z8dOdP�Z9dQdR�Z:dSdT�Z;dUdV�Z<dWdX�Z=dYdZ�Z>d[d\�Z?d]d^�Z@d_d`�ZAdadb�ZBdcdd�ZCdzdedf�ZDeEjFdgdh��ZGdidj�ZHdkdl�ZIeJ�Kedm�dndo��ZLdpdq�ZMdrds�ZNdtdu�ZOdvdw�ZPdS){�InitConfigTestsi�
surrogatepassrvrr)�_config_init�	allocator�
parse_argv�configure_locale�coerce_c_localeZcoerce_c_locale_warn�	utf8_mode�legacy_windows_fs_encoding)r�r�r�r�)r�r��isolated�use_environmentr��dev_moder�)r�r�r�Nr�default)8r�r�r�r��_use_peg_parser�install_signal_handlers�
use_hash_seed�	hash_seed�faulthandler�tracemalloc�import_time�show_ref_countZ	dump_refs�malloc_stats�filesystem_encoding�filesystem_errors�pycache_prefix�program_namer��argv�
_orig_argv�xoptions�warnoptions�pythonpath_env�homer$�base_executable�prefix�base_prefix�exec_prefix�base_exec_prefix�module_search_paths�
platlibdir�site_import�
bytes_warning�inspect�interactive�optimization_level�parser_debug�write_bytecoderA�quiet�user_site_directory�configure_c_stdio�buffered_stdio�stdio_encoding�stdio_errorsZskip_source_first_line�run_commandZ
run_module�run_filenameZ_install_importlib�check_hash_pycs_mode�pathconfig_warnings�
_init_main�_isolated_interpreter�legacy_windows_stdio)r�r�r�)
r�r�r�r�r�r�r�r�r�r�)ZPy_HasFileSystemDefaultEncodingZPy_HashRandomizationFlagZ$_Py_HasFileSystemDefaultEncodeErrors)ZPy_UTF8Moder�))ZPy_BytesWarningFlagr�)ZPy_DebugFlagr�)ZPy_DontWriteBytecodeFlagr�T)Z Py_FileSystemDefaultEncodeErrorsr�)ZPy_FileSystemDefaultEncodingr�)Z
Py_FrozenFlagr�T)ZPy_IgnoreEnvironmentFlagr�T)ZPy_InspectFlagr�)ZPy_InteractiveFlagr�)ZPy_IsolatedFlagr�)Z
Py_NoSiteFlagr�T)ZPy_NoUserSiteDirectoryr�T)ZPy_OptimizeFlagr�)ZPy_QuietFlagr�)ZPy_UnbufferedStdioFlagr�T)ZPy_VerboseFlagrA))ZPy_LegacyWindowsFSEncodingFlagr�))ZPy_LegacyWindowsStdioFlagr�cCs
d|_dSr/)�EXPECTED_CONFIG)�clsrrr�
tearDownClass�szInitConfigTests.tearDownClasscCs<i}|D].}d|vr.|�dd�\}}|||<qd||<q|S)N�=rT)�split)r+Z
xoptions_listr��optr�valuerrr�
main_xoptions�s

zInitConfigTests.main_xoptionscCs�t�}t�d�}tjdd|g}tj||tjtjd�}|jrRt	d|j
�d|j����|j
�d�}zt
�|�WSt
jy�|�d|���Yn0dS)	Na4
            import json
            import sys
            import _testinternalcapi

            configs = _testinternalcapi.get_configs()

            data = json.dumps(configs)
            data = data.encode('utf-8')
            sys.stdout.buffer.write(data)
            sys.stdout.buffer.flush()
        z-S�-c)rr6r7z)failed to get the default config: stdout=z stderr=ru�fail to decode stdout: )r�textwrap�dedentr#r$r;r_r=r3�	Exceptionr6r7�decode�json�loads�JSONDecodeError�fail)r+r�coderD�procr6rrr�_get_expected_config_impls$
���z)InitConfigTests._get_expected_config_implcCslt}|jdur|��|_i}|j��D]@\}}i}|��D]"\}}t|t�rT|��}|||<q:|||<q&|Sr/)r�r�r��items�
isinstancerr:)r+r��configsZ
config_keyZconfig_value�configrr�rrr�_get_expected_configs




z$InitConfigTests._get_expected_configcCs(|j}|��}|d}|��D]\}	}
|
|jur||	||	<q|drN|tkrbdD]}	|j||	<qR|dst|j|d<|ddkr�|d|jur�d|d<|d|jur�|j|d<|d	|jur�d|d	<|d
|jur�d|d
<tr�|j}n4|d|ju�rt	j
�|d�}nt	j
�t	�
�d
�}|d|ju�r2||d<|d|ju�rJ||d<|d|ju�rbd|d<|d}|��D]"\}	}
|
|ju�rr||	||	<�qr|d|ju�r|d}
|
du�r�|
�t	j
j�}g|�|d�|d<|du�r|d��|d<||d�|jD]}	|	|v�r||	||	<�qdS)N�
pre_configr�)r�r�r�r�r�rr�rur�r�r�rvr�rr$r�z./_testembedr�r�r�)�	__class__r�r��GET_DEFAULT_CONFIG�
API_COMPAT�
IGNORE_CONFIG�UTF8_MODE_ERRORSr"r&rrrr%r(r�r�r:�COPY_PRE_CONFIG)r+�expected_preconfig�expectedr�api�modify_path_cbr�r�r�rr�Zdefault_executabler�r��pathsrrr�get_expected_config/s\






z#InitConfigTests.get_expected_configcCsNt|d�}t|���D]$\}}||jur|�|d�||=q|�||�dS)Nr��rrr�r��poprC)r+r�r�r�rr�rrr�check_pre_configos
z InitConfigTests.check_pre_configcCsNt|d�}t|���D]$\}}||jur|�|d�||=q|�||�dS)Nr�r�)r+r�r�r�rr�rrr�check_configws
zInitConfigTests.check_configc	Cs�|d}|d}t|j�}|jD]D}t|�dkrP|\}}}||rFdnd||<q |\}}||||<q |jD]D}t|�dkr�|\}}}||r�dnd||<ql|\}}||||<ql|�|d|�dS)Nr�r�rrrZ
global_config)r�DEFAULT_GLOBAL_CONFIG�COPY_GLOBAL_CONFIGrN�COPY_GLOBAL_PRE_CONFIGrC)	r+r�r�r�r��itemZ
global_keyZcore_keyZoppositerrr�check_global_configs 




z#InitConfigTests.check_global_configF)�
preconfig_apir�
ignore_stderrr5cCsbt�}|dur|�|�|}|dur(|}|tkr8|j}n|tkrH|j}n|j}|durZi}t|fi|��}|durvi}|tkr�|j}
n|tkr�|j	}
n|j
}
t|
fi|��}|�|||||�|j|||
d�\}}|dur�|ds�d}|du�r|	�s|�
|��|�zt�|�}Wn&tj�y:|�d|���Yn0|�||�|�||�|�|�|S)N)rr5rArr�)r�update�API_ISOLATED�PRE_CONFIG_ISOLATED�
API_PYTHON�PRE_CONFIG_PYTHON�PRE_CONFIG_COMPATr�
CONFIG_PYTHON�CONFIG_ISOLATED�
CONFIG_COMPATr�rIrCr�r�r�r�r�r�r�r�)r+ZtestnameZexpected_configr�r�r7r�r�rr�r5Znew_envZdefault_preconfigZdefault_configrGrHr�rrr�check_all_configs�sR
��

z!InitConfigTests.check_all_configscCs|jdtd�dS)NZtest_init_initialize_config�r��rr�r0rrr�test_init_default_config�sz(InitConfigTests.test_init_default_configcCs|jdtd�dS)N�test_preinit_compat_configrrr0rrrr�sz*InitConfigTests.test_preinit_compat_configcCs|jdtd�dS)N�test_init_compat_configrrr0rrrr	�sz'InitConfigTests.test_init_compat_configcCs@ddi}ddddgdddddddddd�
}|jd||td	�dS)
Nr�rz./globalvarr�default::BytesWarningr)
r�r�r�r�r�r�r�r�rAr�r�r�r��test_init_global_configrr�r+�	preconfigr�rrrr�s&��
�z'InitConfigTests.test_init_global_configc$Cs~tdd�}dddddddddddd	d
dggd�dgd
�gd�dddddddddddddd|jdddd�#}|jd||td�dS)Nr�r�r�r�{r�	iso8859-1�replaceZconf_pycache_prefixz./conf_program_namer��arg2)�python3�-W�cmdline_warnoption�-X�cmdline_xoptionr��passr)zconfig_xoption1=3zconfig_xoption2=Zconfig_xoption3r)rr
Zconfig_warnoption�pass
Z
my_platlibdir�always)#r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rAr�r�r�r�r�r�r�r�r�r��test_init_from_configr��PYMEM_ALLOCATOR_MALLOCr�rr�rrrrr�sT��7
�z%InitConfigTests.test_init_from_configcCsPdti}dddddddddddddd	ddd
gd|jdd�}|jd
||td�dS)Nr�r�*r�/my/path�env_pycache_prefixrrr�EnvVar�env_platlibdir�r�r�r�r�r�r�r�r�r�r�rAr�r�r�r�r�r�r�r�r��test_init_compat_envrrrrrrr$'s4��
�z$InitConfigTests.test_init_compat_envcCsRtdd�}dddddddddddddd	ddd
gd|jdd�}|jd
||td�dS)Nrrrrrr rrrr!r"r#�test_init_python_envr)rr�rr�rrrrr%Ds6��
�z$InitConfigTests.test_init_python_envcCs0ttd�}tdddgd�}|jd||td�dS)N�r�rr��r�r�r��test_init_env_dev_moder)r�PYMEM_ALLOCATOR_DEBUGrr�rrrrr(bs
�
�z&InitConfigTests.test_init_env_dev_modecCs0ttd�}tdddgd�}|jd||td�dS)Nr&rr�r'�test_init_env_dev_mode_allocr)rrrr�rrrrr*js
�
�z,InitConfigTests.test_init_env_dev_mode_alloccCs,dti}dddgd�}|jd||td�dS)Nr�rr�)r�r�r��test_init_dev_moder)r)rr�rrrrr+rs��
�z"InitConfigTests.test_init_dev_modecCsDdti}dggd�tj�d�dddgdgd�}|jd||td	�dS)
Nr��	script.py)rr�devr,rr�r-)r�r�r�r�r�r�r��test_preinit_parse_argvr)r)rrrrr�rrrrr.~s�
�	
�z'InitConfigTests.test_preinit_parse_argvcCs2ddi}gd�}||dd�}|jd||td�dS)Nr�r)r�-Ez-Irr-r�utf8r,)r�r�r��test_preinit_dont_parse_argvr�rr�)r+r
r�r�rrrr1�s��
�z,InitConfigTests.test_preinit_dont_parse_argvcCs dddd�}|jd|td�dS)Nrr�r�r�r��test_init_isolated_flagr�rr��r+r�rrrr4�s
�z'InitConfigTests.test_init_isolated_flagcCs dddd�}|jd|td�dS)Nrrr3�test_preinit_isolated1rrr6rrrr7�s
�z&InitConfigTests.test_preinit_isolated1cCs dddd�}|jd|td�dS)Nrrr3�test_preinit_isolated2rrr6rrrr8�s
�z&InitConfigTests.test_preinit_isolated2cCs|jdtd�dS)N�test_preinit_isolated_configrr2r0rrrr9�sz,InitConfigTests.test_preinit_isolated_configcCs|jdtd�dS)N�test_init_isolated_configrr2r0rrrr:�sz)InitConfigTests.test_init_isolated_configcCs|jdtd�dS)N�test_preinit_python_configrr5r0rrrr;�sz*InitConfigTests.test_preinit_python_configcCs|jdtd�dS)N�test_init_python_configrr5r0rrrr<�sz'InitConfigTests.test_init_python_configcCs ddd�}|jdi|td�dS)Nr)r�r��test_init_dont_configure_localerr5)r+r
rrrr=�s�
�z/InitConfigTests.test_init_dont_configure_localecCs(ddd�}dd�}|jd|t|d�dS)Nz./init_read_setZ
my_executable)r�r$cSs|�dd�|�d�dS)NrZtest_path_insert1Ztest_path_append)�insertrU)rrrr�modify_path�sz7InitConfigTests.test_init_read_set.<locals>.modify_path�test_init_read_set)r�r�r5)r+r�r?rrrr@�s��z"InitConfigTests.test_init_read_setcCs.dgd�gd�gd�d�}|jd|td�dS)Nr)Zconfig_xoptionrZsysadd_xoptionr�)�ignore:::cmdline_warnoptionzignore:::sysadd_warnoptionzignore:::config_warnoption)rrrArr)r�r�r�r��test_init_sys_addrr5r6rrrrB�s�z!InitConfigTests.test_init_sys_addcCs8d}ddgdd|dgd|ddd�}|jd	|td
�dS)N�Rimport _testinternalcapi, json; print(json.dumps(_testinternalcapi.get_configs()))r�rr�	./python3ror)r�r�r�r�r��test_init_run_mainrr5�r+r�r�rrrrE�s
�z"InitConfigTests.test_init_run_maincCs<d}ddgdd|dgd|dddd	�}|jd
|tdd�dS)
NrCr�rrrDrorr)r�r�r�r�r�r��test_init_mainz)Run Python code before _Py_InitializeMain)r�r7r5rFrrrrG�s��
�zInitConfigTests.test_init_maincCs.dgd�gd�dddd�}|jd|td	�dS)
Nr)r��arg1�-v�arg3��./argv0r/r�rrHrIrJrLrr)r�r�r�r�r�r��test_init_parse_argvrr5r6rrrrMs�z$InitConfigTests.test_init_parse_argvcCs4ddi}dgd�gd�dd�}|jd||td�dS)Nr�rrKrL)r�r�r�r��test_init_dont_parse_argvrr5)r+r�r�rrrrNs��
�z)InitConfigTests.test_init_dont_parse_argvcCsDtrd}|j}nd}tr |j}nt�|�p,d}|�|||d��dS)N�pythonrr)r�r�r$)r"r&�MACOS�shutil�whichr�)r+r�r�r$rrr�default_program_name&s�z$InitConfigTests.default_program_namecCsX|��}|dd}|ddddd�}|�|�dtjj�|�i}|jd|t|dd�dS)	Nr�r�r)r�r�r�r�r��TESTPATH�test_init_setpathT�r�rr�)r�rSrrr�r%rr��r+r�r�rrrrrU6s�
�z!InitConfigTests.test_init_setpathc	CsT|��}|dd}|dddddddd�}dtjj�|�i}|jd|t|d	d
�dS)Nr�r�rZconf_program_nameZconf_executable)r�r�r�r�r�r�r�r$rT�test_init_setpath_configTrV)r�rrr�r%rr�rWrrrrXIs��z(InitConfigTests.test_init_setpath_configc
Cs�|��}|dur|dd}|dur0|dd}tr@|ddStj}tj�|tjd|j�|j	�d��tj�|tjd|j�d|j	���tj�|tjd|j�d|j	��d�gSdS)Nr�r�r�rOz.zip�.�lib-dynload)
r�r"r#�version_inforrr%r��major�minor)r+r�r�r��verrrrr�^s$����z#InitConfigTests.module_search_pathsc	cs�t����}tj�|�}trlddl}tj�|j�}t�	|�D]0}|�|d�r:t
�tj�||�tj�||��q:tj�|tj�
|j��}t
�|j|�t
�|j|�||_|VWd�n1s�0YdS)Nrz*.dll)�tempfile�TemporaryDirectoryrr�realpathr"�fnmatchr!r&�listdirrQ�copyfiler%r
�copystat)r+�tmpdirrbZexedir�fZ	exec_copyrrr�tmpdir_with_pythonqs
"z"InitConfigTests.tmpdir_with_pythoncCs�|��}|dd}tjj�|�}|D]8}tj�|�s8q&tj�tj�|d��r&tj�|�}qpq&|�d|���|}}t	j
}|j||d�}	||	|||||d�}|�|�||d�}
|j
d|t|
d	�dS)
Nr�r��os.pyzUnable to find home in )r�r�)r�r�r�r�r�r�r�)ZTESTHOMEr��test_init_setpythonhome)r�r)r�rrr�r%�isdirr'r!r�r#r[r�rSrr�)r+r�r��	paths_strrr�r�r�r^Zexpected_pathsrrrrrj�s4�	

�z'InitConfigTests.test_init_setpythonhomecCs6|��}|dd}tjj�|�}||d<d|i}|S)Nr�r�r�r�)r�rrr�r%)r+r�Zall_configsr�rlrrrr�copy_paths_by_env�sz!InitConfigTests.copy_paths_by_envz#Windows does not use pybuilddir.txtc
	Cs�|����}d}tj�||�}t�|�tj�|d�}t|ddd��}|�|�Wd�n1sb0Y|��}||d<|j}|||d�}|�	|�}	|j
d|t|	d	|d
�Wd�n1s�0YdS)N�libdirzpybuilddir.txt�wr0��encoding���)r�r$r�r	T�r�rr�r5)rhrrr%�mkdir�open�writer�r&rmrr�)
r+rfZsubdirrn�filename�fpr�r$r�rrrr�test_init_pybuilddir�s&

(�
�z$InitConfigTests.test_init_pybuilddircCs|�����}t�����}tj}tsRtj�|tj	d|j
�d|j��d�}t�|�n0tj�|d�}t�|�t
�tjtj�|d��tj�|d�}t|ddd	��,}td
||d�td|d�Wd�n1s�0Y|��}ts�||d
<nZt|�D]H\}}	|dk�r&tj�|tj�|	��||<q�tj�|tj�|	��||<q�||d
<|j}
|}|||
|
|d�}t�rz||d<||d<|�|�}
|jd|t|
d|d�}t�r�|�|ddtj�|tj�|jdd���Wd�n1�s�0YWd�n1�s0YdS)NrOrYrZ�libriz
pyvenv.cfgror0rpz	home = %s��filez$include-system-site-packages = falserrr)r�r�r�r$r�r�r�r	TrsZwindowsZpython3_dll)rhr_r`r#r[r"rrr%r�r\r]�makedirsrQrdr rurBr�rbr
r&rmrr�rCr�)r+rfZpyvenv_homer^Zlib_dynloadrwrxr��indexrr$r�r�r�actualrrr�test_init_pyvenv_cfg�sf��
*

�
�
��z$InitConfigTests.test_init_pyvenv_cfgc
s�t�d��t�d�}�fdd�}|d�}|d�}|d�}|d�}|d	�}|d
�}|��d}	|�|��tjj�|	d�|�|�|	d
�|�|�|	d�|�|�|	d�|�|�|	d�|�|�|	d�dS)N�ctypes�_testinternalcapicst�j|�}d|_�j|_|S)Nr)�getattrZ	pythonapi�argtypesZ	c_wchar_pZrestype)r�func�r�rr�get_funcsz8InitConfigTests.test_global_pathconfig.<locals>.get_func�
Py_GetPath�Py_GetPrefix�Py_GetExecPrefix�Py_GetProgramName�Py_GetProgramFullPath�Py_GetPythonHomer�r�r�r�r�r$r�)r�
import_moduleZget_configsrCr�rrr�)
r+r�r�r�r�r�r�r�r�r�rr�r�test_global_pathconfig
s$

�z&InitConfigTests.test_global_pathconfigcCs<gd�}ttd�}ddd|gd�d�}|jd||td�dS)N)zignore:::PyConfig_Insert0r�z
ignore:::env1z
ignore:::env2zignore:::cmdline1zignore:::cmdline2r
zignore:::PySys_AddWarnOption1zignore:::PySys_AddWarnOption2zignore:::PyConfig_BeforeReadzignore:::PyConfig_AfterReadr&r)rz-Wignore:::cmdline1z-Wignore:::cmdline2)r�r�r�r�r��test_init_warnoptionsr)rr)rr�)r+r�r
r�rrrr�3s
�	
�z%InitConfigTests.test_init_warnoptionscCs|�d�dS)N�test_get_argc_argv�rIr0rrrr�Nsz"InitConfigTests.test_get_argc_argv)N)NNNN)NN)QrYrZr[r}r"r��objectr�r�r��PYMEM_ALLOCATOR_NOT_SETrr�rr�r�r�r�r�r#r�rrrr�r�r�r9r��classmethodr�r�r�r�r�r�r�r�rrrr	rrr$r%r(r*r+r.r1r4r7r8r9r:r;r<r=r@rBrErGrMrNrSrUrXr��
contextlib�contextmanagerrhrjrmriZskipIfryr�r�r�r�rrrrr�@sh�	���
�D�����



�
@��3?			


!

=&r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�
AuditingTestscCs|�d�dS)N�test_open_code_hookr�r0rrrr�Tsz!AuditingTests.test_open_code_hookcCs|�d�dS)N�
test_auditr�r0rrrr�WszAuditingTests.test_auditcCs|�d�dS)N�test_audit_subinterpreterr�r0rrrr�Zsz'AuditingTests.test_audit_subinterpretercCs|jdtjdd�dS)N�test_audit_run_commandr�r2r3�rIr�
SHORT_TIMEOUTr0rrrr�]s�z$AuditingTests.test_audit_run_commandcCs|jdtjdd�dS)N�test_audit_run_filerr�r�r0rrrr�bs�z!AuditingTests.test_audit_run_filec	Cs�tj�|jtj�d}t|ddd��(}td|d�td|d�Wd�n1sR0Yz4it��d|i�}|j	d	tj
d
|d�Wt�|�nt�|�0dS)N�.pyrorurpz
import sysr{z&sys.__interactivehook__ = lambda: None�
PYTHONSTARTUP�test_audit_run_interactivehook�
�r2r3r�rrr%r)rZTESTFNrurBrrIr��unlink�r+Zstartuprgrrrrr�gs*�z,AuditingTests.test_audit_run_interactivehookc	Cs�tj�|jtj�d}t|ddd��}td|d�Wd�n1sF0Yz4it��d|i�}|j	dtj
d	|d
�Wt�|�nt�|�0dS)Nr�rorurprr{r��test_audit_run_startupr�r�r�r�rrrr�ts*�z$AuditingTests.test_audit_run_startupcCs|jdtjdd�dS)N�test_audit_run_stdinrr�r�r0rrrr��s�z"AuditingTests.test_audit_run_stdinN)rYrZr[r�r�r�r�r�r�r�r�rrrrr�Ss
r��__main__)"�testrri�collectionsrr�r�rrOrQr;r#r_r�rr"�platformrPr�r)rr�r�r�rqrrrZTestCaser\r�r�rYrWrrrr�<module>sJ

	n"2


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