HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_compileall.cpython-312.opt-1.pyc
�

~h�e���l�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlmZmZ	ddlmZddlmZddlmZe�dZddlmZdd	lmZdd
lm Z ddl!m"Z"ddl!m#Z#d
�Z$d�Z%d�Z&Gd�d�Z'Gd�de'ejPe#d��Z)Gd�de'ejPe#d��Z*ejVejXd�Gd�dejP��Z-Gd�d�Z.Gd�de.ejPe#d��Z/Gd�de.ejPe#d��Z0ej$e1ed �d!�Gd"�d#��Z2Gd$�d%e2ejPe#d��Z3Gd&�d'e2ejPe#d��Z4e5d(k(rejl�yy#eef$rdZY��QwxYw))�N)�mock�
skipUnless)�_cleanup_tests)�ProcessPoolExecutor)�_check_system_limitsTF)�support)�	os_helper)�
script_helper)�without_source_date_epoch)�SourceDateEpochTestMetac�L�|sd}tjj||��S)N���optimization)�	importlib�util�cache_from_source��script�opts  �;/opt/alt/python312/lib64/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�S�G�F�C� �6�6��6s�c��tj|�j}tj|�j}||k(S)z8Returns True if two files have the same inode (hardlink))�os�stat�st_ino)�	filename1�	filename2�inode1�inode2s    r�is_hardlinkr'/s5��
�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.setUp8sI��!�)�)�+�������
�
�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-r.zx (
)r r7r8r3�bad_source_pathr;r<rCs  r�add_bad_source_filez'CompileallTestsBase.add_bad_source_fileHsR��!�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!r9�st_mtime�struct�packrr�MAGIC_NUMBER)rDrE�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)rNrNz0filesystem doesn't support timestamps near 2**32�
r �utimer9�
OverflowError�OSError�skipTest�
contextlib�redirect_stdout�io�StringIO�
assertTrue�
compileall�compile_file�rDs r� test_year_2038_mtime_compilationz4CompileallTestsBase.test_year_2038_mtime_compilationUs���	N��H�H�T�%�%�'=�>��
'�
'����
�
6�	G��O�O�J�3�3�D�4D�4D�E�F�	G�	G���w�'�	N��M�M�L�M�	N��	G�	G��� B�	/B'� B$�#B$�'B0c�f�	tj|jd�t
jtj��5|jtj|j��ddd�y#ttf$r|jd�Y��wxYw#1swYyxYw)N)� rjz+filesystem doesn't support large timestampsrZrfs r�test_larger_than_32_bit_timesz1CompileallTestsBase.test_larger_than_32_bit_times_s���	I��H�H�T�%�%�~�6��
'�
'����
�
6�	G��O�O�J�3�3�D�4D�4D�E�F�	G�	G���w�'�	I��M�M�G�H�	I��	G�	G�rhc���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)	zOCheck that compileall recreates bytecode when the new metadata is
        used.�SOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setrKN�wbFT��force�quiet)r �environ�get�unittest�SkipTest�
py_compile�compiler9�assertEqualrXr;r:rO�lenr<�assertNotEqualrd�compile_dirr3rc)rD�metadatarE�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�Ec��|jtjdtjj
dd��y)NrMrr)r~rRrSrrrTrfs r�
test_mtimezCompileallTestsBase.test_mtimeys.�����f�k�k�'�9�>�>�3N�3N�*+�Q�0�	1rc�&�|jd�y)Ns)r~rfs 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)NFTror)r:r>r �unlinkrcrdrer9r7�isfiler{r3rI�assertFalserH)rD�fns  r�test_compile_filesz&CompileallTestsBase.test_compile_files�s����<�<����/�	�B�
��	�	�"�
�	�
	
���
�/�/��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}|jtjtj|j���ddd�|jj�d�|jtjj|j��y#1swY�bxYw)Nz&Compiling ([^WindowsPath|PosixPath].*))r�r r7r�r:r�captured_stdoutrcrdre�pathlib�Pathr9�assertRegex�getvalue)rD�stdouts  r�test_compile_file_pathlikez.CompileallTestsBase.test_compile_file_pathlike�s��������������5�6�
�
$�
$�
&�	U�&��O�O�J�3�3�G�L�L��AQ�AQ�4R�S�T�	U�������*�,U�V���������t�|�|�4�5�	U�	U�s
�
AC0�0C9c��|jtjj|j��|jt
jtj|j�tjd�d���|jtjj|j��y)N�	ddir_pathr)�ddirrq�r�r r7r�r:rcrdrer�r�r9rfs r�test_compile_file_pathlike_ddirz3CompileallTestsBase.test_compile_file_pathlike_ddir�sy�������������5�6����
�/�/����T�=M�=M�0N�5<�\�\�+�5N�67�9�	:�	
��������t�|�|�4�5rc��|jtjj|j��|jt
jtj|j�tjd�d���|jtjj|j��y�N�
stripdir_pathr)�stripdirrqr�rfs r�#test_compile_file_pathlike_stripdirz7CompileallTestsBase.test_compile_file_pathlike_stripdir�sy�������������5�6����
�/�/����T�=M�=M�0N�9@���o�9V�67�9�	:�	
��������t�|�|�4�5rc��|jtjj|j��|jt
jtj|j�tjd�d���|jtjj|j��y�N�prependdir_pathr)�
prependdirrqr�rfs r�%test_compile_file_pathlike_prependdirz9CompileallTestsBase.test_compile_file_pathlike_prependdir�sz�������������5�6����
�/�/����T�=M�=M�0N�;B�<�<�HY�;Z�67�9�	:�	
��������t�|�|�4�5rc���tjjj|jg��5|jt
jd���ddd�tjjj|jg��5|j�|jt
jddd���ddd�y#1swY�xYw#1swYyxYw)N�r7r�rqFT)�skip_curdirrprq)
�test�test_importlibr�import_stater3rcrd�compile_pathrIr�rfs r�test_compile_pathz%CompileallTestsBase.test_compile_path�s���
�
 �
 �
%�
%�
2�
2����8H�
2�
I�	>��O�O�J�3�3�!�<�=�	>��
 �
 �
%�
%�
2�
2����8H�
2�
I�	K��$�$�&����Z�4�4��;?�q�J�
K�	K�	K�	>�	>��	K�	K�s�&C�8C&�C#�&C/c���tjj|jd�}tjj|d�}tj|�t|d�5	ddd�t
j|�|jtjjtjj|d���y#1swY�kxYw)NrUrErn�__pycache__)
r r7r8r3rAr;rdrer��exists)rD�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#1swYyxYw�N)	rIr_r`rarbr�rdrerHrfs r�#test_compile_file_encoding_fallbackz7CompileallTestsBase.test_compile_file_encoding_fallback�sZ��� � �"�
�
'�
'����
�
6�	L����Z�4�4�T�5I�5I�J�K�	L�	L�	L�s�/A0�0A9c�h�d\}}tj|jd|��tjj|j|��}|jtjj|��tjj|j|��}|jtjj|��tjj|j|��}|jtjj|��y)N)rrT�rq�optimizer)
rdr{r3rrrr9rcr r7r�r=rB)rDr�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}tjtj|j��ddd�j�j�d}|j|d�|jtjj|j��y#1swY�uxYw)Nrz$Listing ([^WindowsPath|PosixPath].*))r�r r7r�r:rr�rdr{r�r�r3r��
splitlinesr�rc)rDr��lines   r�test_compile_dir_pathlikez-CompileallTestsBase.test_compile_dir_pathlike�s��������������5�6�
�
$�
$�
&�	A�&��"�"�7�<�<����#?�@�	A���� �+�+�-�a�0������F�G���������t�|�|�4�5�		A�	A�s�
3C4�4C=c��|jtjj|j��|jt
jtj|j�tjd�d���|jtjj|j��yr��r�r r7r�r:rcrdr{r�r�r3rfs r�"test_compile_dir_pathlike_stripdirz6CompileallTestsBase.test_compile_dir_pathlike_stripdir�sw�������������5�6����
�.�.�w�|�|�D�N�N�/K�8?���_�8U�56�8�	9�	
��������t�|�|�4�5rc��|jtjj|j��|jt
jtj|j�tjd�d���|jtjj|j��yr�r�rfs r�$test_compile_dir_pathlike_prependdirz8CompileallTestsBase.test_compile_dir_pathlike_prependdir�sx�������������5�6����
�.�.�w�|�|�D�N�N�/K�:A�,�,�GX�:Y�56�8�	9�	
��������t�|�|�4�5r�requires multiprocessingz&concurrent.futures.ProcessPoolExecutorc�~�tj|jdd��|j|j�y�NT��rq�workers�rdr{r3rc�called�rD�	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�
ValueErrorrdr{r3rfs r�!test_compile_workers_non_positivez5CompileallTestsBase.test_compile_workers_non_positives?��
�
#�
#�J�$K�M�	?��"�"�4�>�>�2�>�	?�	?�	?�s�"A�Ac��tj|jdd��|j|jddd�y)NTrr�r�max_workers)rdr{r3rx�	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�)rdr{r3r�r�rc)rD�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�)rDr�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)rq�	maxlevels)r3�ranger r7r8rAr5r?r9rrrrdr{r�r�rc)rD�depthr7�i�source�pyc_filenames      r�test_compile_dir_maxlevelsz.CompileallTestsBase.test_compile_dir_maxlevelss������~�~���q�%�!�)�$�	6�A��7�7�<�<���Q�C�j�1�D��W�W�\�\�$��4�F��H�H�T�N��O�O�D�,�,�f�5�		6�
!�~�~�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)
z@Recursive compile_dir ddir must contain package paths; bpo39769.r��foo�__init__r�modzdef fn(): 1/0
fn()
Trr)rqr�r�N�")r3r r7r8rAr
�make_script�appendr4�multiprocessing_cleanup_testsrdr{rc�
startswithrrrry�sep�assert_python_failurer�r��get_code_from_pycrx�co_filename�assertIn�fsdecode)rDr�r��fullpathr7�mods�subdirr��modcode�modpath�_�err�expected_in�mod_code_objs              r�_test_ddir_onlyz#CompileallTestsBase._test_ddir_only+s����E�?���~�~�����	L�F��7�7�<�<��f�-�D��H�H�T�N��%�%�d�J��;��K�K�
�1�1�$��2I�K�
L�		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)�=Recursive compile_dir ddir= contains package paths; bpo39769.�
<a prefix>F�r�r��rrfs r�test_ddir_only_one_workerz-CompileallTestsBase.test_ddir_only_one_workerHs���#�#���#�F�Frc�(�|jdd��S)rrTrrrfs r�test_ddir_multiple_workersz.CompileallTestsBase.test_ddir_multiple_workersLs���#�#���#�E�Erc�(�|jdd��S)�?Recursive compile_dir ddir='' contains package paths; bpo39769.rFrrrfs r�test_ddir_empty_only_one_workerz3CompileallTestsBase.test_ddir_empty_only_one_workerQs���#�#��e�#�<�<rc�(�|jdd��S)r
rTrrrfs r� test_ddir_empty_multiple_workersz4CompileallTestsBase.test_ddir_empty_multiple_workersUs���#�#��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�realr7r��1 / 0rT)rqr�r.�r r7r8r3�makedirsr
r�rrrrdr{r�r��str�sys�getdefaultencoding�assertNotIn)
rDr�r7rr}r��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)Nrr�r�/fooT)rqr�r.)r r7r8r3rr
r�rrrrdr{r�r�rrr)
rDr�r7rr}r�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)	Nrr�rrrT)rqr�r�r.r�rDr�r7rr}r�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�rrr7r�r�rTz/barr)rqr�r�r�)r r7r8r3rr
r��assertRaisesr�rdr{)rDr�r7s   r�test_strip_prepend_and_ddirz/CompileallTestsBase.test_strip_prepend_and_ddir�s���<���w�w�|�|�D�N�N�6�X�6��
���D���!�!�$���8�
�
�
�z�
*�	G��"�"�4�t�&�,2�v�
G�	G�	G�	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�r3r�rrrrdrercr r7r�r��	Exception)rDrr}�	opt_level�test_combinations�opt_combinations      r�!test_multiple_optimization_levelsz5CompileallTestsBase.test_multiple_optimization_levels�s����*�*�4�>�>�+>�+2�4����$�	P�I��I�I�i�n�n�6�6�v�DM�7�O�
P�	P� ��V�a��V�a��V�Y�?��0�	�O��#�#�F�$�-<�
>�,�
�	���������r�)�}� =�>���I�I�b��m�,�
�	��!����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)rq�
limit_sl_dest)r r7r8r3rr
r��symlinkrrrrdr{rcr�r��
rD�allowed_path�
symlinks_path�prohibited_path�allowed_script�prohibited_script�allowed_symlink�prohibited_symlink�
allowed_bc�
prohibited_bcs
          r�test_ignore_symlink_destinationz3CompileallTestsBase.test_ignore_symlink_destination�sb���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__rFrIrXrgrkr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�_have_multiprocessingr�patchr�r�r�r�r�r�rrrrr
rrr!r$r-r	�skip_unless_symlinkrC�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�rDrErFrJrrrLrL����	rrL)�	metaclass�source_date_epochc��eZdZy)�!CompileallTestsWithoutSourceEpochNrMrJrrrRrR�rNrrRz tempdir is not encodable on WASIc�"�eZdZdZd�Zd�Zd�Zy)�EncodingTestzTIssue 6716: compileall should escape source code when printing errors
    to stdout.c�2�tj�|_tjj|jd�|_t|jdd��5}|jd�|jd�ddd�y#1swYyxYw)Nr+r,r-r.z# -*- coding: utf-8 -*-
u
print u"€"
)	r1r2r3r r7r8r9r;r<rCs  rrFzEncodingTest.setUp�sp��!�)�)�+����7�7�<�<����
�C���
�$�"�"�C�'�
:�	,�d��J�J�2�3��J�J�*�+�	,�	,�	,�s�!#B
�
Bc�B�tj|j�yr�)r5r6r3rfs r�tearDownzEncodingTest.tearDown�s���
�
�d�n�n�%rc��	tj}tjtj�d��t_tj|j�|t_y#t_wxYw)N�asciir.)rr�ra�
TextIOWrapper�BytesIOrdr{r3)rD�orig_stdouts  r�
test_errorzEncodingTest.test_error�sK��	%��*�*�K��)�)�"�*�*�,��H�C�J��"�"�4�>�>�2�$�C�J���C�J�s�A!A/�/
A<N)rDrErF�__doc__rFrWr]rJrrrTrT�s���,�&�%rrTc�D�eZdZdZd�Zejd��Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
eej d
�d���Zej d
�d��Zd
dgfdddgfdddgffD]\ZZZeefd�Zee�dez<�d�Zd�Zed��Zd�Zd�Zej<d��Zd�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d(�Z+d)�Z,e-e.d*�d+��Z/e0jbd,�d-��Z2d.�Z3d/�Z4ej<d0��Z5d1�Z6d2�Z7y3)4�CommandLineTestsBasezTest compileall's CLI.c��tj�|_|jtj
|j�tjj|jd�|_	t
j|j�tjj|jd�|_tj|jdd�|_tj|jdd�|_y)Nr�r�r�r�bar)r1r2r3r4r	r6r r7r8�pkgdirrA�pkgdir_cachedirr
r��initfn�barfnrfs rrFzCommandLineTestsBase.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)z&Adjust and restore sys.pycache_prefix.�
__testcache__)�
PYTHONPATH�PYTHONPYCACHEPREFIXN)r�pycache_prefixr r7r8r3)rD�
old_prefix�
new_prefixs   r�temporary_pycache_prefixz-CommandLineTestsBase.temporary_pycache_prefix�s^�����'�'�
��W�W�\�\�$�.�.�/�B�
�	,�!+�C��"�n�n�'1��
�
",�C����C��s�;A6�A&�A6�&
A3�3A6c�>�gtj��d�d�d�|�S)Nz-S�-mrd)r�!optim_args_from_interpreter_flags)rD�argss  r�
_get_run_argsz"CommandLineTestsBase._get_run_args
s<����:�:�<������(����	rc��tj|j|�i|�ddi��\}}}|jd|�|S)N�PYTHONIOENCODINGr-r)r
�assert_python_okrsrx�rDrr�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�)rrrrcr r7r��rDr�r7s   r�assertCompiledz#CommandLineTestsBase.assertCompileds/���~�~�/�/��3����������t�,�-rc��tjj|�}|jtj
j
|��yr�)rrrr�r r7r�r}s   r�assertNotCompiledz&CommandLineTestsBase.assertNotCompiled s1���~�~�/�/��3�����������-�.rc�B�tj|jdd�}|j�5}|jdi|��|j|�|j
|j�|j
|j�ddd�y#1swYyxYw)N�bazrrJ)	r
r�r3rnryr~r�rerf)rD�bazfn�envs   r�test_no_args_compiles_pathz/CommandLineTestsBase.test_no_args_compiles_path$s����)�)�$�.�.�%��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�<rrJ)�-f)r
r�r3rnryrrrr r[�timer!rQrxrz)rDr�r��pycpathrV�mtime2s      r� test_no_args_respects_force_flagz5CommandLineTestsBase.test_no_args_respects_force_flag-s
���)�)�$�.�.�%��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 rJ)�-q)r
r�r3rnryr�r)rDr��noisyrqs    r� test_no_args_respects_quiet_flagz5CommandLineTestsBase.test_no_args_respects_quiet_flag@s����!�!�$�.�.�%��<�
�
*�
*�
,�	,��$�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)Nrprdr�c3�r�K�|].}|jtjj�����0y�wr�)�formatr�implementation�	cache_tag)�.0�base�exts  �r�	<genexpr>z)CommandLineTestsBase.f.<locals>.<genexpr>Us2�����K�"&�#�k�k�#�*<�*<�*F�*F��L�K�s�47)z__init__.{}.{}z	bar.{}.{})
r
rvrcrcr r7r�rd�sortedrx�listdirr��endswith)rDr��switch�expectedr�s `   r�fzCommandLineTestsBase.fPs�����*�*�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�R�!#���S�!1�!�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 r7r�rdr�rxr�)rDr�s  r�test_legacy_pathsz&CommandLineTestsBase.test_legacy_paths]sl��	
����t�T�[�[�1����������(<�(<�=�>��&�'�������
�
�4�;�;� 7�8�(�Crc�`�|jd|j�|jtjj|j��tjj|jd�}|jtjj|��|jd|j�|jtjj|j��|jtjj|��y)Nr�r�)	ryrcrcr r7r�rdr8r�)rD�
cachecachedirs  r�test_multiple_runsz'CommandLineTestsBase.test_multiple_runsgs���	
����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!rQrxrz)rDr�rVr�s    r�
test_forcezCommandLineTestsBase.test_forcets�������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 r7r8rcrAr
r�ryr�r�r�r~)rD�
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 r7r8rcr
�make_pkgr�ryr�r�r�r~)	rDr��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 r7r8rcr
r�r8ryr~)rDr�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)ryrcrzrx)rDr�rqs   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{rzrx)rDr�rq�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~rerfs 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 r7r8r3rAr
r�ryrcr~rerf)rD�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��rDrrr�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 �renamer7r8�remover�r�)rDr�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 r7r8r3rcr��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-r.�f1.py�f2.pyr�)
r
r�rcr;r r7r8r3r<�linesepryr~r��rDr�r�r�r�r�s      r�test_include_file_with_argz/CommandLineTestsBase.test_include_file_with_arg�sL��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�
&�
&�t�{�{�D�"�
=��
�"�'�'�,�,�t�~�~�t�4�c�G�
L�	D�PR��H�H�R�W�W�\�\�$�+�+�w�7��
�
�B�C��H�H�R�W�W�\�\�$�+�+�w�7��
�
�B�C�	D�	
����r�w�w�|�|�D�N�N�D�A�2�F����B�����B�����r�"����B��	D�	D�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-r.r�r�)
r
r�rcr;r r7r8r3r<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�	D�PR��H�H�R�W�W�\�\�$�+�+�w�7��
�
�B�C�	D�����r�w�w�|�|�D�N�N�D�A�B����r�"����B�����r�"����r�"�
	D�	D�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�rJr��-rY)
r
r�rc�spawn_pythonrs�stdinr<r r��encode�kill_pythonr�r~)rDr�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~)rD�bingfnrrr�s     r�!test_compiles_as_much_as_possiblez6CommandLineTestsBase.test_compiles_as_much_as_possibles����*�*�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�)rDrs  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-hashrK���littler�z"--invalidation-mode=unchecked-hashr)r
r�rcrrrr r7r8ryr;rOrxrP�
from_bytes)rDr��fprUs    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�r3r�r r7r8r�rAr�ryr~)rDr��files�suffixrcr�rEs       r�test_workersz!CommandLineTestsBase.test_workers6s����*�*�4�>�>�6�2�F�����A�h�	H�F��W�W�\�\�$�.�.�'�.�.��2H�I�F��H�H�V���*�*�6�:�r�B�B��L�L��2�2�6�6�2�F�G�		H�	
�������s�3����F�#��	&�D�����%�	&rzcompileall.compile_dirc�4�tjdtj|jdg��5tj�|j|j�|j|jddd�ddd�y#1swYyxYw)Nzsys.argvz-j0r�r�r�r)rrHr�
executabler3rd�mainrcr�rxr�)rDr{s  r�test_workers_available_coresz1CommandLineTestsBase.test_workers_available_coresEsx��
�Z�Z�
� �^�^�T�^�^�U�C�E�	F��O�O���O�O�K�.�.�/����[�2�2�2�6�y�A�1�E�		F�	F�	F�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)	Nrr�rrrz-sz-pr.)r r7r8r3rr
r�rrrryr�r�rrrrr s           rr!z+CommandLineTestsBase.test_strip_and_prependMs
��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>ps����$L�q�T�C��F�]�$L�s�)r r7r8r3rr
r�r�rrrryrcr�rPr�r))rDr7rr}r*r+r,s       rr-z6CommandLineTestsBase.test_multiple_optimization_levelsas'���w�w�|�|�D�N�N�O�<��
���D���*�*�4�+>�+2�4����$�	P�I��I�I�i�n�n�6�6�v�DM�7�O�
P�	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�,�
�	��!����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/r0r1r2r3r'r4r5r6z-e)r r7r8r3rr
r�r8rrrryrcr�r�r9s
          rrCz4CommandLineTestsBase.test_ignore_symlink_destinationxsb���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{r3rfs 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)
r1�TemporaryDirectory�subTestr
r�rr�ryrxr')rDrr7r�pycsrrs      r�
test_hardlinkz"CommandLineTestsBase.test_hardlink�s��#�
	K�E��,�,�.�
K�$��\�\��\�.�K�*�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�K�
K�
K�
	K�K�K��
K�
K�s#�C?�B3C3� C?�3C<�8C?�?D		N)8rDrErFr^rFr_�contextmanagerrnrsryr{r~r�r�rr�requires_resourcer�r��namer�r�r��localsr�r�r�r�r�r	rIr�r�r�r�r�r�r�r�r�r�r�r�r�rrrGrrrHrr!r-rCrr"rJrrr`r`�s��� �G����,��,��
��.�/�/���W���u�%�+�&��+�"�W���u�%�-�&�-�
�5�"��	�[�4�&�)�	�;���0��3���c�6�
�F�
	4�23���&��-�.�!3�$D�8��
+��
+�
#� #�D�"�"��#��%�&�)�
	$�1�
1�D� �#�#�(�;�D��%�'A�B�&�C�&��T�Z�Z�(�)�F�*�F�
�(�.�"�"�8�#�8�0H�
Krr`c��eZdZy)�CommandLineTestsWithSourceEpochNrMrJrrr(r(�rNrr(c��eZdZy)�CommandLineTestsNoSourceEpochNrMrJrrr*r*�rNrr*�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�rfs rrFzHardlinkDedupTestsBase.setUp�s	����	rc#�K�tj�5}||_|��d|_ddd�y#1swYyxYw�wr�)r1rr7)rDr7s  r�temporary_directoryz*HardlinkDedupTestsBase.temporary_directory�s;����
�
(�
(�
*�	�d��D�I��J��D�I�	�	�	�s�?�3�	?�<�?c�D�tj|j||�Sr�)r
r�r7)rD�coder%s   rr�z"HardlinkDedupTestsBase.make_script�s���(�(����D�$�?�?rTrF)rr�rpc�L�tj|jd|||��y)NT)rqr��hardlink_dupesrp)rdr{r7)rDrr�rps    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)rqr�r4)r0r�r#r�rdr{r7rfs 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�r8)rD�	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=)rDr:r;r2s    r�
iter_codesz!HardlinkDedupTestsBase.iter_codes�sF����&�	3�I�*�
3�	��'�'�)�y�'�Q���Y�	�2�2�
3�	3�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')rDr2r:r;rr!s      r�
test_disabledz$HardlinkDedupTestsBase.test_disabled�s���*.�/�/�*;�	D�&�D�)�Y����	�Y��G�
D��-�-�/�D�!�-�-�d�3�F�#�F�+�D��$�$�5�$�1��$�$�[��a��$�q�'�%B�C��$�$�[��a��$�q�'�%B�C��$�$�[��a��$�q�'�%B�C�
D�
D�
D�	D�D�D��
D�
D�s#�C-�BC!�C-�!C*�&C-�-C6	c��t|�}|jt|d|d�|�|jt|d|d�|xr|�|jt|d|d�|�y)Nrrr)rrxr')rDrr: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)rDr2r:r;rs     rr"z$HardlinkDedupTestsBase.test_hardlinks���*.�/�/�*;�	G�&�D�)�Y����	�Y��G�
G��-�-�/�G�!�-�-�d�3�F��$�$�&��(�(���I�F�G�
G�
G�	G�G�G��
G�
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{rrcr')rDrGr�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�$;�<�=�
=�
=�		=�=�=��
=�
=�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{rrcr')rDrrIrJs    r�test_duplicated_levelsz-HardlinkDedupTestsBase.test_duplicated_levelss|���
%�
%�
'�	5��%�%�d�&6�&6�&8�9�F����l��3��6�1�%�D��6�1�%�D��O�O�K��d�3�4�	5�	5�	5�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�rpr��shallow)r0r�r{rDrr r!r"rxrcr'rzr��filecmp�cmp�rDrr!�inodes    r�test_recompilationz)HardlinkDedupTestsBase.test_recompilation$s&���
%�
%�
'�	J��%�%�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�)	J�	J�	J�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
rvr7rxr�r'rRrSrTs    r�test_importz"HardlinkDedupTestsBase.test_import=sA���
%�
%�
'�	J��%�%�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�-	J�	J�	J�s�EE3�3E<N)r)FF)rDrErFrFr_r#r0r�r{r7r=r@rBrDr"rKrMrVrYrJrrr-r-�sl���������@�$(�)�5�B�<� �3�
D�(�G�=�
5�J�2Jrr-c��eZdZy)�!HardlinkDedupTestsWithSourceEpochNrMrJrrr[r[YrNrr[c��eZdZy)�HardlinkDedupTestsNoSourceEpochNrMrJrrr]r]`rNrr]�__main__)7rdr_rR�importlib.utilrrar r�rvr5rRrr1�test.test_importlib.utilr�r�rtrr�multiprocessing.utilrr��concurrent.futuresr�concurrent.futures.processrrG�NotImplementedError�ModuleNotFoundErrorr�test.supportr	r
�test.test_py_compilerrrrr'r)�TestCaserLrR�skipIf�is_wasirTr`r(r*�hasattrr-r[r]rDrrJrr�<module>rls�������	�	���
�
�
�����%�	"�U�6�?��� ���"�&�:�8�F�7��N8�N8�b	�%8�%-�%6�%6�/F�7;�	�	�(;�(0�(9�(9�2I�:?�	��������"D�E�%�8�$�$�%�F�%�.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���["	�0�1�"�!��"�s�F&�&	F3�2F3