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-1.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)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.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.r/zx (
)r!r8r9r4�bad_source_pathr<r=rDs  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)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��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)� 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��O�O�J�3�3�D�4D�4D�E�F�7�
6���w�'�	I��M�M�G�H�	I��
6�
6�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)	zOCheck that compileall recreates bytecode when the new metadata is
        used.�SOURCE_DATE_EPOCHzSOURCE_DATE_EPOCH is setrLN�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�Ec��|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@�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!r8r�r;r�captured_stdoutrdrerfr
r:�assertRegex�getvalue)rE�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)�ddirrr�
r�r!r8r�r;rdrerfr
r:rgs 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)�stripdirrrr�rgs 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)�
prependdirrrr�rgs 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�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�!�<�=�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)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#1swYyxYw�N)	rJr`rarbrcr�rerfrIrgs 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�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}tjt|j��ddd�j�j�d}|j|d�|jtjj|j��y#1swY�uxYw)Nrz$Listing ([^WindowsPath|PosixPath].*))r�r!r8r�r;rr�rer|r
r4r��
splitlinesr�rd)rEr��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!r8r�r;rdrer|r
r4rgs 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�rgs 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��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�>�M�M�M�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�%�!�)�$�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)
z@Recursive compile_dir ddir must contain package paths; bpo39769.r��foo�__init__r�modzdef fn(): 1/0
fn()
Trr)rrr�r�N�")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����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)�=Recursive compile_dir ddir= contains package paths; bpo39769.�
<a prefix>F�r�r��r�rgs r�test_ddir_only_one_workerz-CompileallTestsBase.test_ddir_only_one_workerHs���#�#���#�F�Frc�(�|jdd��S)rrTrrrgs r�test_ddir_multiple_workersz.CompileallTestsBase.test_ddir_multiple_workersLs���#�#���#�E�Erc�(�|jdd��S)�?Recursive compile_dir ddir='' contains package paths; bpo39769.rFrrrgs r�test_ddir_empty_only_one_workerz3CompileallTestsBase.test_ddir_empty_only_one_workerQs���#�#��e�#�<�<rc�(�|jdd��S)r	rTrrrgs 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�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)Nrr�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)	Nrr�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�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�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����$�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)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�r�rrr
rrrr r#r,r	�skip_unless_symlinkrB�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�rCrDrErIrrrKrK����	rrK)�	metaclass�source_date_epochc��eZdZy)�!CompileallTestsWithoutSourceEpochNrLrIrrrQrQ�rMrrQz tempdir is not encodable on WASIc�"�eZdZdZd�Zd�Zd�Zy)�EncodingTestzTIssue 6716: compileall should escape source code when printing errors
    to stdout.c��tj�|_tjj|jd�|_t|jdd��5}|jd�ddd�y#1swYyxYw)Nr,r-r.r/ub"€")	r2r3r4r!r8r9r:r<r=rDs  rrGzEncodingTest.setUp�s[��!�)�)�+����7�7�<�<����
�C���
�$�"�"�C�'�
:�d�
�J�J�{�#�;�
:�
:�s�!A<�<Bc�B�tj|j�yr�)r6r7r4rgs r�tearDownzEncodingTest.tearDown�s���
�
�d�n�n�%rc��tjtj�d��}tj|�5tj|j�}ddd�|j�|jd�|j�}|jd|�|jd|�y#1swY�`xYw)N�asciir/rz<SyntaxError: bytes can only contain ASCII literal characters�UnicodeEncodeError)
rb�
TextIOWrapper�BytesIOr`rarer|r4r��seekrPr�r)rE�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)rCrDrE�__doc__rGrVr`rIrrrSrS�s���$�&�4rrSc�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)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)z&Adjust and restore sys.pycache_prefix.�
__testcache__)�
PYTHONPATH�PYTHONPYCACHEPREFIXN)r�pycache_prefixr!r8r9r4)rE�
old_prefix�
new_prefixs   r�temporary_pycache_prefixz-CommandLineTestsBase.temporary_pycache_prefixs^�����'�'�
��W�W�\�\�$�.�.�/�B�
�	,�!+�C��"�n�n�'1��
�
",�C����C��s�;A6�A&�A6�&
A3�3A6c�>�gtj��d�d�d�|�S)Nz-S�-mre)r�!optim_args_from_interpreter_flags)rE�argss  r�
_get_run_argsz"CommandLineTestsBase._get_run_argss<����:�:�<������(����	rc��tj|j|�i|�ddi��\}}}|jd|�|S)N�PYTHONIOENCODINGr.r)r
�assert_python_okrvry�rEru�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)Nrxr.)r
r�rvrzs      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.assertCompiled"s/���~�~�/�/��3����������t�,�-rc��tjj|�}|jtj
j
|��yr�)rrrr�r!r8r�r�s   r�assertNotCompiledz&CommandLineTestsBase.assertNotCompiled&s1���~�~�/�/��3�����������-�.rc�B�tj|jdd�}|j�5}|jdi|��|j|�|j
|j�|j
|j�ddd�y#1swYyxYw)N�bazrrI)	r
r�r4rqr|r�r�rhri)rE�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�<rrI)�-f)r
r�r4rqr|rrrr!r\�timer"rRryr{)rEr�r��pycpathrW�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 rI)�-q)r
r�r4rqr|r�r)rEr��noisyrrs    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)Nrsrer�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
ryrfrdr!r8r�rg�sortedry�listdirr��endswith)rEr��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)
r|rfr�r!r8r�rgr�ryr�)rEr�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�)	r|rfrdr!r8r�rgr9r�)rE�
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�)
r|rfrrrrir!r\r�r"rRryr{)rEr�rWr�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!r8r9rfrBr
r�r|r�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!r8r9rfr
�make_pkgr�r|r�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!r8r9rfr
r�r7r|r�)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)r|rfr{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�rfr~r{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[^\\/]*$)r|rfr�rir�rhrgs 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�r|rfr�rhri)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�rfr~r��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)Nr�zraise Exceptionr�r�r��bingz
import bazzbaz.pycF)�
__isolatedr�)r
r�rfr|rrrr!�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)r~r!r8r9r4rfr��assertNotRegexr�r�rrrrgr�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�rfr<r!r8r9r4r=�linesepr|r�r��rEr�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.r/r�r�)
r
r�rfr<r!r8r9r4r=r�r|r�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�rIr��-rX)
r
r�rf�spawn_pythonrv�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�rfr~rhrir�r�r�)rE�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')r|r�)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�rfrrrr!r8r9r|r<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�r|r�)rEr��files�suffixrfr�rFs       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)rrGr�
executabler4re�mainrdr�ryr�)rEr|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)	Nrr�rrrz-sz-pr/)r!r8r9r4rr
r�rrrr|r�r�rrrrrs           rr z+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!r8r9r4rr
r�r�rrrr|rdr�rQr�r()rEr8rr~r)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/r0r1r2r&r3r4r5z-e)r!r8r9r4rr
r�r7rrrr|rdr�r�r8s
          rrBz4CommandLineTestsBase.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~r4rgs 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�r|ryr()rEr!r8r�pycsrus      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)8rCrDrErarGr`�contextmanagerrqrvr|r~r�r�r�rr�requires_resourcer�r��namer�r�r��localsr�r�r�r�r�r	rHr�r�r�r�r�r�r�r�r�r�r�r�rr	rrFrrrGrr r,rBrr%rIrrrcrc�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�
Krrcc��eZdZy)�CommandLineTestsWithSourceEpochNrLrIrrr+r+�rMrr+c��eZdZy)�CommandLineTestsNoSourceEpochNrLrIrrr-r-�rMrr-�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�)r2r"r8)rEr8s  r�temporary_directoryz*HardlinkDedupTestsBase.temporary_directory�s2����
�
(�
(�
*�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)r!r�rqc�L�tj|jd|||��y)NT)rrr��hardlink_dupesrq)rer|r8)rEr!r�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�r7)r3r�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�r=r>)r@)rEr=r>r5s    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)NrBFr rrr)rCr#r3r�rr|r�r()rEr5r=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)rryr()rErr=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)NrB)rCr#r3r�r|rG)rEr5r=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#r3r�r@r|rrdr()rErJr�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)rrrrrKrr)r3r�r@r|rrdr()rErrLrMs    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�rqr��shallow)r3r�r|rGrr!r"r#ryrdr(r{r��filecmp�cmp�rErr$�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(rrRr�z-cz
import moduleF)r�rlrrTrS)r3r�r@r|rGrr!r"r#r
ryr8ryr�r(rUrVrWs    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)rCrDrErGr`r&r3r�r|r:r@rCrErGr%rNrPrYr\rIrrr0r0�sl���������@�$(�)�5�B�<� �3�
D�(�G�=�
5�J�2Jrr0c��eZdZy)�!HardlinkDedupTestsWithSourceEpochNrLrIrrr^r^_rMrr^c��eZdZy)�HardlinkDedupTestsNoSourceEpochNrLrIrrr`r`frMrr`�__main__)8rer`rU�importlib.utilrrbr!rwr6rSrr2�test.test_importlib.utilr�r�rurr�multiprocessing.utilrr��concurrent.futuresr�concurrent.futures.processrrF�NotImplementedError�ModuleNotFoundErrorr�test.supportr	r
�test.test_py_compilerr�test.support.os_helperr
rrr(r*�TestCaserKrQ�skipIf�is_wasirSrcr+r-�hasattrr0r^r`rCrrIrr�<module>rps�������	�	��
�
�
�����%�	"�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