Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_py_compile.cpython-311.pyc
�

�Ke�-���ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZd�Zd�ZGd�dee
j����ZGd�d	��ZGd
�dee
jed�
��ZGd�dee
jed�
��ZGd�de
j��Zedkre
j��dSdS)�N)�support)�	os_helper�
script_helperc�F��tj����fd���}|S)z+Runs function with SOURCE_DATE_EPOCH unset.c���tj��5}|�d���|i|��cddd��S#1swxYwYdS)N�SOURCE_DATE_EPOCH)r�EnvironmentVarGuard�unset��args�kwargs�env�fxns   ��>/usr/local/apps/python3/lib/python3.11/test/test_py_compile.py�wrapperz*without_source_date_epoch.<locals>.wrappers����
�
*�
,�
,�	(���I�I�)�*�*�*��3��'��'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�?�A�A��	functools�wraps�rrs` r�without_source_date_epochr�8����_�S���(�(�(�(���(��N�c�F��tj����fd���}|S)z)Runs function with SOURCE_DATE_EPOCH set.c�x��tj��5}d|d<�|i|��cddd��S#1swxYwYdS)N�	123456789r)rr	rs   �rrz'with_source_date_epoch.<locals>.wrappers����
�
*�
,�
,�	(��'2�C�#�$��3��'��'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�
/�3�3rrs` r�with_source_date_epochrrrc���eZdZ�fd�Z�xZS)�SourceDateEpochTestMetac�"��t���||||��}t|��D]Y}|�d��rBt	||��}|rt|��}nt
|��}t|||���Z|S)N�test_)�super�__new__�dir�
startswith�getattrrr�setattr)
�mcls�name�bases�dct�source_date_epoch�cls�attr�methr�	__class__s
         �rr"zSourceDateEpochTestMeta.__new__&s�����g�g�o�o�d�D�%��5�5����H�H�	,�	,�D����w�'�'�
,��s�D�)�)��$�>�4�T�:�:�G�G�7��=�=�G���T�7�+�+�+���
r)�__name__�
__module__�__qualname__r"�
__classcell__)r/s@rrr%s8���������������rrc���eZdZd�Zd�Zd�Zd�Zeje	j
�e	j��pe	j
�
e	j��d��d���Zd�Zd�Zd	�Zejeje	jd
kd��ejd�������Zd
�Zd�Zejejjdkd��d���Zd�Zd�Zd�ZdS)�PyCompileTestsBasec��tjtj�����|_tj�|jd��|_|jdz|_tj
�|j��|_tj�
tj����d|_tj�
|j��d}|rtj|��t!|jd��5}|�d��ddd��dS#1swxYwYdS)N)r#�_test.py�cr�w�x = 123
)�tempfile�mkdtemp�os�getcwd�	directory�path�join�source_path�pyc_path�	importlib�util�cache_from_source�
cache_path�
splitdrive�	cwd_drive�chdir�open�write)�self�drive�files   r�setUpzPyCompileTestsBase.setUp7s<��!�)�b�i�k�k�:�:�:����7�<�<���
�C�C����(�3�.��
�#�.�:�:�4�;K�L�L�����+�+�B�I�K�K�8�8��;���
��"�"�4�#3�4�4�Q�7���	��H�U�O�O�O�
�$�"�C�
(�
(�	$�D��J�J�{�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s�E�E�Ec�|�tj|j��|jrt	j|j��dSdS�N)�shutil�rmtreer?rIr=rJ�rMs r�tearDownzPyCompileTestsBase.tearDownGs@���
�d�n�%�%�%��>�	%��H�T�^�$�$�$�$�$�	%�	%rc� �tj|j|j��|�t
j�|j����|�t
j�|j	����dSrR)
�
py_compile�compilerBrC�
assertTruer=r@�exists�assertFalserGrUs r�test_absolute_pathz%PyCompileTestsBase.test_absolute_pathLsf����4�+�T�]�;�;�;��������t�}�5�5�6�6�6����������8�8�9�9�9�9�9rc��	tj|jdz|j��tj�|j��sJ�|�t��5tj|j	|j��ddd��dS#1swxYwYdS#ttf$r|�d��YdSwxYw)Nz.actualz.need to be able to create a symlink for a file)
r=�symlinkrCr@�islink�assertRaises�FileExistsErrorrXrYrB�NotImplementedError�OSError�skipTestrUs r�test_do_not_overwrite_symlinksz1PyCompileTestsBase.test_do_not_overwrite_symlinksQs'��	D��J�t�}�y�0�$�-�@�@�@��7�>�>�$�-�0�0�0�0�0��"�"�?�3�3�
D�
D��"�4�#3�T�]�C�C�C�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D����
D�
D�
D�
D�
D�
D��	$�W�-�	L�	L�	L��M�M�J�K�K�K�K�K�K�	L���s#�"B�$ B�B�B�&C�Cz7requires os.devnull and for it to be a non-regular filec��|�t��5tj|jt
j��ddd��dS#1swxYwYdSrR)rarbrXrYrBr=�devnullrUs r�&test_do_not_overwrite_nonregular_filesz9PyCompileTestsBase.test_do_not_overwrite_nonregular_files]s���
�
�
��
/�
/�	=�	=���t�/���<�<�<�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=s�%A
�
A�Ac��tj|j��|�tj�|j����dSrR)rXrYrBrZr=r@r[rGrUs r�test_cache_pathz"PyCompileTestsBase.test_cache_pathes>����4�+�,�,�,��������t��7�7�8�8�8�8�8rc��tj|j��5tjt
j�|j��t
j�|j	����ddd��n#1swxYwY|�
t
j�|j	����|�t
j�|j
����dSrR)r�
change_cwdr?rXrYr=r@�basenamerBrCrZr[r\rGrUs r�test_cwdzPyCompileTestsBase.test_cwdis��
�
!�$�.�
1�
1�	@�	@���r�w�/�/��0@�A�A�!�w�/�/��
�>�>�
@�
@�
@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	
�������t�}�5�5�6�6�6����������8�8�9�9�9�9�9s�AB�B�Bc��tjtj�|j��tj�|j����|�tj�|j����|�	tj�|j
����dSrR)rXrYr=r@�relpathrBrCrZr[r\rGrUs r�test_relative_pathz%PyCompileTestsBase.test_relative_pathps�����2�7�?�?�4�+;�<�<��7�?�?�4�=�9�9�	;�	;�	;��������t�}�5�5�6�6�6����������8�8�9�9�9�9�9r�ntz/cannot control directory permissions on Windowsc��tj|j��}tj|jtj��	|�t��5tj|j	|j
��ddd��n#1swxYwYtj|j|j��dS#tj|j|j��wxYwrR)r=�statr?�chmod�S_IREADra�IOErrorrXrYrBrC�st_mode)rM�modes  r�test_exceptions_propagatez,PyCompileTestsBase.test_exceptions_propagatevs����w�t�~�&�&��
������.�.�.�	3��"�"�7�+�+�
D�
D��"�4�#3�T�]�C�C�C�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D�
D����
D�
D�
D�
D�
�H�T�^�T�\�2�2�2�2�2��B�H�T�^�T�\�2�2�2�2���s/�B1� B�9B1�B	�	B1�B	�
B1�1!Cc���tj�tj�t��d��}tj��5|�tj	|d�����ddd��n#1swxYwY|�
tj�tj
�|������dS)N�bad_coding2.pyF)�doraise)r=r@rA�dirname�__file__r�captured_stderr�assertIsNonerXrYr\r[rDrErF)rM�
bad_codings  r�test_bad_codingz"PyCompileTestsBase.test_bad_coding�s���W�\�\�"�'�/�/�(�";�";�=M�N�N�
�
�
$�
&�
&�	M�	M����j�0��U�K�K�K�L�L�L�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M����	M�	M�	M�	M���������N�,�,�Z�8�8�:�:�	;�	;�	;�	;�	;s�*B�B�Bc�T�tj|j|j��|�t
j�|j����|�t
j�|j	����t|jd��5}tj�
|���di��}ddd��n#1swxYwYt
j�d��rd}nd}|�||��dS)N�rb�testr�r)rXrYrBrCrZr=r@r[r\rGrKrD�_bootstrap_external�
_classify_pyc�read�environ�get�assertEqual)rM�fp�flags�expected_flagss    r�test_source_date_epochz)PyCompileTestsBase.test_source_date_epoch�s,����4�+�T�]�;�;�;��������t�}�5�5�6�6�6����������8�8�9�9�9�
�$�-��
&�
&�	'�"��1�?�?����	�	�6�2�'�'�E�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'��:�>�>�-�.�.�	"�!�N�N�!�N������/�/�/�/�/s�#4C#�#C'�*C'rztest does not work with -Oc	�l�tj�|jd��}tj�|��}|dz}tj�|��\}}tj�|��}|�	tj�||��tj�dd�
tjj
������t|d��5}|�d��ddd��n#1swxYwYt!j|��|�tj�|����|�tj�|����dS)Nz
foo.bar.pyr8�__pycache__zfoo.bar.{}.pycr9r:)r=r@rAr?rDrErF�splitrnr��format�sys�implementation�	cache_tagrKrLrXrYrZr[r\)rM�
weird_pathrGrC�head�tail�penultimate_tailrOs        r�test_double_dot_no_clobberz-PyCompileTestsBase.test_double_dot_no_clobber�s����W�\�\�$�.�,�?�?�
��^�5�5�j�A�A�
���#���W�]�]�:�.�.�
��d��7�+�+�D�1�1������G�L�L�)�4�0�0��G�L�L�� �'�'��(:�(D�E�E�
G�
G�	H�	H�	H�
�*�c�
"�
"�	$�d��J�J�{�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$���:�&�&�&��������z�2�2�3�3�3���������1�1�2�2�2�2�2s�D1�1D5�8D5c�d�|�dtj|jd�����dS)Nzopt-2�)�optimize)�assertInrXrYrBrUs r�test_optimization_pathz)PyCompileTestsBase.test_optimization_path�s/���
�
�g�z�1�$�2B�Q�O�O�O�P�P�P�P�Prc��tj|jtjj���t|jd��5}tj�	|�
��di��}ddd��n#1swxYwY|�|d��tj|jtjj���t|jd��5}tj�	|�
��di��}ddd��n#1swxYwY|�|d��dS)N)�invalidation_moder�r�r��)
rXrYrB�PycInvalidationMode�CHECKED_HASHrKrGrDr�r�r�r��UNCHECKED_HASH)rMr�r�s   r�test_invalidation_modez)PyCompileTestsBase.test_invalidation_mode�s�������(�<�I�	
�	
�	
�	
��$�/�4�
(�
(�	'�B��1�?�?����	�	�6�2�'�'�E�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'�	
�����%�%�%�����(�<�K�	
�	
�	
�	
��$�/�4�
(�
(�	'�B��1�?�?����	�	�6�2�'�'�E�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'�	
�����$�$�$�$�$s$�4B�B�B� 4D � D$�'D$c�v�tj�tj�t��d��}tj��5}|�tj	|dd�����|�tj	|dd�����|�
|���d��|�tj
��5tj	|dd���ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr}Fr�)r~�quietT�r�)r=r@rArr�rr�r�rXrYr��getvaluera�PyCompileError)rMr��stderrs   r�
test_quietzPyCompileTestsBase.test_quiet�s����W�\�\�"�'�/�/�(�";�";�=M�N�N�
�
�
$�
&�
&�	F�&����j�0��U�RS�T�T�T�U�U�U����j�0��T�QR�S�S�S�T�T�T����V�_�_�.�.��3�3�3��"�"�:�#<�=�=�
F�
F��"�:�t�1�E�E�E�E�
F�
F�
F�
F�
F�
F�
F�
F�
F�
F�
F����
F�
F�
F�
F�		F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs7�BD.�2D�
D.�D	�D.�D	�D.�.D2�5D2N) r0r1r2rPrVr]rf�unittest�skipIfr=r@r[rh�isfilerirkrorrr�skip_if_dac_overrider(�skip_unless_working_chmodr{r�r�r�r�r�r�r�r�r��rrr5r55s�������$�$�$� %�%�%�
:�:�:�

D�
D�
D��X�_������
�3�3�3�Q�r�w�~�~�b�j�7Q�7Q�N�P�P�=�=�P�P�=�9�9�9�:�:�:�:�:�:��#��X�_�R�W��_�F�H�H��(�
3�
3�)�(�H�H�$�#�
3�;�;�;�0�0�0��X�_�S�Y�'�!�+�-I�J�J�3�3�K�J�3�&Q�Q�Q�%�%�%�$F�F�F�F�Frr5c��eZdZdS)�PyCompileTestsWithSourceEpochN�r0r1r2r�rrr�r���������	�Drr�T)�	metaclassr+c��eZdZdS)� PyCompileTestsWithoutSourceEpochNr�r�rrr�r��r�rr�Fc�t�eZdZd�Zd�Zej��d���Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�ZdS)�PyCompileCLITestCasec�b�tj��|_tj�|jd��|_tj�	|j��|_
t|jd��5}|�d��ddd��dS#1swxYwYdS)Nr7r9r:)
r;r<r?r=r@rArBrDrErFrGrKrL)rMrOs  rrPzPyCompileCLITestCase.setUp�s���!�)�+�+����7�<�<���
�C�C���#�.�:�:�4�;K�L�L���
�$�"�C�
(�
(�	$�D��J�J�{�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s�B$�$B(�+B(c�8�tj|j��dSrR)rrTr?rUs rrVzPyCompileCLITestCase.tearDown�s������(�(�(�(�(rc���|rM|ddkrAd|vr=tjtjdddg|d���d���Stjddg|�Ri|��S)Nr�-�input�-mrXT)r��capture_output)�
subprocess�runr��
executable�encoder�assert_python_ok)rMrr
s   r�pycompilecmdz!PyCompileCLITestCase.pycompilecmd�s���
�	7�D��G�s�N�N�w�&�'8�'8��>�3�>�4��s�"K�(.�w��(>�(>�(@�(@�15�7�7�7�
7��-�d�L�R�4�R�R�R�6�R�R�Rrc�(�tjddg|�R�S)Nr�rX)r�assert_python_failure)rMrs  r�pycompilecmd_failurez)PyCompileCLITestCase.pycompilecmd_failure�s���2�4��M��M�M�M�Mrc�N�|�d|j���}|�|jd��|�|jd��|�|jd��|�tj�	|j
����dS)Nr�)r�rr)r�rBr��
returncode�stdoutr�rZr=r@r[rG)rM�results  r�
test_stdinzPyCompileCLITestCase.test_stdin�s����"�"�3�d�.>�"�?�?������*�A�.�.�.�������,�,�,�������,�,�,��������t��7�7�8�8�8�8�8rc�@�|�|j|j��\}}}|�|d��|�|d��|�|d��|�tj�|j����dS)Nrr)r�rBr�rZr=r@r[rG)rM�rcr�r�s    r�test_with_filesz$PyCompileCLITestCase.test_with_files�s���!�.�.�t�/?��AQ�R�R���F�F�����Q���������%�%�%������%�%�%��������t��7�7�8�8�8�8�8rc�@�tj�tj�t��d��}|�|��\}}}|�|d��|�|d��|�d|��dS)N�badsyntax_3131.pyr�rsSyntaxError)r=r@rArr�r�r�r��rM�
bad_syntaxr�r�r�s     r�test_bad_syntaxz$PyCompileCLITestCase.test_bad_syntaxs����W�\�\�"�'�/�/�(�";�";�=P�Q�Q�
�!�6�6�z�B�B���F�F�����Q���������%�%�%��
�
�n�f�-�-�-�-�-rc�B�tj�tj�t��d��}|�d|��\}}}|�|d��|�|d��|�|d��dS)Nr��-qr�r)r=r@rArr�r�r�r�s     r�test_bad_syntax_with_quietz/PyCompileCLITestCase.test_bad_syntax_with_quiets����W�\�\�"�'�/�/�(�";�";�=P�Q�Q�
�!�6�6�t�Z�H�H���F�F�����Q���������%�%�%������%�%�%�%�%rc�p�tj�tj�t��d��}|�|j|��\}}}|�|d��|�|d��|�d|�	����dS)N�should_not_exists.pyr�rsno such file or directory)
r=r@rArr�r�rBr�r��lower�rM�should_not_existsr�r�r�s     r�test_file_not_existsz)PyCompileCLITestCase.test_file_not_existss����G�L�L������)B�)B�DZ�[�[��!�6�6�t�7G�IZ�[�[���F�F�����Q���������%�%�%��
�
�2�F�L�L�N�N�C�C�C�C�Crc�N�tj�tj�t��d��}|�d|j|��\}}}|�|d��|�|d��|�|d��dS)Nr�r�r�r)r=r@rArr�r�rBr�r�s     r�test_file_not_exists_with_quietz4PyCompileCLITestCase.test_file_not_exists_with_quiets����G�L�L������)B�)B�DZ�[�[��!�6�6�t�T�=M�O`�a�a���F�F�����Q���������%�%�%������%�%�%�%�%rN)r0r1r2rPrVr�requires_subprocessr�r�r�r�r�r�r�r�r�rrr�r��s�������$�$�$�)�)�)�!�W� �"�"�S�S�#�"�S�N�N�N�9�9�9�9�9�9�.�.�.�&�&�&�D�D�D�&�&�&�&�&rr��__main__)r�importlib.utilrDr=rXrSrur�r�r;r�r�r�test.supportrrrr�type�TestCaserr5r�r�r�r0�mainr�rr�<module>r�s�����������	�	�	�	�����
�
�
�
���������
�
�
�
���������������1�1�1�1�1�1�1�1�������
�
�
�
�
�d�d�8�#4�5�5�
�
�
� WF�WF�WF�WF�WF�WF�WF�WF�t	�	�	�	�	�$6�$,�$5�.E�6:�	�	�	�	�	�	�	�	�	�'9�'/�'8�1H�9>�	�	�	�	�B&�B&�B&�B&�B&�8�,�B&�B&�B&�J�z����H�M�O�O�O�O�O��r