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-2.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�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.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!r8r9r4�bad_source_pathr<r=rDs  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"r:�st_mtime�struct�packrr�MAGIC_NUMBER)rErF�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)rOrOz0filesystem doesn't support timestamps near 2**32�
r!�utimer:�
OverflowError�OSError�skipTest�
contextlib�redirect_stdout�io�StringIO�
assertTrue�
compileall�compile_file�rEs 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)� rkz+filesystem doesn't support large timestampsr[rgs 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�ric���	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 setrL�wbFT��force�quiet)r!�environ�get�unittest�SkipTest�
py_compile�compiler:�assertEqualrYr<r;rP�lenr=�assertNotEqualre�compile_dirr4rd)rE�metadatarF�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)NrNrr)rrSrTrrrUrgs r�
test_mtimezCompileallTestsBase.test_mtimeys.�����f�k�k�'�9�>�>�3N�3N�*+�Q�0�	1rc�&�|jd�y)Ns)rrgs 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)NFTrpr)r;r?r!�unlinkrdrerfr:r8�isfiler|r4rJ�assertFalserI)rE�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!r8r�r;r�captured_stdoutrdrerf�pathlib�Pathr:�assertRegex�getvalue)rE�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)�ddirrr�r�r!r8r�r;rdrerfr�r�r:rgs 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)�stripdirrrr�rgs 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)�
prependdirrrr�rgs 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�r8r�rrFT)�skip_curdirrqrr)
�test�test_importlibr�import_stater4rdre�compile_pathrJr�rgs 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)NrVrFro�__pycache__)
r!r8r9r4rBr<rerfr��exists)rE�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 )	rJr`rarbrcr�rerfrIrgs 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�rr�optimizer)
rer|r4rrrr:rdr!r8r�r>rC)rEr�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!r8r�r;rr�rer|r�r�r4r��
splitlinesr�rd)rEr��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!r8r�r;rdrer|r�r�r4rgs 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�rgs 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��rr�workers�rer|r4rd�called�rE�	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�
ValueErrorrer|r4rgs 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)rer|r4ry�	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�)rer|r4r�r�rd)rE�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�)rEr�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)rr�	maxlevels)r4�ranger!r8r9rBr6r@r:rrrrer|r�r�rd)rE�depthr8�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)Nr��foo�__init__r�modzdef fn(): 1/0
fn()
Trr)rrr�r��")r4r!r8r9rBr
�make_script�appendr5�multiprocessing_cleanup_testsrer|rd�
startswithrrrrz�sep�assert_python_failurer�r��get_code_from_pycry�co_filename�assertIn�fsdecode)rEr�r��fullpathr8�mods�subdirr��modcode�modpath�_�err�expected_in�mod_code_objs              r�_test_ddir_onlyz#CompileallTestsBase._test_ddir_only+s���N��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)N�
<a prefix>F�r�r��rrgs r�test_ddir_only_one_workerz-CompileallTestsBase.test_ddir_only_one_workerHs��K��#�#���#�F�Frc�*�	|jdd��S)NrTrrrgs r�test_ddir_multiple_workersz.CompileallTestsBase.test_ddir_multiple_workersLs��K��#�#���#�E�Erc�*�	|jdd��S)NrFrrrgs r�test_ddir_empty_only_one_workerz3CompileallTestsBase.test_ddir_empty_only_one_workerQs��M��#�#��e�#�<�<rc�*�	|jdd��S)NrTrrrgs 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�realr8r��1 / 0rT)rrr�r/�r!r8r9r4�makedirsr
r�rrrrer|r�r��str�sys�getdefaultencoding�assertNotIn)
rEr�r8rr~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)Nr
r�r�/fooT)rrr�r/)r!r8r9r4rr
r�rrrrer|r�r�rrr)
rEr�r8rr~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)	Nr
r�rrrT)rrr�r�r/r�rEr�r8rr~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�rrr8r�r�rTz/barr)rrr�r�r�)r!r8r9r4rr
r��assertRaisesr�rer|)rEr�r8s   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�r4r�rrrrerfrdr!r8r�r��	Exception)rErr~�	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)rr�
limit_sl_dest)r!r8r9r4rr
r��symlinkrrrrer|rdr�r��
rE�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__rGrJrYrhrlrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�_have_multiprocessingr�patchr�r�r�r�r�r�rrrr	rrrrr"r+r	�skip_unless_symlinkrA�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�rBrCrDrHrrrJrJ����	rrJ)�	metaclass�source_date_epochc��eZdZy)�!CompileallTestsWithoutSourceEpochNrKrHrrrPrP�rLrrPz tempdir is not encodable on WASIc� �eZdZ	d�Zd�Zd�Zy)�EncodingTestc�2�tj�|_tjj|jd�|_t|jdd��5}|jd�|jd�ddd�y#1swYyxYw)Nr,r-r.r/z# -*- coding: utf-8 -*-
u
print u"€"
)	r2r3r4r!r8r9r:r<r=rDs  rrGzEncodingTest.setUp�sp��!�)�)�+����7�7�<�<����
�C���
�$�"�"�C�'�
:�	,�d��J�J�2�3��J�J�*�+�	,�	,�	,�s�!#B
�
Bc�B�tj|j�yr )r6r7r4rgs r�tearDownzEncodingTest.tearDown�s���
�
�d�n�n�%rc��	tj}tjtj�d��t_tj|j�|t_y#t_wxYw)N�asciir/)rr�rb�
TextIOWrapper�BytesIOrer|r4)rE�orig_stdouts  r�
test_errorzEncodingTest.test_error�sK��	%��*�*�K��)�)�"�*�*�,��H�C�J��"�"�4�>�>�2�$�C�J���C�J�s�A!A/�/
A<N)rBrCrDrGrUr[rHrrrRrR�s���,�&�%rrRc�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)r2r3r4r5r	r7r!r8r9�pkgdirrB�pkgdir_cachedirr
r��initfn�barfnrgs rrGzCommandLineTestsBase.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!r8r9r4)rE�
old_prefix�
new_prefixs   r�temporary_pycache_prefixz-CommandLineTestsBase.temporary_pycache_prefix�s_����4��'�'�
��W�W�\�\�$�.�.�/�B�
�	,�!+�C��"�n�n�'1��
�
",�C����C��s�<A7�A'�A7�'
A4�4A7c�>�gtj��d�d�d�|�S)Nz-S�-mre)r�!optim_args_from_interpreter_flags)rE�argss  r�
_get_run_argsz"CommandLineTestsBase._get_run_args
s<����:�:�<������(����	rc��tj|j|�i|�ddi��\}}}|jd|�|S)N�PYTHONIOENCODINGr.r)r
�assert_python_okrpry�rEro�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)Nrrr.)r
r�rprts      r�assertRunNotOKz#CommandLineTestsBase.assertRunNotOKsD��$�:�:��+�+�D�1�2�5=�2�)0�2���C���3��|�rc��tjj|�}|jtj
j
|��yr )rrrrdr!r8r��rEr�r8s   r�assertCompiledz#CommandLineTestsBase.assertCompileds/���~�~�/�/��3����������t�,�-rc��tjj|�}|jtj
j
|��yr )rrrr�r!r8r�rzs   r�assertNotCompiledz&CommandLineTestsBase.assertNotCompiled s1���~�~�/�/��3�����������-�.rc�B�tj|jdd�}|j�5}|jdi|��|j|�|j
|j�|j
|j�ddd�y#1swYyxYw)N�bazrrH)	r
r�r4rkrvr{r}rbrc)rE�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)Nrr�<rrH)�-f)r
r�r4rkrvrrrr!r\�timer"rRryr{)rEr�r��pycpathrW�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)NrrsListing rH)�-q)r
r�r4rkrvr�r)rEr��noisyrrs    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)Nrmrer�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
rsr`rdr!r8r�ra�sortedry�listdirr��endswith)rEr��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)
rvr`r�r!r8r�rar�ryr�)rEr�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�)	rvr`rdr!r8r�rar9r�)rE�
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�)
rvr`rrrrcr!r\r�r"rRryr{)rEr�rWr�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!r8r9r`rBr
r�rvr}r�r�r{)rE�
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!r8r9r`r
�make_pkgr�rvr}r�r�r{)	rEr��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!r8r9r`r
r�r6rvr{)rEr�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)rvr`r{ry)rEr�rrs   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�r`rxr{ry)rEr�rr�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[^\\/]*$)rvr`r}rcr{rbrgs 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!r8r9r4rBr
r�rvr`r{rbrc)rE�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�r`rxr��rErrr�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)Nrzraise Exceptionr�r�r��bingz
import bazzbaz.pycF)�
__isolatedr�)r
r�r`rvrrrr!�renamer8r9�remover�r�)rEr�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)rxr!r8r9r4r`r��assertNotRegexr�r�rrrrar�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�r`r<r!r8r9r4r=�lineseprvr{r}�rEr�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�r`r<r!r8r9r4r=r�rvr}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�rHr��-rW)
r
r�r`�spawn_pythonrp�stdinr=r!r��encode�kill_pythonr}r{)rEr�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�r`rxrbrcr�r}r{)rE�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')rvr�)rErs  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-hashrL���littler�z"--invalidation-mode=unchecked-hashr)r
r�r`rrrr!r8r9rvr<rPryrQ�
from_bytes)rEr��fprVs    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�r4r�r!r8r9r�rBr�rvr{)rEr��files�suffixr`r�rFs       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)rrFr�
executabler4re�mainrdr�ryr�)rEr|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)	Nr
r�rrrz-sz-pr/)r!r8r9r4rr
r�rrrrvr�r�rrrrrs           rrz+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!r8r9r4rr
r�r�rrrrvrdr�rQr�r')rEr8rr~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-r.r/r0r1r%r2r3r4z-e)r!r8r9r4rr
r�r6rrrrvrdr�r�r7s
          rrAz4CommandLineTestsBase.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)rxr4rgs 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)
r2�TemporaryDirectory�subTestr
r�rr�rvryr()rErr8r�pycsros      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)7rBrCrDrGr`�contextmanagerrkrprvrxr{r}r�rr�requires_resourcer�r��namer�r�r��localsr�r�r�r�r�r	rGr�r�r�r�r�r�r�r�r�r�r�r�r�rrrErrrFrrr+rArrrHrrr]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)�CommandLineTestsWithSourceEpochNrKrHrrr%r%�rLrr%c��eZdZy)�CommandLineTestsNoSourceEpochNrKrHrrr'r'�rLrr'�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�rgs rrGzHardlinkDedupTestsBase.setUp�s	����	rc#�K�tj�5}||_|��d|_ddd�y#1swYyxYw�wr )r2rr8)rEr8s  r�temporary_directoryz*HardlinkDedupTestsBase.temporary_directory�s;����
�
(�
(�
*�	�d��D�I��J��D�I�	�	�	�s�?�3�	?�<�?c�D�tj|j||�Sr )r
r�r8)rE�coder"s   rr�z"HardlinkDedupTestsBase.make_script�s���(�(����D�$�?�?rTrF)rr�rqc�L�tj|jd|||��y)NT)rrr��hardlink_dupesrq)rer|r8)rErr�rqs    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)rrr�r1)r-r�r!r�rer|r8rgs 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�r9)rE�	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�r7r8)r:)rEr7r8r/s    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=rr-r�rr|r�r()rEr/r7r8rrs      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)rryr()rErr7r8rs     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=rr-r�r|rA)rEr/r7r8rs     rrz$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)rr-r�r:r|rrdr()rErDr�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)rrrrrErr)r-r�r:r|rrdr()rErrFrGs    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�rqr��shallow)r-r�r|rArr!r"r#ryrdr(r{r��filecmp�cmp�rErr�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"rrLr�z-cz
import moduleF)r�rfrrTrM)r-r�r:r|rArr!r"r#r
rsr8ryr�r(rOrPrQs    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)rBrCrDrGr`r r-r�r|r4r:r=r?rArrHrJrSrVrHrrr*r*�sl���������@�$(�)�5�B�<� �3�
D�(�G�=�
5�J�2Jrr*c��eZdZy)�!HardlinkDedupTestsWithSourceEpochNrKrHrrrXrXYrLrrXc��eZdZy)�HardlinkDedupTestsNoSourceEpochNrKrHrrrZrZ`rLrrZ�__main__)7rer`rO�importlib.utilrrbr!r�rwr6rSrr2�test.test_importlib.utilr�r�rurr�multiprocessing.utilrr��concurrent.futuresr�concurrent.futures.processrrE�NotImplementedError�ModuleNotFoundErrorr�test.supportr	r
�test.test_py_compilerrrrr(r*�TestCaserJrP�skipIf�is_wasirRr]r%r'�hasattrr*rXrZrBrrHrr�<module>ris�������	�	���
�
�
�����%�	"�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