Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_compileall.cpython-312.opt-2.pyc

�

'Μg���p�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZ
ddlZddlZddlmZmZ	ddlmZddlmZddlmZe�dZddl
mZdd	lmZdd
lmZddl m!Z!ddl m"Z"dd
l#m$Z$d�Z%d�Z&d�Z'Gd�d�Z(Gd�de(ejRe"d��Z*Gd�de(ejRe"d��Z+ejXejZd�Gd�dejR��Z.Gd�d�Z/Gd�de/ejRe"d��Z0Gd�d e/ejRe"d��Z1ej"e2ed!�d"�Gd#�d$��Z3Gd%�d&e3ejRe"d��Z4Gd'�d(e3ejRe"d��Z5e6d)k(rejn�yy#eef$rdZY��WwxYw)*�N)�mock�
skipUnless)�_cleanup_tests)�ProcessPoolExecutor)�_check_system_limitsTF)�support)�	os_helper)�
script_helper)�without_source_date_epoch)�SourceDateEpochTestMeta)�FakePathc�L�|sd}tjj||��S)N���optimization)�	importlib�util�cache_from_source��script�opts  �1/usr/local/lib/python3.12/test/test_compileall.py�get_pycr$s$������>�>�+�+�F��+�E�E�c�@�dD�cgc]}t||���c}Scc}w)N�r��)rrs  r�get_pycsr+s!��,5�6�I�S�G�F�C� �I�6�6��6s�c��	tj|�j}tj|�j}||k(S�N)�os�stat�st_ino)�	filename1�	filename2�inode1�inode2s    r�is_hardlinkr)/s8��B�
�W�W�Y�
�
&�
&�F�
�W�W�Y�
�
&�
&�F��V��rc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zeed�ej4d�d���Zd�Zeed�ej4d�d���Zeed�ej4d�ej4d�d����Zeed�ej4dd��ej4d�d����Zd�Z d d!�d"�Z!d#�Z"eed�d$��Z#d%�Z$eed�d&��Z%d'�Z&d(�Z'd)�Z(d*�Z)d+�Z*e+jXd,��Z-y)-�CompileallTestsBasec��tj�|_|jtj
|j�tjj|jd�|_	tjj|j�|_
t|jdd��5}|jd�ddd�tjj|jd�|_tjj|j �|_t	j$|j|j �tjj|jd�|_t
j(|j&�tjj|j&d�|_t	j$|j|j*�y#1swY��9xYw)	N�_test.py�w�utf-8��encodingzx = 123
z	_test2.py�_subdirz	_test3.py)�tempfile�mkdtemp�	directory�
addCleanup�shutil�rmtreer"�path�join�source_pathrrr�bc_path�open�write�source_path2�bc_path2�copyfile�subdirectory�mkdir�source_path3��self�files  r�setUpzCompileallTestsBase.setUp8sB��!�)�)�+�������
�
�t�~�~�6��7�7�<�<����
�C��� �~�~�7�7��8H�8H�I���
�$�"�"�C�'�
:�d��J�J�{�#�;��G�G�L�L�����E���!���8�8��9J�9J�K��
�����(�(�$�*;�*;�<��G�G�L�L�����C���
����"�"�#��G�G�L�L��):�):�K�H�������(�(�$�*;�*;�<�;�
:�s�9H�Hc���tjj|jd�|_t|jdd��5}|j
d�ddd�y#1swYyxYw)Nz_test_bad.pyr.r/r0zx (
)r"r9r:r5�bad_source_pathr=r>rEs  r�add_bad_source_filez'CompileallTestsBase.add_bad_source_fileHsI��!�w�w�|�|�D�N�N�N�K���
�$�&�&��g�
>�$��J�J�w��?�
>�
>�s�A#�#A,c�L�t|jd�5}|jd�}ddd�tt	j
|j�j�}tjdtjjd|dz�}|fS#1swY�rxYw)N�rb��<4sLLr���)
r=r<�read�intr"r#r;�st_mtime�struct�packrr�MAGIC_NUMBER)rFrG�data�mtime�compares     r�timestamp_metadataz&CompileallTestsBase.timestamp_metadataMs|��
�$�,�,��
%���9�9�R�=�D�&��B�G�G�D�,�,�-�6�6�7���+�+�g�y�~�~�'B�'B�A�#�k�1�3���W�}��&�
%�s�B�B#c�f�	tj|jd�t
jtj��5|jtj|j��ddd�y#ttf$r|jd�Y��wxYw#1swYyxYw)N)rPrPz0filesystem doesn't support timestamps near 2**32�
r"�utimer;�
OverflowError�OSError�skipTest�
contextlib�redirect_stdout�io�StringIO�
assertTrue�
compileall�compile_file�rFs r� test_year_2038_mtime_compilationz4CompileallTestsBase.test_year_2038_mtime_compilationUs���	N��H�H�T�%�%�'=�>��
'�
'����
�
6��O�O�J�3�3�D�4D�4D�E�F�7�
6���w�'�	N��M�M�L�M�	N��
6�
6��� B�	/B'� B$�#B$�'B0c�f�	tj|jd�t
jtj��5|jtj|j��ddd�y#ttf$r|jd�Y��wxYw#1swYyxYw)N)� rlz+filesystem doesn't support large timestampsr\rhs r�test_larger_than_32_bit_timesz1CompileallTestsBase.test_larger_than_32_bit_times_s���	I��H�H�T�%�%�~�6��
'�
'����
�
6��O�O�J�3�3�D�4D�4D�E�F�7�
6���w�'�	I��M�M�G�H�	I��
6�
6�rjc���	tjjd�rtjd��tj|j�|j|j��t|jd�5}|j�t|�d}ddd�t|jd�5}|j|�|j�ddd�|j|j��t!j"|j$dd��|j&|j��y#1swY��xYw#1swY�rxYw)N�SOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setrM�wbFT��force�quiet)r"�environ�get�unittest�SkipTest�
py_compile�compiler;�assertEqualrZr=r<rQ�lenr>�assertNotEqualrf�compile_dirr5re)rF�metadatarG�bcs    r�recreation_checkz$CompileallTestsBase.recreation_checkis��	�
�:�:�>�>�-�.��#�#�$>�?�?����4�+�+�,�����$�1�1�3�4�
�$�,�,��
%������S��]�^�,�B�&�
�$�,�,��
%���J�J�x� ��J�J�r�N�&�	����T�4�4�6�7����t�~�~�U�$�G������0�0�2�3�&�
%��
%�
%�s�E�#E�E�E c��|jtjdtjj
dd��y)NrOrr)r�rTrUrrrVrhs r�
test_mtimezCompileallTestsBase.test_mtimeys.�����f�k�k�'�9�>�>�3N�3N�*+�Q�0�	1rc�&�|jd�y)Ns)r�rhs r�test_magic_numberz%CompileallTestsBase.test_magic_number~s�����k�*rc�j�|j|jfD]}	tj|��|j	tj|jdd���|j	tjj|j�xr*tjj|j��tj|j�|j	tj|jdd���|j	tjj|j�xr)tjj|j��tj|j�tj|j�|j�|jtj|jdd���|jtj|jdd���y#Y��xYw)NFTrqr)r<r@r"�unlinkrerfrgr;r9�isfiler}r5rK�assertFalserJ)rF�fns  r�test_compile_filesz&CompileallTestsBase.test_compile_files�s����<�<����/�B�
��	�	�"�
�0�
	
���
�/�/��0@�0@�6;�4�I�	J���������t�|�|�4�:��G�G�N�N�4�=�=�9�9�	;�
�	�	�$�,�,�����
�.�.�t�~�~�U�59�;�	<���������t�|�|�4�6������t�}�}�5�	7�
�	�	�$�,�,��
�	�	�$�-�-� �� � �"�����0�0��1E�1E�7<�A�G�	H�����/�/����6;�1�F�	G��#
��s�H-�-H2c���|jtjj|j��tj�5}|jtjt|j���ddd�|jj�d�|jtjj|j��y#1swY�bxYw)Nz&Compiling ([^WindowsPath|PosixPath].*))r�r"r9r�r<r�captured_stdoutrerfrgr
r;�assertRegex�getvalue)rF�stdouts  r�test_compile_file_pathlikez.CompileallTestsBase.test_compile_file_pathlike�s��������������5�6�
�
$�
$�
&�&��O�O�J�3�3�H�T�=M�=M�4N�O�P�'�������*�,U�V���������t�|�|�4�5�'�
&�s�
8C&�&C/c�j�|jtjj|j��|jt
jt|j�td�d���|jtjj|j��y)N�	ddir_pathr)�ddirrs�
r�r"r9r�r<rerfrgr
r;rhs r�test_compile_file_pathlike_ddirz3CompileallTestsBase.test_compile_file_pathlike_ddir�sq�������������5�6����
�/�/���9I�9I�0J�5=�k�5J�67�9�	:�	
��������t�|�|�4�5rc�j�|jtjj|j��|jt
jt|j�td�d���|jtjj|j��y�N�
stripdir_pathr)�stripdirrsr�rhs r�#test_compile_file_pathlike_stripdirz7CompileallTestsBase.test_compile_file_pathlike_stripdir�sq�������������5�6����
�/�/���9I�9I�0J�9A�/�9R�67�9�	:�	
��������t�|�|�4�5rc�j�|jtjj|j��|jt
jt|j�td�d���|jtjj|j��y�N�prependdir_pathr)�
prependdirrsr�rhs r�%test_compile_file_pathlike_prependdirz9CompileallTestsBase.test_compile_file_pathlike_prependdir�sr�������������5�6����
�/�/���9I�9I�0J�;C�DU�;V�67�9�	:�	
��������t�|�|�4�5rc���tjjj|jg��5|jt
jd���ddd�tjjj|jg��5|j�|jt
jddd���ddd�y#1swY�xYw#1swYyxYw)N�r9r�rsFT)�skip_curdirrrrs)
�test�test_importlibr�import_stater5rerf�compile_pathrKr�rhs r�test_compile_pathz%CompileallTestsBase.test_compile_path�s���
�
 �
 �
%�
%�
2�
2����8H�
2�
I��O�O�J�3�3�!�<�=�J��
 �
 �
%�
%�
2�
2����8H�
2�
I��$�$�&����Z�4�4��;?�q�J�
K�J�
I�J�
I��J�
I�s�&C�8C&�C#�&C/c���tjj|jd�}tjj|d�}tj|�t|d�5	ddd�t
j|�|jtjjtjj|d���y#1swY�kxYw)NrWrGrp�__pycache__)
r"r9r:r5rCr=rfrgr��exists)rF�data_dir�	data_files   r�test_no_pycache_in_non_packagez2CompileallTestsBase.test_no_pycache_in_non_package�s����7�7�<�<�����7���G�G�L�L��6�2�	�
�����
�)�T�
"��#����	�*��������������X�}�(M�N�O�#�
"�s�,C�C!c��|j�tjtj��5|jt
j|j��ddd�y#1swYyxYwr!)	rKrarbrcrdr�rfrgrJrhs r�#test_compile_file_encoding_fallbackz7CompileallTestsBase.test_compile_file_encoding_fallback�sM��� � �"�
�
'�
'����
�
6����Z�4�4�T�5I�5I�J�K�7�
6�
6�s�/A0�0A9c�h�d\}}tj|jd|��tjj|j|��}|jtjj|��tjj|j|��}|jtjj|��tjj|j|��}|jtjj|��y)N)rrT�rs�optimizer)
rfr}r5rrrr;rer"r9r�r?rD)rFr�r�cached�cached2�cached3s      r�
test_optimizez!CompileallTestsBase.test_optimize�s���29�
��#����t�~�~�T�H�M����1�1�$�2B�2B�?B�2�D����������v�.�/��.�.�2�2�4�3D�3D�@C�3�E����������w�/�0��.�.�2�2�4�3D�3D�@C�3�E����������w�/�0rc���|jtjj|j��tj�5}tjt|j��ddd�j�j�d}|j|d�|jtjj|j��y#1swY�uxYw)Nrz$Listing ([^WindowsPath|PosixPath].*))r�r"r9r�r<rr�rfr}r
r5r��
splitlinesr�re)rFr��lines   r�test_compile_dir_pathlikez-CompileallTestsBase.test_compile_dir_pathlike�s��������������5�6�
�
$�
$�
&�&��"�"�8�D�N�N�#;�<�'���� �+�+�-�a�0������F�G���������t�|�|�4�5�	'�
&�s�
)C*�*C3c�j�|jtjj|j��|jt
jt|j�td�d���|jtjj|j��yr��
r�r"r9r�r<rerfr}r
r5rhs r�"test_compile_dir_pathlike_stripdirz6CompileallTestsBase.test_compile_dir_pathlike_stripdir�so�������������5�6����
�.�.�x����/G�8@��8Q�56�8�	9�	
��������t�|�|�4�5rc�j�|jtjj|j��|jt
jt|j�td�d���|jtjj|j��yr�r�rhs r�$test_compile_dir_pathlike_prependdirz8CompileallTestsBase.test_compile_dir_pathlike_prependdir�sp�������������5�6����
�.�.�x����/G�:B�CT�:U�56�8�	9�	
��������t�|�|�4�5r�requires multiprocessingz&concurrent.futures.ProcessPoolExecutorc�~�tj|jdd��|j|j�y�NT��rs�workers�rfr}r5re�called�rF�	pool_mocks  r�test_compile_pool_calledz,CompileallTestsBase.test_compile_pool_called�s,��	���t�~�~�T�1�E����	�(�(�)rc��|jtd�5tj|jd��ddd�y#1swYyxYw)Nz%workers must be greater or equal to 0���)r�)�assertRaisesRegex�
ValueErrorrfr}r5rhs r�!test_compile_workers_non_positivez5CompileallTestsBase.test_compile_workers_non_positives=��
�
#�
#�J�$K�M��"�"�4�>�>�2�>�M�M�M�s�"A�Ac��tj|jdd��|j|jddd�y)NTrr�r�max_workers)rfr}r5rz�	call_argsr�s  r�test_compile_workers_cpu_countz2CompileallTestsBase.test_compile_workers_cpu_counts:��	���t�~�~�T�1�E�����,�,�Q�/�
�>��Erzcompileall.compile_filec��tj|jd��|j|j�|j|j�y)NTr�)rfr}r5r�r�re)rF�compile_file_mockr�s   r�test_compile_one_workerz+CompileallTestsBase.test_compile_one_workers?��	���t�~�~�T�:�����)�)�*����)�0�0�1rN��newc�~�tj|jdd��|j|j�yr�r�)rFr�s  r�$test_compile_missing_multiprocessingz8CompileallTestsBase.test_compile_missing_multiprocessings-��	���t�~�~�T�1�E����)�0�0�1rc��d}|j}td|dz�D]z}tjj	|d|���}tjj	|d�}tj
|�t
j|j|��|tjj�}tj|jd|dz
��|jtjj|��tj|jd|��|j!tjj|��y)N�r�dir_z	script.pyT)rs�	maxlevels)r5�ranger"r9r:rCr7rAr;rrrrfr}r�r�re)rF�depthr9�i�source�pyc_filenames      r�test_compile_dir_maxlevelsz.CompileallTestsBase.test_compile_dir_maxlevelss������~�~���q�%�!�)�$�A��7�7�<�<���Q�C�j�1�D��W�W�\�\�$��4�F��H�H�T�N��O�O�D�,�,�f�5�	%�
!�~�~�7�7��?�����t�~�~�T�U�Q�Y�O����������5�6����t�~�~�T�U�K���������|�4�5rT)�parallelc��	ddg}|j}g}|D]t}tjj||�}tj|�tj|dd�|jtj|dd���v|r|jt�tj|jd||rdnd	�
�|j|�|D�]}|j|j|j�|�tjj!|�}|t#|jtj$z�d}	tj&|�\}
}
}tjj||	�}t(j*jj-|�}
|j/|
j0|�|j3d|�d�tj4|���� y)Nr��foo�__init__r�modzdef fn(): 1/0
fn()
Trr)rsr�r��")r5r"r9r:rCr
�make_script�appendr6�multiprocessing_cleanup_testsrfr}re�
startswithrrrr{�sep�assert_python_failurer�r��get_code_from_pycrz�co_filename�assertIn�fsdecode)rFr�r��fullpathr9�mods�subdirr��modcode�modpath�_�err�expected_in�mod_code_objs              r�_test_ddir_onlyz#CompileallTestsBase._test_ddir_only+s���N��E�?���~�~�����F��7�7�<�<��f�-�D��H�H�T�N��%�%�d�J��;��K�K�
�1�1�$��2I�K�
L�	���O�O�9�:�������d��%��1�	.�	
������C��O�O�C�N�N�4�>�>�:�C�@��n�n�6�6�s�;�G��#�d�n�n�R�V�V�3�4�5�6�G�%�;�;�G�D�I�A�q�#��'�'�,�,�t�W�5�K��.�.�3�3�E�E�g�N�L����\�5�5�{�C��M�M�A�k�]�!�,�b�k�k�#�.>�?�rc�*�	|jdd��S)N�
<a prefix>F�r�r��r�rhs r�test_ddir_only_one_workerz-CompileallTestsBase.test_ddir_only_one_workerHs��K��#�#���#�F�Frc�*�	|jdd��S)NrTrrrhs r�test_ddir_multiple_workersz.CompileallTestsBase.test_ddir_multiple_workersLs��K��#�#���#�E�Erc�*�	|jdd��S)NrFrrrhs r�test_ddir_empty_only_one_workerz3CompileallTestsBase.test_ddir_empty_only_one_workerQs��M��#�#��e�#�<�<rc�*�	|jdd��S)NrTrrrhs r� test_ddir_empty_multiple_workersz4CompileallTestsBase.test_ddir_empty_multiple_workersUs��M��#�#��d�#�;�;rc��gd�}tjj|jg|���}tj|�tj|dd�}tjj|�}tjj|jg|dd���}tj|d|��tj|�\}}}tjj|dd�}	|j|	t|tj ����|j#|t|tj ����y)N�r��build�realr9r��1 / 0rT)rsr�r0�r"r9r:r5�makedirsr
r�rrrrfr}r�r��str�sys�getdefaultencoding�assertNotIn)
rFr�r9rrr��rc�outr�r�s
          r�test_strip_onlyz#CompileallTestsBase.test_strip_onlyZs���4���w�w�|�|�D�N�N�6�X�6��
���D���*�*�4���A��
�^�^�
-�
-�f�
5���7�7�<�<����>��"�1��>�����t�4�(�C�$�:�:�2�>���C���g�g�l�l�H�Q�R�L�1���
�
����c�4�4�6�7�	
�	
������c�4�4�6�7�	
rc��gd�}tjj|jg|���}tj|�tj|dd�}tjj|�}d}tj|d|��tj|�\}}}tjj||jg|���}	|j|	t|tj ����y)Nrr�r�/fooT)rsr�r0)r"r9r:r5rr
r�rrrrfr}r�r�rrr)
rFr�r9rrr�rrr�r�s
          r�test_prepend_onlyz%CompileallTestsBase.test_prepend_onlyms���4���w�w�|�|�D�N�N�6�X�6��
���D���*�*�4���A��
�^�^�
-�
-�f�
5���
����t�4�J�G�$�:�:�2�>���C���g�g�l�l�:�t�~�~�I��I���
�
����c�4�4�6�7�	
rc��gd�}tjj|jg|���}tj|�tj|dd�}tjj|�}tjj|jg|dd���}d}tj|d||��tj|�\}}}	tjj|g|dd���}
|j|
t|	tj ����|j#|t|	tj ����y)	Nrr�rrrT)rsr�r�r0r�rFr�r9rrr�r�rrr�r�s           r�test_strip_and_prependz*CompileallTestsBase.test_strip_and_prepend|s��4���w�w�|�|�D�N�N�6�X�6��
���D���*�*�4���A��
�^�^�
-�
-�f�
5���7�7�<�<����>��"�1��>���
����t�4�(0�Z�	I�$�:�:�2�>���C���g�g�l�l�:�=�����=���
�
����c�4�4�6�7�	
�	
������c�4�4�6�7�	
rc�@�gd�}tjj|jg|���}tj|�tj|dd�|jt�5tj|dddd��ddd�y#1swYyxYw)N)r�r
rr9r�r�rTz/barr)rsr�r�r�)r"r9r:r5rr
r��assertRaisesr�rfr})rFr�r9s   r�test_strip_prepend_and_ddirz/CompileallTestsBase.test_strip_prepend_and_ddir�st��<���w�w�|�|�D�N�N�6�X�6��
���D���!�!�$���8�
�
�
�z�
*��"�"�4�t�&�,2�v�
G�+�
*�
*�s�0B�Bc���tj|jdd�}g}dD]2}|jtj
j
||����4ddgddgddggd�g}|D]k}tj|d	|�
�|D]L}|jtjj||��	tj||��N�my#t$rY�]wxYw)N�test_optimization�a = 0�rrrr�rrrrrTr�)r
r�r5r�rrrrfrgrer"r9r�r��	Exception)rFrr�	opt_level�test_combinations�opt_combinations      r�!test_multiple_optimization_levelsz5CompileallTestsBase.test_multiple_optimization_levels�s����*�*�4�>�>�+>�+2�4����$�I��I�I�i�n�n�6�6�v�DM�7�O�
P�%� ��V�a��V�a��V�Y�?��0�O��#�#�F�$�-<�
>�,�	���������r�)�}� =�>���I�I�b��m�,�-� 1��!����s�=C�	C&�%C&c�"�tjj|jddd�}tjj|jddd�}tjj|jddd�}tj|�tj|�tj|�tj|dd�}tj|dd�}tjj|d	�}tjj|d
�}tj||�tj||�tjj|�}tjj|�}	tj|d|��|jtjj|��|jtjj|	��y)
Nr��dir�allowed�symlinks�
prohibited�test_allowedr$�test_prohibited�test_allowed.py�test_prohibited.pyT)rs�
limit_sl_dest)r"r9r:r5rr
r��symlinkrrrrfr}rer�r��
rF�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���w�w�|�|�D�N�N�F�E�9�M�������T�^�^�V�U�J�O�
��'�'�,�,�t�~�~�v�u�l�S��
���L�!�
���M�"�
���O�$�'�2�2�<��QX�Y��)�5�5�o�GX�Za�b���'�'�,�,�}�6G�H���W�W�\�\�-�9M�N��
�
�
�>�?�3�
�
�
�$�&8�9��^�^�5�5�o�F�
�!���8�8�9K�L�
����}�D��U���������z�2�3���������
�6�7r).�__name__�
__module__�__qualname__rHrKrZrirmr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�_have_multiprocessingr�patchr�r�r�r�r�r�r�rrrr
rrrr!r*r	�skip_unless_symlinkr@�rrr+r+6s���=�  �
�G�G�4� 1�
+�G�26�6�6�6�K�
P�L�
1�6�6�6��%�'A�B��T�Z�Z�8�9�*�:�C�*�?�
�%�'A�B��T�Z�Z�8�9�F�:�C�F��%�'A�B��T�Z�Z�8�9��T�Z�Z�)�*�2�+�:�C�2�
�%�'A�B��T�Z�Z�8�d�C��T�Z�Z�)�*�2�+�D�C�2�6�"15�@�:G��%�'A�B�F�C�F�=��%�'A�B�<�C�<�
�&

�
�*G��&�"�"�8�#�8rr+c��eZdZy)�CompileallTestsWithSourceEpochN�rArBrCrGrrrIrI����	rrI)�	metaclass�source_date_epochc��eZdZy)�!CompileallTestsWithoutSourceEpochNrJrGrrrOrO�rKrrOz tempdir is not encodable on WASIc� �eZdZ	d�Zd�Zd�Zy)�EncodingTestc��tj�|_tjj|jd�|_t|jdd��5}|jd�ddd�y#1swYyxYw)Nr-r.r/r0ub"€")	r3r4r5r"r9r:r;r=r>rEs  rrHzEncodingTest.setUp�s[��!�)�)�+����7�7�<�<����
�C���
�$�"�"�C�'�
:�d�
�J�J�{�#�;�
:�
:�s�!A<�<Bc�B�tj|j�yr!)r7r8r5rhs r�tearDownzEncodingTest.tearDown�s���
�
�d�n�n�%rc��tjtj�d��}tj|�5tj|j�}ddd�|j�|jd�|j�}|jd|�|jd|�y#1swY�`xYw)N�asciir0rz<SyntaxError: bytes can only contain ASCII literal characters�UnicodeEncodeError)
rc�
TextIOWrapper�BytesIOrarbrfr}r5r��seekrQr�r)rF�buffer�compiled�ress    r�
test_errorzEncodingTest.test_error�s����!�!�"�*�*�,��A��
�
'�
'��
/�!�-�-�d�n�n�=�H�0�����"����A���k�k�m���
�
�J��	
�	
���-�s�3�0�
/�s� B>�>CN)rArBrCrHrTr^rGrrrQrQ�s���$�&�4rrQc�B�eZdZ	d�Zej
d��Zd�Zd�Zd�Z	d�Z
d�Zd�Ze
ejd	�d
���Zejd	�d��Zdd
gfdddgfdddgffD]\ZZZeefd�Zee�dez<�d�Zd�Ze
d��Zd�Zd�Zej:d��Zd�Zd�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.e/j`d+�d,��Z1d-�Z2d.�Z3ej:d/��Z4d0�Z5d1�Z6y2)3�CommandLineTestsBasec��tj�|_|jtj
|j�tjj|jd�|_	t
j|j�tjj|jd�|_tj|jdd�|_tj|jdd�|_y)Nr�r�r�r�bar)r3r4r5r6r	r8r"r9r:�pkgdirrC�pkgdir_cachedirr
r��initfn�barfnrhs rrHzCommandLineTestsBase.setUp�s���!�)�)�+������	�(�(�$�.�.�9��g�g�l�l�4�>�>�5�9���
�������!�w�w�|�|�D�K�K��G���#�/�/����Z��L���"�.�.�t�{�{�E�2�F��
rc#��K�	tj}tjj	|j
d�}	|t_|j
|d���|t_y#|t_wxYw�w)N�
__testcache__)�
PYTHONPATH�PYTHONPYCACHEPREFIX)r�pycache_prefixr"r9r:r5)rF�
old_prefix�
new_prefixs   r�temporary_pycache_prefixz-CommandLineTestsBase.temporary_pycache_prefixs_����4��'�'�
��W�W�\�\�$�.�.�/�B�
�	,�!+�C��"�n�n�'1��
�
",�C����C��s�<A7�A'�A7�'
A4�4A7c�>�gtj��d�d�d�|�S)Nz-S�-mrf)r�!optim_args_from_interpreter_flags)rF�argss  r�
_get_run_argsz"CommandLineTestsBase._get_run_argss<����:�:�<������(����	rc��tj|j|�i|�ddi��\}}}|jd|�|S)N�PYTHONIOENCODINGr/r)r
�assert_python_okrsrz�rFrr�env_varsrrr�s      r�assertRunOKz CommandLineTestsBase.assertRunOKsM��$�5�5��,�,�T�2�3�6>�3�*1�3���C��	
����c�"��
rc�d�tj|j|�i|�ddi��\}}}|||fS)Nrur/)r
r�rsrws      r�assertRunNotOKz#CommandLineTestsBase.assertRunNotOKsD��$�:�:��+�+�D�1�2�5=�2�)0�2���C���3��|�rc��tjj|�}|jtj
j
|��yr!)rrrrer"r9r��rFr�r9s   r�assertCompiledz#CommandLineTestsBase.assertCompiled"s/���~�~�/�/��3����������t�,�-rc��tjj|�}|jtj
j
|��yr!)rrrr�r"r9r�r}s   r�assertNotCompiledz&CommandLineTestsBase.assertNotCompiled&s1���~�~�/�/��3�����������-�.rc�B�tj|jdd�}|j�5}|jdi|��|j|�|j
|j�|j
|j�ddd�y#1swYyxYw)N�bazrrG)	r
r�r5rnryr~r�rerf)rF�bazfn�envs   r�test_no_args_compiles_pathz/CommandLineTestsBase.test_no_args_compiles_path*sy���)�)�$�.�.�%��D��
�
*�
*�
,���D���#�s�#�����&��"�"�4�;�;�/��"�"�4�:�:�.�	-�
,�
,�s�AB�B�cpuc��tj|jdd�}|j�5}|jdi|��t
jj|�}ddd�tjtj�dz
fdz�tj|�j}|jdi��tj|�j}|j||�|jdi|��tj|�j}|j||�y#1swY��xYw)Nr�r�<rrG)�-f)r
r�r5rnryrrrr"r]�timer#rSrzr|)rFr�r��pycpathrX�mtime2s      r� test_no_args_respects_force_flagz5CommandLineTestsBase.test_no_args_respects_force_flag3s���)�)�$�.�.�%��D��
�
*�
*�
,���D���#�s�#��n�n�6�6�u�=�G�-�	����4�9�9�;�r�>�+�A�-�.����� �)�)�������3������!�*�*�������'�����%��%�����!�*�*�����E�6�*�-�
,�s�2E�E
c� �tj|jdd�|j�5}|jdi|��}ddd�|jd�|jdi��}|j
d|�y#1swY�@xYw)Nr�rsListing rG)�-q)r
r�r5rnryr�r)rFr��noisyrss    r� test_no_args_respects_quiet_flagz5CommandLineTestsBase.test_no_args_respects_quiet_flagFs|���!�!�$�.�.�%��<�
�
*�
*�
,��$�D�$�$�+�s�+�E�-��
�
�k�5�)� �� � �-��-������e�,�	-�
,�s�B�B
�normal�pycr�z	opt-1.pyc�-O�doubleoptimizez	opt-2.pycz-OOc���tj|ddd|jgz�|jtj
j
|j��t�fd�dD��}|jtt	j|j��|�|jt	j|j�D�cgc]}|j��r|��c}�ycc}w)Nrprfr�c3�r�K�|].}|jtjj�����0y�wr!)�formatr�implementation�	cache_tag)�.0�base�exts  �r�	<genexpr>z)CommandLineTestsBase.f.<locals>.<genexpr>[s1�����K�*I�$�#�k�k�#�*<�*<�*F�*F��L�*I�s�47)z__init__.{}.{}z	bar.{}.{})
r
rvrcrer"r9r�rd�sortedrz�listdirr��endswith)rFr��switch�expectedr�s `   r�fzCommandLineTestsBase.fVs�����*�*�V��|�T�4�;�;�7�.8�
:�
�O�O�B�G�G�N�N�4�+?�+?�@�A��K�*I�K�K�H����V�B�J�J�t�/C�/C�$D�E�x�P����2�:�:�d�k�k�+B�3�+B�R�!#���S�!1�!�+B�3�
4��3s�C7�test_pep3147_paths_c�8�|jdd|j�|jtjj|j��tgd��}|jttj|j��|�y)Nz-br�)�__init__.pyz__init__.pyczbar.pyzbar.pyc)
ryrcr�r"r9r�rdr�rzr�)rFr�s  r�test_legacy_pathsz&CommandLineTestsBase.test_legacy_pathscsl��	
����t�T�[�[�1����������(<�(<�=�>��&�'�������
�
�4�;�;� 7�8�(�Crc�`�|jd|j�|jtjj|j��tjj|jd�}|jtjj|��|jd|j�|jtjj|j��|jtjj|��y)Nr�r�)	ryrcrer"r9r�rdr:r�)rF�
cachecachedirs  r�test_multiple_runsz'CommandLineTestsBase.test_multiple_runsms���	
����t�{�{�+���������t�';�';�<�=������T�%9�%9�=�I�
���������
�6�7�����t�{�{�+���������t�';�';�<�=���������
�6�7rc�`�|jd|j�tjj	|j
�}t
j|tj�dz
fdz�t
j|�j}|jd|j�t
j|�j}|j||�|jdd|j�t
j|�j}|j||�y)Nr�r�rr�)
ryrcrrrrfr"r]r�r#rSrzr|)rFr�rXr�s    r�
test_forcezCommandLineTestsBase.test_forcezs�������t�{�{�+��.�.�2�2�4�:�:�>��
����4�9�9�;�r�>�+�A�-�.����� �)�)������t�{�{�+�����!�*�*�������'�����t�T�[�[�1�����!�*�*�����E�6�*rc�N�tjj|jd�}tj|�tj|dd�}tj|dd�}|jdd|j�|j|�|jtjjtjj|d���|jd|j�|j|�|j|�y)N�spamr�r�hamr�z-lr�)r"r9r:rcrCr
r�ryr�r�r�r~)rF�
subpackage�	subinitfn�hamfns    r�test_recursion_controlz+CommandLineTestsBase.test_recursion_control�s����W�W�\�\�$�+�+�v�6�
�
�����!�-�-�j�*�b�I�	��)�)�*�e�R�@������t�T�[�[�1����y�)��������������Z��(O�P�Q�����t�{�{�+����I�&����E�"rc��tjj|jd�}tjj|d�}tjj|d�}|||fD]}t	j
|��tjj|d�}t	j|dd�}t	j|dd�}t	j|dd�}|jdd|j�|j|�|jtjjtjj|d	���|jdd
|j�|j|�|j|�|j|�|jdd|j�|j|�|j|�|j|�|j|�|jdd|j�|j|�|j|�|j|�|j|�y)
Nr�r��eggsr�r�eggr�z-r 0r�z-r 1z-r 2z-r 5)r"r9r:rcr
�make_pkgr�ryr�r�r�r~)	rFr��subpackage2�subpackage3�pkgr�r��spamfn�eggfns	         r�test_recursion_limitz)CommandLineTestsBase.test_recursion_limit�s����W�W�\�\�$�+�+�v�6�
��g�g�l�l�:�u�5���g�g�l�l�;��7����[�9�C��"�"�3�'�:��G�G�L�L��]�;�	��)�)�*�e�R�@���*�*�;���C���)�)�+�u�b�A������v�t�{�{�3����y�)�����G�G�N�N�2�7�7�<�<�
�M�B�C�	E�	
����v�t�{�{�3����I�&����E�"����v�&�����v�t�{�{�3����I�&����E�"����F�#����u�%�����v�t�{�{�3����I�&����E�"����F�#����E�"rc	��tjj|jd�}t	j
|�tjdtjj|d��tjdtjj|d��|jd|j�|jtjj|jdddd��y)Nr��.�evil�evil2r�r�)	r"r9r:rcr
r�r5ryr~)rFr�s  r�test_symlink_loopz&CommandLineTestsBase.test_symlink_loop�s���
�g�g�l�l�4�;�;��/�����s�#�
�
�
�3������S�&�1�2�
�
�
�3������S�'�2�3�����t�{�{�+����B�G�G�L�L��K�K����-�
�	rc��|j|j�}|jd|j�}|jd|�|jd|�y)Nr�r)ryrcr|rz)rFr�rss   r�
test_quietzCommandLineTestsBase.test_quiet�sL��� � ����-��� � ��t�{�{�3�����C��'�����e�$rc��tj|jdd�|jd|j�\}}}|jd|j�\}}}|j	d|�|jd|�y)N�crunchyfrog�
bad(syntaxr�z-qqr)r
r�rcr{r|rz)rFr�rs�silents    r�test_silentz CommandLineTestsBase.test_silent�sp���!�!�$�+�+�}�l�K��)�)�$����<���5�!��*�*�5�$�+�+�>���6�1����C��'�����f�%rc��|jddd|j�|j|j�|j	|j
�y)Nr�z-xz
ba[^\\/]*$)ryrcr�rfr~rerhs r�test_regexpz CommandLineTestsBase.test_regexp�s>������t�]�D�K�K�@����t�z�z�*����D�K�K�(rc���tjj|jd�}tj|�tj|dd�}tj|dd�}|jd|j|�|j|j�|j|j�|j|�|j|�y)N�foo2r�r�bar2r�)r"r9r:r5rCr
r�ryrcr~rerf)rF�pkgdir2�init2fn�bar2fns    r�test_multiple_dirsz'CommandLineTestsBase.test_multiple_dirs�s����'�'�,�,�t�~�~�v�6��
������+�+�G�Z��D���*�*�7�F�B�?������t�{�{�G�4����D�K�K�(����D�J�J�'����G�$����F�#rc��tj|jdd�|jddd|j�\}}}|j	|d�y)Nr�r�r��-d�dinsdale�File "dinsdale)r
r�rcr{r��rFrrr�s    r�test_d_compile_errorz)CommandLineTestsBase.test_d_compile_error�sI���!�!�$�+�+�}�l�K��*�*�4��z�4�;�;�O���C������/�0rc��tj|jdd�}|jddd|j�tj|jdd�}tj
j
|�}tj|tjj|jd��tj|�tj|d	�
�\}}}|j|d�y)Nr�zraise Exceptionr�r�r��bingz
import bazzbaz.pycF)�
__isolatedr�)r
r�rcryrrrr"�renamer9r:�remover�r�)rFr�r�r�rrr�s       r�test_d_runtime_errorz)CommandLineTestsBase.test_d_runtime_error�s����)�)�$�+�+�u�>O�P������t�Z����=�
�
&�
&�t�{�{�F�L�
I���n�n�.�.�u�5��
�	�	�#�r�w�w�|�|�D�K�K��;�<�
�	�	�%��$�:�:�2�%�P���C������/�0rc��|jdtjj|jd�|j
�\}}}|j
|d�|j|d�|jtjjtjj|j���y)N�-i�
nosuchfilesrror.*nosuchfiles	Traceback)r{r"r9r:r5rcr��assertNotRegexr�r�rrrrdr�s    r�test_include_bad_filez*CommandLineTestsBase.test_include_bad_file�s����*�*��"�'�'�,�,�t�~�~�|�<�d�k�k�K���C������1�2����C��.���������	���(H�(H�,0�,@�,@�)B�C�	Drc���tj|jdd�}tj|jdd�}tj|jdd�}tj|jdd�}ttj
j
|jd�dd�	�5}|jtj
j
|jd
�tjz�|jtj
j
|jd�tjz�ddd�|jdtj
j
|jd�|�|j|�|j|�|j|�|j|�y#1swY��xYw)
N�f1r�f2�f3�f4�l1r.r/r0�f1.py�f2.pyr�)
r
r�rcr=r"r9r:r5r>�linesepryr~r��rFr�r�r�r�r�s      r�test_include_file_with_argz/CommandLineTestsBase.test_include_file_with_arg�sC��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�"�'�'�,�,�t�~�~�t�4�c�G�
L�PR��H�H�R�W�W�\�\�$�+�+�w�7��
�
�B�C��H�H�R�W�W�\�\�$�+�+�w�7��
�
�B�C�M�	
����r�w�w�|�|�D�N�N�D�A�2�F����B�����B�����r�"����B��M�
L�s
�;BG�G!c�2�tj|jdd�}tj|jdd�}tj|jdd�}tj|jdd�}ttj
j
|jd�dd�	�5}|jtj
j
|jd
�tjz�ddd�|jdtj
j
|jd��|j|�|j|�|j|�|j|�y#1swY��xYw)Nr�rr�r�r�r�r.r/r0r�r�)
r
r�rcr=r"r9r:r5r>r�ryr�r~r�s      r�test_include_file_no_argz-CommandLineTestsBase.test_include_file_no_args��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�"�'�'�,�,�t�~�~�t�4�c�G�
L�PR��H�H�R�W�W�\�\�$�+�+�w�7��
�
�B�C�M�����r�w�w�|�|�D�N�N�D�A�B����r�"����B�����r�"����r�"�
M�
L�s
�;AF
�
Fc��tj|jdd�}tj|jdd�}tj|jdd�}tj|jdd�}tj|j	d�ddgz�}|j
j
|tjzjd	��tj|�|j|�|j|�|j|�|j|�y)
Nr�rr�r�r�rGr��-rV)
r
r�rc�spawn_pythonrs�stdinr>r"r��encode�kill_pythonr�r~)rFr�r�r�r��ps      r�test_include_on_stdinz*CommandLineTestsBase.test_include_on_stdins���
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=���&�&��);�);�B�)?�4��+�)M�O��	���
�
�r�"�*�*�}�,�,�W�5�6��!�!�!�$����r�"����r�"����B�����r�"rc�P�tj|jdd�}|jd|j||j
�\}}}|j
|d�|j|�|j|j�|j|j
�y)Nr�zsyntax(errorr�srror)	r
r�rcr{rerfr�r�r~)rF�bingfnrrr�s     r�!test_compiles_as_much_as_possiblez6CommandLineTestsBase.test_compiles_as_much_as_possible"s����*�*�4�;�;���O���*�*�<����+1�4�:�:�?���C������g�&����v�&����D�K�K�(����D�J�J�'rc�J�|jd�}|j|d�y)N�badfilenamesCan't list 'badfilename')ryr�)rFrs  r�!test_invalid_arg_produces_messagez6CommandLineTestsBase.test_invalid_arg_produces_message+s#�����}�-������9�:rc��tj|jdd�tjjtjj|jd��}|jd|j�t|d�5}|j�}ddd�|jtjddd�d	�|jd
|j�t|d�5}|j�}ddd�|jtj|ddd�d�y#1swY��xYw#1swY�?xYw)Nr�rr�z --invalidation-mode=checked-hashrM���littler�z"--invalidation-mode=unchecked-hashr)r
r�rcrrrr"r9r:ryr=rQrzrR�
from_bytes)rFr��fprWs    r�test_pyc_invalidation_modez/CommandLineTestsBase.test_pyc_invalidation_mode/s����!�!�$�+�+�t�R�8��n�n�.�.��G�G�L�L����g�.�0�����;�T�[�[�I�
�#�t�_���7�7�9�D���������Q�q�	�8�<�d�C����=�t�{�{�K�
�#�t�_���7�7�9�D���������Q�q�	�8�<�d�C�
�_���_�s�D>�;E
�>E�
Er�c��tj|jdd�}g}td�D]�}tj
j
|jdj|��}t	j|�tj|dd�}|jtj|dd����|j|jdd�|j|�|D]}|j|��y)Nr�rr�zfoo{}r�z-j�0)r
r�r5r�r"r9r:r�rCr�ryr~)rFr��files�suffixrcr�rGs       r�test_workersz!CommandLineTestsBase.test_workers<s����*�*�4�>�>�6�2�F�����A�h�F��W�W�\�\�$�.�.�'�.�.��2H�I�F��H�H�V���*�*�6�:�r�B�B��L�L��2�2�6�6�2�F�G�	�	
�������s�3����F�#��D�����%�rzcompileall.compile_dirc�4�tjdtj|jdg��5tj�|j|j�|j|jddd�ddd�y#1swYyxYw)Nzsys.argvz-j0r�r�r�r)rrEr�
executabler5rf�mainrer�rzr�)rFr}s  r�test_workers_available_coresz1CommandLineTestsBase.test_workers_available_coresKsr��
�Z�Z�
� �^�^�T�^�^�U�C�E��O�O���O�O�K�.�.�/����[�2�2�2�6�y�A�1�E�	E�E�E�s�AB�Bc��gd�}tjj|jg|���}tj|�tj|dd�}tjj|�}tjj|jg|dd���}d}|jd|d||�tj|�\}}}	tjj|g|dd���}
|j|
t|	tj����|j!|t|	tj����y)	Nrr�rrrz-sz-pr0)r"r9r:r5rr
r�rrrryr�r�rrrrrs           rrz+CommandLineTestsBase.test_strip_and_prependSs
��4���w�w�|�|�D�N�N�6�X�6��
���D���*�*�4���A��
�^�^�
-�
-�f�
5���7�7�<�<����>��"�1��>���
�����x��z�4�@�$�:�:�2�>���C���g�g�l�l�:�=�����=���
�
����c�4�4�6�7�	
�	
������c�4�4�6�7�	
rc
�R�tjj|jd�}tj|�tj|dd�}g}dD]2}|jtjj||����4ddgddgddggd	�g}|D]v}|j|gd
�|D����|D]U}|jtjj|t|���	tj||��W�xy#t $rY�fwxYw)N�
optimizationsr#r$r%rr�1�2)rrrc3�8K�|]}dt|�z���y�w)z-oN)r)r��ns  rr�zICommandLineTestsBase.test_multiple_optimization_levels.<locals>.<genexpr>vs����$L�O�q�T�C��F�]�O�s�)r"r9r:r5rr
r�r�rrrryrer�rRr�r&)rFr9rrr'r(r)s       rr*z6CommandLineTestsBase.test_multiple_optimization_levelsgs���w�w�|�|�D�N�N�O�<��
���D���*�*�4�+>�+2�4����$�I��I�I�i�n�n�6�6�v�DM�7�O�
P�%�"�3�Z�!�3�Z�!�3�Z�,�.�� 1�O��D���T�M�$L�O�$L�M�,�	���������r�#�i�.�/A� B�C���I�I�b��m�,�-� 1��!����s�=D�	D&�%D&c��tjj|jddd�}tjj|jddd�}tjj|jddd�}tj|�tj|�tj|�tj|dd�}tj|dd�}tjj|d	�}tjj|d
�}tj||�tj||�tjj|�}tjj|�}	|j|d|�|jtjj|��|jtjj|	��y)Nr�r,r-r.r/r0r$r1r2r3z-e)r"r9r:r5rr
r�r5rrrryrer�r�r6s
          rr@z4CommandLineTestsBase.test_ignore_symlink_destination~sb���w�w�|�|�D�N�N�F�E�9�M�������T�^�^�V�U�J�O�
��'�'�,�,�t�~�~�v�u�l�S��
���L�!�
���M�"�
���O�$�'�2�2�<��QX�Y��)�5�5�o�GX�Za�b���'�'�,�,�}�6G�H���W�W�\�\�-�9M�N��
�
�
�>�?�3�
�
�
�$�&8�9��^�^�5�5�o�F�
�!���8�8�9K�L�
������l�;���������z�2�3���������
�6�7rc�>�|j|jdd�y)N�-o 1�--hardlink-dupes)r{r5rhs r�test_hardlink_bad_argsz+CommandLineTestsBase.test_hardlink_bad_args�s��	
���D�N�N�F�4F�Grc
��dD]�}tj�5}|j|��5tj|dd�}t|�}gd�}|r|j
d�|j|g|���|jt|d|d�|�|jt|d|d	�|�|jt|d|d	�|�ddd�ddd���y#1swY�xYw#1swY��xYw)
N)TF��deduprr$)r�z-o 0rz-o 2rrrr)
r3�TemporaryDirectory�subTestr
r�rr�ryrzr))rFrr9r�pycsrrs      r�
test_hardlinkz"CommandLineTestsBase.test_hardlink�s���#�E��,�,�.�$��\�\��\�.�*�6�6�t�X�w�O�F�#�F�+�D�9�D�����$6�7�$�D�$�$�T�1�D�1��$�$�[��a��$�q�'�%B�E�J��$�$�[��a��$�q�'�%B�E�J��$�$�[��a��$�q�'�%B�E�J�/�/�.�#�.�.��/�.�s#�C?�B3C3� C?�3C<�8C?�?D		N)7rArBrCrHra�contextmanagerrnrsryr{r~r�r�rr�requires_resourcer�r��namer�r�r��localsr�r�r�r�r�r	rFr�r�r�r�r�r�r�r�r�r�r�r�r�rrrDrrrErrr*r@rr"rGrrr`r`�s��� �G����,��,��
��.�/�/���W���u�%�+�&��+�"�W���u�%�-�&�-�
�5�"��	�[�4�&�)�	�;���0����c�6�
�F�
	4�23���&��-�.�!�$D�8��
+��
+�
#� #�D�"�"��#��%�&�)�
	$�1�
1�D� �#�#�(�;�D��%�'A�B�&�C�&��T�Z�Z�(�)�F�*�F�
�(�.�"�"�8�#�8�0H�
Krr`c��eZdZy)�CommandLineTestsWithSourceEpochNrJrGrrr(r(�rKrr(c��eZdZy)�CommandLineTestsNoSourceEpochNrJrGrrr*r*�rKrr*�linkzrequires os.linkc��eZdZd�Zej
d��Zdd�Zdddd�d�Zd	�Z	dd
�Z
d�Zd�Zdd
�Z
d�Zd�Zd�Zd�Zd�Zy)�HardlinkDedupTestsBasec��d|_yr!r�rhs rrHzHardlinkDedupTestsBase.setUp�s	����	rc#�K�tj�5}||_|��d|_ddd�y#1swYyxYw�wr!)r3rr9)rFr9s  r�temporary_directoryz*HardlinkDedupTestsBase.temporary_directory�s2����
�
(�
(�
*�d��D�I��J��D�I�+�
*�
*�s�?�3�	?�<�?c�D�tj|j||�Sr!)r
r�r9)rF�coder%s   rr�z"HardlinkDedupTestsBase.make_script�s���(�(����D�$�?�?rTrF)rr�rrc�L�tj|jd|||��y)NT)rsr��hardlink_dupesrr)rfr}r9)rFrr�rrs    rr}z"HardlinkDedupTestsBase.compile_dir�s �����t�y�y��x�.3�5�	Brc��|j�5|jd�|jt�5t	j
|jddd��ddd�|jt�5t	j
|jdddgd��ddd�ddd�y#1swY�UxYw#1swY�xYw#1swYyxYw)N�passTr)rsr�r4)r0r�r r�rfr}r9rhs r�
test_bad_argsz$HardlinkDedupTestsBase.test_bad_args�s����
%�
%�
'����V�$��"�"�:�.��&�&�t�y�y��q�6:�<�/��"�"�:�.��&�&�t�y�y���1�v�6:�<�/�(�
'�.�.��/�.��(�
'�s:�'C�$B0�C�9&B<�C�0B9	�5C�<C	�C�Cc��g}|r|jd�|jd�|r|jd�dj|�S)Nz'module docstring'zx = 1z
assert x == 1�
)r�r:)rF�	docstring�	assertion�liness    r�create_codez"HardlinkDedupTestsBase.create_code�sA������L�L�-�.�
���W����L�L��)��y�y���rc#�\K�dD]#}dD]}|j||��}|||f����%y�w)N)FT�r:r;)r=)rFr:r;r2s    r�
iter_codesz!HardlinkDedupTestsBase.iter_codes�s<����&�I�*�	��'�'�)�y�'�Q���Y�	�2�2�+�'�s�*,c
���|j�D]�\}}}|j||��5|j�5|j|�}t	|�}|jd��|j
t|d|d��|j
t|d|d��|j
t|d|d��ddd�ddd���y#1swY�xYw#1swY��xYw)Nr?Frrrr)r@r r0r�rr}r�r))rFr2r:r;rr!s      r�
test_disabledz$HardlinkDedupTestsBase.test_disabled�s���*.�/�/�*;�&�D�)�Y����	�Y��G��-�-�/�!�-�-�d�3�F�#�F�+�D��$�$�5�$�1��$�$�[��a��$�q�'�%B�C��$�$�[��a��$�q�'�%B�C��$�$�[��a��$�q�'�%B�C�
0�H�G�+<�/�/��H�G�s#�C-�BC!�C-�!C*�&C-�-C6	c��t|�}|jt|d|d�|�|jt|d|d�|xr|�|jt|d|d�|�y)Nrrr)rrzr))rFrr:r;r!s     r�check_hardlinksz&HardlinkDedupTestsBase.check_hardlinks�s����������T�!�W�d�1�g�6�&��	(�����T�!�W�d�1�g�6�&��8�y�=�	:�����T�!�W�d�1�g�6�&��	(rc�8�|j�D]o\}}}|j||��5|j�5|j|�}|j	�|j|||�ddd�ddd��qy#1swY�xYw#1swY��xYw)Nr?)r@r r0r�r}rD)rFr2r:r;rs     rr"z$HardlinkDedupTestsBase.test_hardlinks���*.�/�/�*;�&�D�)�Y����	�Y��G��-�-�/�!�-�-�d�3�F��$�$�&��(�(���I�F�0�H�G�+<�/�/��H�G�s"�B�5B�1B�B
�	B�B	c	�~�dD]�}|j|��5|j�5|j|j��}|j	|��t||d�}t||d�}|j
t||��ddd�ddd���y#1swY�xYw#1swY��xYw)N))rr)rr)rr)�opts�r�rr)r r0r�r=r}rrer))rFrGr�pyc1�pyc2s     r�test_only_two_levelsz+HardlinkDedupTestsBase.test_only_two_levelss���,�D����4��(��-�-�/�"�-�-�d�.>�.>�.@�A�F��$�$�d�$�3�"�6�4��7�3�D�"�6�4��7�3�D��O�O�K��d�$;�<�0�)�(�-�/�/��)�(�s#�B3�A+B'�B3�'B0�,B3�3B<	c��|j�5|j|j��}|jgd���t	|d�}t	|d�}|jt
||��ddd�y#1swYyxYw)N)rrrrrHrr)r0r�r=r}rrer))rFrrIrJs    r�test_duplicated_levelsz-HardlinkDedupTestsBase.test_duplicated_levelsss���
%�
%�
'��%�%�d�&6�&6�&8�9�F����l��3��6�1�%�D��6�1�%�D��O�O�K��d�3�4�(�
'�
'�s�A'B�B
c��|j�5|jd�}|j�|j|�t	|�}tj|d�j}|jd�}|jddgd��|j|tj|d�j�|jt|d|d��|j|tj|d�j�|jtj|d|dd���ddd�y#1swYyxYw)	Nr$r�print(0)rT)r�rrr��shallow)r0r�r}rDrr"r#r$rzrer)r|r��filecmp�cmp�rFrr!�inodes    r�test_recompilationz)HardlinkDedupTestsBase.test_recompilation*s���
%�
%�
'��%�%�g�.�F������ � ��(��F�#�D��G�G�D��G�$�+�+�E��%�%�j�1�F�
���q�!�f�D��9�
���U�B�G�G�D��G�$4�$;�$;�<��O�O�K��Q���a��9�:�����r�w�w�t�A�w�'7�'>�'>�?����W�[�[��a��$�q�'�4�H�I�)(�
'�
'�s�D8E�Ec��|j�5|j|j�d��}|j�|j	|�t|�}t
j|d�j}|jdd��}tjdddd|j�	�|j|t
j|d�j�|j|t
j|d
�j�|jt|d|d
��|jtj |d|d
d�
��ddd�y#1swYyxYw)N�module)r%rrOr�z-cz
import moduleF)r�rirrTrP)r0r�r=r}rDrr"r#r$r
rvr9rzr�r)rRrSrTs    r�test_importz"HardlinkDedupTestsBase.test_importCs4���
%�
%�
'��%�%�d�&6�&6�&8�x�%�H�F������ � ��(��F�#�D��G�G�D��G�$�+�+�E��%�%�j�x�%�@�F�
�*�*��d�O��$�)�)�
�

���U�B�G�G�D��G�$4�$;�$;�<����U�B�G�G�D��G�$4�$;�$;�<����[��a��$�q�'�:�;����W�[�[��a��$�q�'�4�H�I�-(�
'�
'�s�EE3�3E<N)r)FF)rArBrCrHrar#r0r�r}r7r=r@rBrDr"rKrMrVrYrGrrr-r-�sl���������@�$(�)�5�B�<� �3�
D�(�G�=�
5�J�2Jrr-c��eZdZy)�!HardlinkDedupTestsWithSourceEpochNrJrGrrr[r[_rKrr[c��eZdZy)�HardlinkDedupTestsNoSourceEpochNrJrGrrr]r]frKrr]�__main__)8rfrarR�importlib.utilrrcr"rxr7rTrr3�test.test_importlib.utilr�r�rvrr�multiprocessing.utilrr��concurrent.futuresr�concurrent.futures.processrrD�NotImplementedError�ModuleNotFoundErrorr�test.supportr	r
�test.test_py_compilerr�test.support.os_helperr
rrr)r+�TestCaserIrO�skipIf�is_wasirQr`r(r*�hasattrr-r[r]rArrGrr�<module>rms�������	�	��
�
�
�����%�	"�U�6�?��� ���"�&�:�8�+�F�7��N8�N8�b	�%8�%-�%6�%6�/F�7;�	�	�(;�(0�(9�(9�2I�:?�	��������"D�E�4�8�$�$�4�F�4�:zK�zK�z
	�&:�'/�'8�'8�1H�9=�	�	�$8�%-�%6�%6�/F�7<�	�����W�R��(�*<�=�ZJ�ZJ�>�ZJ�z	�(>�(0�(9�(9�2I�:>�	�	�&<�&.�&7�&7�0G�8=�	��z���H�M�M�O���i"	�0�1�"�!��"�s�F(�(	F5�4F5

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