Your IP : 216.73.216.213


Current Path : /opt/alt/python311/lib64/python3.11/test/test_import/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/test/test_import/__pycache__/__init__.cpython-311.pyc

�

�0�i�����ddlZddlZddlZddlZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZddlZddlmZddlmZmZmZmZmZmZmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*ddlm+Z+dd	lm,Z,dd
l-m.Z.ddl/m0Z0ej1ej2d��Z3d
�Z4Gd�dej5��Z6e3Gd�dej5����Z7Gd�dej5��Z8Gd�dej5��Z9Gd�dej5��Z:Gd�dej5��Z;Gd�dej5��Z<Gd�dej5��Z=eGd�dej5����Z>eGd �d!ej5����Z?Gd"�d#ej5��Z@Gd$�d%ej5��ZAeBd&krejC��dSdS)'�N)�_get_sourcefile)�mock)�	os_helper)�
STDLIB_DIR�	is_jython�	swap_attr�	swap_item�cpython_only�
is_emscripten�is_wasi)�forget�make_legacy_pyc�unlink�unload�ready_to_import�
DirsOnSysPath�CleanImport)�TESTFN�rmtree�
temp_umask�TESTFN_UNENCODABLE)�
script_helper)�threading_helper)�uncache)�
ModuleTypez*test meaningful only when writing bytecodec�l�|dz|dz|dz|dzfD]}t|���td��dS)N�.py�.pyc�.pyw�	$py.class�__pycache__)rr)�name�fs  �@/opt/alt/python311/lib64/python3.11/test/test_import/__init__.py�remove_filesr%(sS���U�l��V�m��V�m��[� �"����	�q�	�	�	�	�
�=������c��eZdZd�Zd�Zd�Zd�Zd�Zd�Ze	d���Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd$d�Zd�Zd�Zd�Zd�Zed���Zd�Zd�Zed���Zd�Ze	d���Zd�Zd�Zd�Ze	d���Z e!j"��d���Z#e$j%e&j'dkd ��d!���Z(d"�Z)d#S)%�ImportTestsc�T�tt��tj��dS�N)r%r�	importlib�invalidate_caches��selfs r$�setUpzImportTests.setUp3s%���V�����#�%�%�%�%�%r&c�.�tt��dSr*)rrr-s r$�tearDownzImportTests.tearDown7s���v�����r&c�t�|�t��5ddl}ddd��dS#1swxYwYdS�Nr)�assertRaises�ModuleNotFoundError�(something_that_should_not_exist_anywhere�r.r6s  r$�&test_import_raises_ModuleNotFoundErrorz2ImportTests.test_import_raises_ModuleNotFoundError:s���
�
�
�2�
3�
3�	<�	<�;�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<��-�1�1c�x�|�t��5ddlm}ddd��dS#1swxYwYdS)Nr)�blah)r4r5r6r;)r.r;s  r$�:test_from_import_missing_module_raises_ModuleNotFoundErrorzFImportTests.test_from_import_missing_module_raises_ModuleNotFoundError>s���
�
�
�2�
3�
3�	F�	F�E�E�E�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	F��/�3�3c�x�|�t��5ddlm}ddd��dS#1swxYwYdS)Nr)r6)r4�ImportErrorr+r6r7s  r$�0test_from_import_missing_attr_raises_ImportErrorz<ImportTests.test_from_import_missing_attr_raises_ImportErrorBs���
�
�
�{�
+�
+�	K�	K�J�J�J�J�J�J�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K����	K�	K�	K�	K�	K�	Kr=c��td��5ddl}|�t��5}ddlm}ddd��n#1swxYwYddd��n#1swxYwY|�|jjd��|�|jj|j	��|�
t|j��d��dS)N�osr��i_dont_existz7cannot import name 'i_dont_exist' from 'os' \(.*os.py\))rrBr4r?rD�assertEqual�	exceptionr"�path�__file__�assertRegex�str)r.rB�cmrDs    r$�/test_from_import_missing_attr_has_name_and_pathz;ImportTests.test_from_import_missing_attr_has_name_and_pathFsG��
��
�
�	,�	,��I�I�I��"�"�;�/�/�
,�2�+�+�+�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	
�����*�D�1�1�1������*�B�K�8�8�8�����R�\�*�*�,f�g�g�g�g�gs3�A�A�A�A	�A�	A	�
A�A� Ac���ddl}|�t��5}ddlm}ddd��n#1swxYwY|�|jjd��t|d��rO|�|jj|j	��|�
t|j��d��dS|�t|j��d��dS)NrrC�	_testcapirHzCcannot import name 'i_dont_exist' from '_testcapi' \(.*\.(so|pyd)\)zEcannot import name 'i_dont_exist' from '_testcapi' (unknown location))rNr4r?rDrErFr"�hasattrrGrHrIrJ)r.rNrKrDs    r$�2test_from_import_missing_attr_has_name_and_so_pathz>ImportTests.test_from_import_missing_attr_has_name_and_so_pathOs7������
�
�
�{�
+�
+�	/�r�.�.�.�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/������*�K�8�8�8��9�j�)�)�
	����R�\�.�	�0B�C�C�C�����B�L�!�!�V�
�
�
�
�
�

����B�L�!�!�W�
�
�
�
�
s�2�6�6c���|�t��5}ddlm}ddd��n#1swxYwY|�|jjd��|�|jj��dS)NrrC�_warning)	r4r?rRrDrErFr"�assertIsNonerG�r.rKrDs   r$�&test_from_import_missing_attr_has_namez2ImportTests.test_from_import_missing_attr_has_nameas���
�
�
�{�
+�
+�	.�r�-�-�-�-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	
�����*�J�7�7�7����"�,�+�,�,�,�,�,��.�2�2c���|�t��5}ddlm}ddd��n#1swxYwY|�|jjddh��|�|j��dS)NrrC�	posixpath�ntpath)r4r?�os.pathrD�assertInrFr"�assertIsNotNonerTs   r$�/test_from_import_missing_attr_path_is_canonicalz;ImportTests.test_from_import_missing_attr_path_is_canonicalhs���
�
�
�{�
+�
+�	-�r�,�,�,�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��
�
�b�l�'�+�x�)@�A�A�A����R�\�*�*�*�*�*rVc��ddl}t��5\}}t|dd���5}|�d��ddd��n#1swxYwYi}|�t
|�|���d���5td|�d�|��ddd��n#1swxYwY|�d	|��ddd��n#1swxYwYt��5\}}t|dd���5}|�d
��ddd��n#1swxYwYi}|�t
|�|���d���5td|�d�|��ddd��n#1swxYwY|�d	|��ddd��dS#1swxYwYdS)Nr�w�utf-8��encodingz__all__ = [b'invalid_type']z\.__all__ must be strzfrom z	 import *sinvalid_typez%globals()[b'invalid_type'] = object()z\.__dict__ must be str)	�rer�open�write�assertRaisesRegex�	TypeError�escape�exec�assertNotIn)r.rcr"rGr#�globalss      r$�"test_from_import_star_invalid_typez.ImportTests.test_from_import_star_invalid_typens`���	�	�	�
�
�
�	7�,�4���d�C�'�2�2�2�
7�a����5�6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7��G��'�'��b�i�i��o�o�E�E�E���
7�
7��,�T�,�,�,�g�6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7�
���_�g�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7��
�
�	7�,�4���d�C�'�2�2�2�
A�a����?�@�@�@�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A����
A�
A�
A�
A��G��'�'��b�i�i��o�o�F�F�F���
7�
7��,�T�,�,�,�g�6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7�
���_�g�6�6�6�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7s��C�A�C�A	�C�A	�6C�	B*�C�*B.	�.C�1B.	�2C�C�C�0F5�D(�F5�(D,	�,F5�/D,	�06F5�&F�;F5�F	�F5�F	�F5�5F9�<F9c�t�|�t��5ddl}ddd��dS#1swxYwYdSr3)r4r?�RAnDoM)r.rns  r$�test_case_sensitivityz!ImportTests.test_case_sensitivity�s����
�
�{�
+�
+�	�	��M�M�M�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r9c�<�ddlm}td��ddlm}dS)Nr)�double_constz"test.test_import.data.double_const)�test.test_import.datarqr)r.rqs  r$�test_double_constzImportTests.test_double_const�s=��	7�6�6�6�6�6��3�4�4�4�6�6�6�6�6�6�6�6r&c����fd�}tj�dtj��	|d��tj�d��rdD]
}||���tjd=dS#tjd=wxYw)Nc���t|z}trtdz}n
tdz}t|dd���5}td|d|���t	jd	��}t	jd	��}td
||���td||���ddd��n#1swxYwYttjvrtjt=tj	��		tt��}n2#t$r%}��d|�d
|����Yd}~nd}~wwxYw��
|j|d|z����
|j|d|z��t!t��t#|��t#|��dS#t!t��t#|��t#|��wxYw)Nr rr_r`raz)# This tests Python's ability to import azfile.��filei�za =zb =zimport from z	 failed: z'module loaded (%s) but contents invalid)rrrd�print�random�	randrange�sys�modulesr+r,�
__import__r?�failrE�a�br
r)	�ext�source�pycr#rr��mod�errr.s	        �r$�test_with_extensionz4ImportTests.test_import.<locals>.test_with_extension�s2����c�\�F��
&��{�*����v�o���f�c�G�4�4�4�
(���A��7��,�,�,�,��$�T�*�*���$�T�*�*���e�Q�Q�'�'�'�'��e�Q�Q�'�'�'�'�

(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(����$�$��K��'��'�)�)�)�

�H�$�V�,�,�C�C��"�H�H�H��I�I�I�S�S�S�#�#�F�G�G�G�G�G�G�G�G�����H����� � ����=��C�E�E�E�� � ����=��C�E�E�E��v�����v�����s��������v�����v�����s�������sC�A B&�&B*�-B*�+D�?F$�
D/�
D*�%F$�*D/�/AF$�$4Grr�win)z.PYz.Pyz.pYrz.PYWz.pYw)r{rG�insertrB�curdir�platform�
startswith)r.r�r�s`  r$�test_importzImportTests.test_import�s���� 	� 	� 	� 	� 	�D	�����2�9�%�%�%�	����&�&�&��|�&�&�u�-�-�
-�H�-�-�C�'�'��,�,�,�,������������O�O�O�Os�:A;�;B
�longlistc��|dz}t|dd���5}|�d��td��D]}|�d���|�d��ddd��n#1swxYwY	tj|��t|��n#t|��wxYwtj�d	��tj
��i}	t|��td
|zd|��tjd=t|dz��t|d
z��|�
��	tj|=dS#t$rYdSwxYw#tjd=t|dz��t|d
z��|�
��	tj|=w#t$rYwwxYwxYw)Nrr_r`razd = [
i�z"",
�]�zimport ����c�o)rdre�range�
py_compile�compilerr{rG�appendr+r,rri�clearr|�KeyError)r.�module�filenamer#�i�	namespaces      r$�test_module_with_large_stackz(ImportTests.test_module_with_large_stack�s?���E�>���(�C�'�
2�
2�
2�	�a�
�G�G�I�����5�\�\�
!�
!������ � � � �
�G�G�C�L�L�L�		�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�
��x�(�(�(��8������F�8��������	���������#�%�%�%��	�	��H�%�%�%���V�#�T�9�5�5�5������8�c�>�"�"�"��8�c�>�"�"�"�
�O�O����
��K��'�'�'���
�
�
����
����������8�c�>�"�"�"��8�c�>�"�"�"�
�O�O����
��K��'�'���
�
�
���
������sa�AA6�6A:�=A:�B&�&B7�/#E8�
E'�'
E5�4E5�8AG�?
G
�G�
G�G�G�Gc��tdz}t|dd���5}td|���ddd��n#1swxYwYtj�dtj��tj	��ttj
vrtj
t=	dD]Q}|�ttt��|�ttj
d	|z���R	tjd=tt��dS#tjd=tt��wxYw)
Nrr_r`raza = 1/0rvr)���z'damaged module in sys.modules on %i try)rrdrxr{rGr�rBr�r+r,r|r4�ZeroDivisionErrorr}rjr%)r.r�r#r�s    r$�test_failing_import_sticksz&ImportTests.test_failing_import_sticks�sh���%���
�&�#��
0�
0�
0�	%�A��)�!�$�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�
	�����2�9�%�%�%��#�%�%�%��S�[� � ���F�#�	!��
P�
P���!�!�"3�Z��H�H�H�� � ����!J�Q�!N�P�P�P�P�
P�
������ � � � � �������� � � � ���s�;�?�?�)AD!�!#Ec���ddl}ddl}|�|||j��|�t|jd����ddlm}|�||j|j��dS)NrrH)�test�test.support�assertIs�__name__�
assertTruerO�support)r.�xr��ys    r$�test_import_name_bindingz$ImportTests.test_import_name_binding�s������������
�
�a��q�z�*�*�*�������j�9�9�:�:�:�	!� � � � � ��
�
�a���q�z�2�2�2�2�2r&c��	d}ddlmcm}n#ddlmcm}wxYwd}|dkrddlmcm}|dz
}|dk�td��D]}ddlmcm}�dS)N.r�
r�r�)�test.support.script_helperr�rr�)r.r�r�s   r$�test_issue31286zImportTests.test_issue31286s���	3��A�2�2�2�2�2�2�2�2�2�2��2�2�2�2�2�2�2�2�2�2�2�2�2�
���"�f�f�2�2�2�2�2�2�2�2�2�
��F�A��"�f�f�
�q���	3�	3�A�2�2�2�2�2�2�2�2�2�2�	3�	3s��c��ttjzdz}t|dd���5}|�d��ddd��n#1swxYwYt
j�dtj��	tt��}|�
tt
j��|�|j
dd��|�|jd	d��tt��t|dd���5}|�d
��ddd��n#1swxYwY|�t"t$j|��t
j�t��}|�|d��|�|j
dd��|�|jd	d��t
jd=tt��t-t��dS#t
jd=tt��t-t��wxYw)
N�pyr_r`raz
a = 1
b=2
rr�z!module has wrong attribute valuesr�za = 10
b=20//0
z$expected module to be in sys.modulesr�)rrB�extseprdrer{rGr�r�r}r[r|rErr�r%r4r�r+�reload�getr\r)r.r�r#r�s    r$�test_failing_reloadzImportTests.test_failing_reloadsb���"�)�#�d�*��
�&�#��
0�
0�
0�	$�A�
�G�G�N�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	�����2�9�%�%�%�	��V�$�$�C��M�M�&�#�+�.�.�.����S�U�A�'J�K�K�K����S�U�A�'J�K�K�K�
�� � � ��f�c�G�4�4�4�
-�����+�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�
���/��1A�3�G�G�G��+�/�/�&�)�)�C�� � ��&L�M�M�M�
���S�U�B�(K�L�L�L����S�U�A�'J�K�K�K������� � � ��6�N�N�N�N�N�������� � � ��6�N�N�N�N���sC�A�A�A�BH�D;�/H�;D?�?H�D?�BH�7Ic���tdz}t|dd���5}|�d��ddd��n#1swxYwYtj�dtj��	tt��}|�	|j
�d����t
j|��tj
t=t|��tj��tt��}tj�|j
��\}}|�|d��tjd=t't��ttj
vrtj
t=dSdS#tjd=t't��ttj
vrtj
t=wxYw)Nrr_r`raztest = None
rr)rrdrer{rGr�rBr�r}r�rH�endswith�remover|rr+r,�splitextrEr%)r.r�r#r��baser�s      r$�test_file_to_sourcezImportTests.test_file_to_source;s����%���
�&�#��
0�
0�
0�	%�A�
�G�G�O�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	�����2�9�%�%�%�	(��V�$�$�C��O�O�C�L�1�1�%�8�8�9�9�9��I�f������F�#��F�#�#�#��'�)�)�)��V�$�$�C���(�(���6�6�I�D�#����S�&�)�)�)������� � � ����$�$��K��'�'�'�%�$�������� � � ����$�$��K��'�'�'�'�'s�?�A�A�5CF�AG!c��tj�t��}t	j��}	|�|��n8#t$r+|�d�	|����YnwxYw|�
t��5}t|��ddd��dS#1swxYwYdS)Nzpath is not encodable to {})
rBrG�abspathrr{�getfilesystemencoding�encode�UnicodeEncodeError�skipTest�formatr4r?r})r.rGrbr�s    r$�test_import_by_filenamez#ImportTests.test_import_by_filenameSs���w���v�&�&���,�.�.��	J��K�K��!�!�!�!��!�	J�	J�	J��M�M�7�>�>�x�H�H�I�I�I�I�I�	J����
�
�
�{�
+�
+�	�q��t����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s#�A�2B�B�!B>�>C�Cc��tjdttjd����}tj|��dS)Nr�z�            import sys
            class C:
               def __del__(self):
                  import importlib
            sys.argv.insert(0, C())
            )r�make_scriptr�textwrap�dedent�assert_python_ok)r.�testfns  r$�!test_import_in_del_does_not_crashz-ImportTests.test_import_in_del_does_not_crash]sE���*�2�v�x��H�8�8����	�&�v�.�.�.�.�.r&c�6�tj�dtj��	t
dz}tj�|��}t|dd���5}	ddd��n#1swxYwY	tj
|d��n�#t$r|�d��Ynrt$rf}|jttdd��ttd	d��fvr�|�d
�|����Yd}~nd}~wwxYwt#t
��tj|��tjd=t't
��dS#tjd=t't
��wxYw)Nrrr_r`ra)���r�z-cannot set modification time to large integer�	EOVERFLOW�EINVALz2cannot set modification time to large integer ({}))r{rGr�rBr�rr+�util�cache_from_sourcerd�utime�
OverflowErrorr��OSError�errno�getattrr�r}�statr%)r.r��compiledr#�es     r$�test_timestamp_overflowz#ImportTests.test_timestamp_overflowhs���	�����2�9�%�%�%�	!��e�^�F� �~�7�7��?�?�H��f�c�G�4�4�4�
���
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
^����!;�<�<�<�<�� �
O�
O�
O��
�
�M�N�N�N�N�N��
^�
^�
^��7�7�5�+�t�#D�#D�#*�5�(�D�#A�#A�#C�C�C���
�
�R�Y�Y�Z[�\�\�]�]�]�]�]�]�]�]�����	
^����

�v�����G�H���������� � � � � �������� � � � ���sf�;E5�'A5�)E5�5A9�9E5�<A9�=E5�B�E5�D'�6E5�8	D'�AD"�E5�"D'�'+E5�5#Fc�x�	tddg���dS#t$r|�d��YdSwxYw)N�httpr;)�fromlistzfromlist must allow bogus names)r}r?r~r-s r$�test_bogus_fromlistzImportTests.test_bogus_fromlist�sY��	9��v���1�1�1�1�1�1���	9�	9�	9��I�I�7�8�8�8�8�8�8�	9���s��9�9c��ddg}tj|�}|���\}}|�d|��dS)N�-cz&del __builtins__.__import__; import ossImportError)r�spawn_python�communicater[)r.�args�popen�stdout�stderrs     r$�test_delete_builtins_importz'ImportTests.test_delete_builtins_import�sI���>�?���*�D�1���*�*�,�,�����
�
�n�f�-�-�-�-�-r&c�z�|�td��5ddlm}ddd��dS#1swxYwYdS)Nz^No module named 'bogus'r)�foo)rfr?�bogusr�)r.r�s  r$�/test_from_import_message_for_nonexistent_modulez;ImportTests.test_from_import_message_for_nonexistent_module�s���
�
#�
#�K�1K�
L�
L�	"�	"�!�!�!�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"��0�4�4c�z�|�td��5ddlm}ddd��dS#1swxYwYdS)Nz^cannot import name 'bogus'r)r�)rfr?rcr�)r.r�s  r$�,test_from_import_message_for_existing_modulez8ImportTests.test_from_import_message_for_existing_module�s���
�
#�
#�K�1N�
O�
O�	!�	!� � � � � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�	!�	!r�c�H�Gd�d��}d}|�t|��|��tj|<|�t
��5}ddlm}ddd��n#1swxYwY|�t|j
��d��dS)Nc��eZdZd�ZdS)�IImportTests.test_from_import_AttributeError.<locals>.AlwaysAttributeErrorc��t�r*)�AttributeError)r.�_s  r$�__getattr__zUImportTests.test_from_import_AttributeError.<locals>.AlwaysAttributeError.__getattr__�s��$�$r&N)r��
__module__�__qualname__r��r&r$�AlwaysAttributeErrorr��s#������
%�
%�
%�
%�
%r&r��test_from_import_AttributeErrorr��does_not_existzScannot import name 'does_not_exist' from '<unknown module name>' (unknown location))�
addCleanuprr{r|r4r?r�r�rErJrF)r.r��module_namerKr�s     r$r�z+ImportTests.test_from_import_AttributeError�s��	%�	%�	%�	%�	%�	%�	%�	%�8�������,�,�,�#7�#7�#9�#9���K� �
�
�
�{�
+�
+�	G�r�F�F�F�F�F�F�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G�	
����R�\�*�*�a�	c�	c�	c�	c�	cs�A/�/A3�6A3c�P�ttdd��5|�t��5ddlm}ddd��n#1swxYwY|�t
��5tjddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�rr�)rrBr4r?r�r�)r.r�s  r$�test_issue31492zImportTests.test_issue31492�si��
�r�:�t�
,�
,�	"�	"��"�"�;�/�/�
.�
.�-�-�-�-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.��"�"�>�2�2�
"�
"��!�!�
"�
"�
"�
"�
"�
"�
"�
"�
"�
"�
"����
"�
"�
"�
"�		"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"sW�B�A�B�A		�	B�A		�
B�*
B�7B�B	�B�
B	�B�B�"Bc�N�����d��tj�dtj�tj�t��d����	d����fd��td��D�]}tj	����fd�td��D��}	tj|�j��5tjd��ddd��n#1swxYwYtj�dd��tj�d	d��nE#tj�dd��tj�d	d��wxYw������	tjd=dS#tjd=wxYw)
Nc�b�|dkr&|jjdkrtjd��dSdSdS)N�call�has_deadlockg�������?)�f_code�co_name�time�sleep)�frame�event�args   r$�delay_has_deadlockz8ImportTests.test_concurrency.<locals>.delay_has_deadlock�s8������5�<�#7�>�#I�#I��
�3��������#I�#Ir&r�datac���tj�������	ddl}n#t$r}|�Yd}~nd}~wwxYwtjd��dSr3)r{�settrace�wait�package�
BaseException)rr�rr�excs  ���r$�runz)ImportTests.test_concurrency.<locals>.run�sw�����/�0�0�0��
�
�����"�N�N�N�N��$�����C�C�C�C�C�C�����������T�"�"�"�"�"s�0�
A�A�Ar�c�:��g|]}tj������S))�target)�	threading�Thread)�.0r�rs  �r$�
<listcomp>z0ImportTests.test_concurrency.<locals>.<listcomp>�s'���J�J�J�A�9�+�3�7�7�7�J�J�Jr&r�rzpackage.submodule)r{rGr�rB�join�dirnamerHr�r�Eventr�
start_threads�setr	r
r|�pop)r.r��threadsrrrrs   @@@@r$�test_concurrencyzImportTests.test_concurrency�s�������	 �	 �	 �	�����2�7�<�<������(A�(A�6�J�J�K�K�K�	��C�
#�
#�
#�
#�
#�
#�
#��2�Y�Y�

�

��!��)�)��J�J�J�J��q���J�J�J��?�)�7����K�K�&�&��
�1�
�
�
�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&��K�O�O�I�t�4�4�4��K�O�O�$7��>�>�>�>���K�O�O�I�t�4�4�4��K�O�O�$7��>�>�>�>�����?��I�#�

������������O�O�O�OsK�)A	F�3D:�
C.�"D:�.C2	�2D:�5C2	�6D:�9AF�:AE<�<	F�F$�win32�Windows-specificc
���ddlm}|tj��}tj�d��j}tj	�
tj	�|��d�d|vrdnd����}tj��5}tj	�
|d��}tj|��tj	�
|tj	�tj����}t%jtj|��t%j||��t)jtj	�
t)jtj��d����D]}t%j||���t%j||��d}	d	�tjD��}	|d
zt0z|	d<t3j|dd
�
d
d�tj	�|����ddg��gt2j|	tj	�|�����t%j||��t3j|ddgt2j|	tj	�|�����ddd��dS#1swxYwYdS)Nr)�GetModuleFileName�_sqlite3z
sqlite3{}.dll�_dr��DLLszvcruntime*.dllc�X�i|]'}|���tj|��(Sr�)�upperrB�environ)r�ks  r$�
<dictcomp>z:ImportTests.test_dll_dependency_import.<locals>.<dictcomp>�s(��@�@�@��1�7�7�9�9�b�j��m�@�@�@r&�;�
PYTHONPATHz-Scz	import oszp = os.add_dll_directory({!r})zimport _sqlite3zp.close)r��env�cwd)�_winapir(r{�	dllhandler+r��	find_spec�originrBrGrrr�r�temp_dir�mkdir�basename�
executable�shutil�copy�globrh�prefixr.r�
subprocess�
check_call�STDOUT)
r.r(�dllname�pydname�depname�tmp�tmp2�pyexer#r3s
          r$�test_dll_dependency_importz&ImportTests.test_dll_dependency_import�s���-�-�-�-�-�-�#�#�C�M�2�2���.�*�*�:�6�6�=���'�,�,��G�O�O�G�$�$��"�"�4�7�?�?�4�4��C�C�E�E���
�
!�
!�"	@�S��7�<�<��V�,�,�D��H�T�N�N�N��G�L�L��b�g�&6�&6�s�~�&F�&F�G�G�E��K����.�.�.��K���%�%�%��Y�r�w�|�|�D�K��
�,C�,C�EU�V�V�W�W�
$�
$����A�s�#�#�#�#��K���&�&�&��C�@�@�R�Z�@�@�@�C� $�s�
�Z� 7�C���
�!��u�c�h�h��4�;�;������0�0�2�2�%��(���#�"�(���G�O�O�E�*�*�

,�

,�

,�

,�
�K���&�&�&��!�5�%�1B�"C�+5�+<�(+�(*�����(>�(>�
@�
@�
@�
@�?"	@�"	@�"	@�"	@�"	@�"	@�"	@�"	@�"	@�"	@�"	@�"	@����"	@�"	@�"	@�"	@�"	@�"	@s�)H3K)�)K-�0K-c���|�t��5}tjdd��ddd��n#1swxYwY|�dt|j����dS)Nr�s6'�Cuz"Frozen object named 'x' is invalid)r4r?�_imp�get_frozen_objectr[rJrF)r.rKs  r$�test_issue105979zImportTests.test_issue105979s���
�
�
�{�
+�
+�	:�r��"�3�(8�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:��
�
�:��"�,�'�'�	)�	)�	)�	)�	)s�=�A�AN)r�)*r�r�r�r/r1r8r<r@rLr
rPrUr]rlrorsr�r�r�r�r�r��skip_if_dont_write_bytecoder�r�r�r�r�r�r�r�r�rr�requires_working_threadingr$�unittest�
skipUnlessr{r�rJrNr�r&r$r(r(1sz������&�&�&����<�<�<�F�F�F�K�K�K�h�h�h�����\��"-�-�-�+�+�+�7�7�7�*���7�7�7�*�*�*�X&�&�&�&�P!�!�!�(	3�	3�	3�3�3�3�"$�$�$�L!�(�(�!� �(�.���	/�	/�	/�!�!�!�!� �!�29�9�9��.�.��\�.�"�"�"�!�!�!�c�c�c� �	"�	"��\�	"�1��0�2�2� � �3�2� �D�X�����0�2D�E�E�*@�*@�F�E�*@�X)�)�)�)�)r&r(c�L�eZdZejejdkd��ejepe	d��d�����Z
ejejdkd��ejd�����Z
ejejdkd��ejd�����Zd�ZdS)	�FilePermissionTests�posix�%test meaningful only on posix systemsz$Emscripten's/WASI's umask is a stub.c�,�d}t|��5t��5\}}tj�|��}t|��}tj�|��s|�	d��t
j
|��}ddd��n#1swxYwYddd��n#1swxYwY|�ttj
|j����td|z����dS)N��4__import__ did not result in creation of a .pyc filei�)rrr+r�r�r}rBrG�existsr~r�rE�oct�S_IMODE�st_mode)r.�maskr"rG�cached_pathr��	stat_infos       r$�test_creation_modez&FilePermissionTests.test_creation_modes{����
��
�
�	-�	-��0�0�	-�L�T�4�#�.�:�:�4�@�@�K���%�%�F��7�>�>�+�.�.�
)��	�	�(�)�)�)����,�,�I�
	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	
����T�\�)�*;�<�<�=�=��U�d�U�]�+�+�	-�	-�	-�	-�	-s5�B>�A:B'�B>�'B+	�+B>�.B+	�/B>�>C�Cc�N�d}td��5t��5\}}tj�|��}tj||��t|��t
j�	|��s|�
d��tj|��}ddd��n#1swxYwYddd��n#1swxYwY|�ttj|j����t|����dS)N�rXrY�rrr+r�r�rB�chmodr}rGrZr~r�rEr[r\r])r.�moder"rGr_r`s      r$�test_cached_mode_issue_2051z/FilePermissionTests.test_cached_mode_issue_2051$s{��
��
��
�
�	-�	-�� 1� 1�	-�\�d�D�#�.�:�:�4�@�@�K��H�T�4� � � ��t�����7�>�>�+�.�.�
)��	�	�(�)�)�)����,�,�I�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	
����T�\�)�*;�<�<�=�=�s�4�y�y�I�I�I�I�I�5�C�BB<�0C�<C	�C�C	�C�C�Cc�X�d}td��5t��5\}}tj�|��}tj||��t|��t
j�	|��s|�
d��tj|��}ddd��n#1swxYwYddd��n#1swxYwY|dz}|�ttj|j����t|����dS)N�rXrY�rd)r.rfr"rGr_r`�expecteds       r$�test_cached_readonlyz(FilePermissionTests.test_cached_readonly5s�����
��
�
�	-�	-�� 1� 1�	-�\�d�D�#�.�:�:�4�@�@�K��H�T�4� � � ��t�����7�>�>�+�.�.�
)��	�	�(�)�)�)����,�,�I�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��%�<������T�\�)�*;�<�<�=�=�s�8�}�}�M�M�M�M�Mrhc�*�t��5\}}t|dd���5}|�d��ddd��n#1swxYwYtj|��}tj||j|jdz
f��tj|d��t|��}|�
|jd��tj|d��t|dd���5}|�d	��ddd��n#1swxYwYt|��tj��t|��}|�
|jd
��t|��t|��tj��|dz}tjtj�|��|��t|��}|�
|jd
��ddd��dS#1swxYwYdS)Nr_r`razx = 'original'
i�rj�originalrczx = 'rewritten'
�	rewrittenr�)rrdrerBr�r��st_atime�st_mtimerer}rEr�rr+r,r�renamer�r�)r.r"rGr#�s�m�
bytecode_onlys       r$�test_pyc_always_writablez,FilePermissionTests.test_pyc_always_writableFs����
�
�	/�,�4���d�C�'�2�2�2�
,�a����*�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,����
�
�A��H�T�A�J��
�9�(<�=�>�>�>��H�T�5�!�!�!��4� � �A����Q�S�*�-�-�-��H�T�5�!�!�!��d�C�'�2�2�2�
-�a����+�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-��4�L�L�L��'�)�)�)��4� � �A����Q�S�+�.�.�.��4�L�L�L��4�L�L�L��'�)�)�)� �3�J�M��I�i�n�6�6�t�<�<�m�L�L�L��4� � �A����Q�S�+�.�.�.�3	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/sY�H�A�H�A	�H�A	�B!H�0D�H�D	�H�D	�C!H�H�HN)r�r�r�rQrRrBr"�skipIfrrrar�skip_unless_working_chmodrgrmrwr�r&r$rTrTs"�������X����G�+�@�B�B��X�_�� ��.���
-�
-�	��B�B�
-��X����G�+�@�B�B��(�J�J�)�(�B�B�J��X����G�+�@�B�B��(�N�N�)�(�B�B�N�/�/�/�/�/r&rTc���eZdZdZdZej�e��Z	ej�
e	e��ejzdzZe
j�e��Zd�Zd�Zd�Zd�Zd�Zd	�Zd
�ZdS)�PycRewritingTests�unlikely_module_namez�
import sys
code_filename = sys._getframe().f_code.co_filename
module_filename = __file__
constant = 1
def func():
    pass
func_filename = func.__code__.co_filename
r�c��tjdd�|_tj�|jd��|_tj|j	��t|jdd���5}|�|j
��ddd��n#1swxYwYtj�d|j	��tj��dS)Nr_r`rar)r{rG�sys_pathr|r"r�orig_modulerBr:�dir_namerd�	file_namere�
module_sourcer�r+r,)r.r#s  r$r/zPycRewritingTests.setUpxs����������
��;�?�?�4�+;�T�B�B���
�������
�$�.�#��
8�
8�
8�	(�A�
�G�G�D�&�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(������4�=�)�)�)��#�%�%�%�%�%s�4B�B�"Bc��|jtjdd�<|j�|jtj|j<nt
|j��t|j��t|j	��t|j��dSr*)r~r{rGrr|rrrr��
compiled_namerr�r-s r$r1zPycRewritingTests.tearDown�sy���m���������'�,0�,<�C�K��(�)�)��4�#�$�$�$��t�~�����t�!�"�"�"��t�}�����r&c�x�t��}t|j||��tj|jSr*)rkr}rr{r|)r.�nss  r$�
import_modulezPycRewritingTests.import_module�s0��
�Y�Y���4�#�R��,�,�,��{�4�+�,�,r&c��|���}|�|j|j��|�|j|j��|�|j|j��tj|j=|���}|�|j|j��|�|j|j��|�|j|j��dSr*)	r�rE�module_filenamer��
code_filename�
func_filenamer{r|r�r.r�s  r$�test_basicszPycRewritingTests.test_basics�s���� � �"�"������,�d�n�=�=�=�����*�D�N�;�;�;�����*�D�N�;�;�;��K��(�)�� � �"�"������,�d�n�=�=�=�����*�D�N�;�;�;�����*�D�N�;�;�;�;�;r&c�$�tj|jd���|���}|�|j|j��|�|j|j��|�|j|j��dS�Nzanother_module.py)�dfile)r�r�r�r�rEr�r�r�r�s  r$�test_incorrect_code_namez*PycRewritingTests.test_incorrect_code_name�s�����4�>�1D�E�E�E�E�� � �"�"������,�d�n�=�=�=�����*�D�N�;�;�;�����*�D�N�;�;�;�;�;r&c��d}tj|j|���tj|j��t|j��}t
j��|���}|�	|j
|��|�	|j|��|�	|j|��dSr�)
r�r�r�rBr�rr+r,r�rEr�r�r�)r.r�pyc_filer�s    r$�test_module_without_sourcez,PycRewritingTests.test_module_without_source�s���$����4�>��8�8�8�8�
�	�$�.�!�!�!�"�4�>�2�2���#�%�%�%�� � �"�"������,�h�7�7�7�����*�F�3�3�3�����*�F�3�3�3�3�3r&c���tj|j��t|jd��5}|�d��}t
j|��}ddd��n#1swxYwYt|j	��}tjj}|�
d��}|||<|�t|�����}t|jd��5}|�|��t
j||��ddd��n#1swxYwY|���}|�|jj|j��dS)N�rb�r�)�	co_consts�wb)r�r�r�rdr��read�marshal�load�listr�r+r��__code__�index�replace�tuplere�dumprE�constant�co_filename)r.r#�header�code�	constants�foreign_code�posr�s        r$�test_foreign_codez#PycRewritingTests.test_foreign_code�s�����4�>�*�*�*�
�$�$�d�
+�
+�	#�q��V�V�B�Z�Z�F��<��?�?�D�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#����(�(�	� �.�7���o�o�a� � ��%�	�#���|�|�e�I�&6�&6�|�7�7��
�$�$�d�
+�
+�	"�q�
�G�G�F�O�O�O��L��q�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�� � �"�"�������1�<�3K�L�L�L�L�Ls#�*A%�%A)�,A)�'+D�D"�%D"N)r�r�r�rr�rBrGr�rr�rr�r�r+r�r�r�r/r1r�r�r�r�r�r�r&r$r{r{es�������
)�K��M��w���v�&�&�H�����X�{�3�3�b�i�?�$�F�I��N�4�4�Y�?�?�M�&�&�&����-�-�-�
	<�	<�	<�<�<�<�	4�	4�	4�M�M�M�M�Mr&r{c�n�eZdZdZeZd�Zd�Zd�Ze	j
ejdkd��d���Z
dS)	�
PathsTests)r�utestäöüßutestéèu
test°³²c�j�tj|j��tjdd�|_dSr*)rBr:rGr{�syspathr-s r$r/zPathsTests.setUp�s)��
��������x����{����r&c�Z�t|j��|jtjdd�<dSr*)rrGr�r{r-s r$r1zPathsTests.tearDown�s'���t�y�����l��������r&c��ttj�|jd��dd���5}|�d��ddd��n#1swxYwYt
j�|jdz��td��}|�|j	d��td��dS)Nztest_trailing_slash.pyr_r`raz testdata = 'test_trailing_slash'�/�test_trailing_slash)rdrBrGrrer{r�r}rE�testdatar)r.r#r�s   r$r�zPathsTests.test_trailing_slash�s���
�"�'�,�,�t�y�*B�C�C���)�)�)�	8�,-�
�G�G�6�7�7�7�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	�����	�#�
�&�&�&��.�/�/�������'<�=�=�=��$�%�%�%�%�%s�A�A�Ar%r&c��ttj�|jd��d��5}|�d��ddd��n#1swxYwYtj��tj�|j��}ddl}|�	��}|d}d|�d|�d�}||dd�z
}	tj
|��nU#t$rH}|jtj
tjtjfvr|�d	|�����d}~wwxYwt"j�d|��	t'd
��}n2#t($r%}|�d|�d|����Yd}~nd}~wwxYw|�|jd
��|�|j�|��|j��t7d
��dS)
Nztest_unc_path.pyr_ztestdata = 'test_unc_path'rz\\�\�$r�z#cannot access administrative share �
test_unc_pathz&could not import 'test_unc_path' from z: )rdrBrGrrer+r,r��socket�gethostname�listdirr�r��EPERM�EACCES�ENOENTr�r{r�r}r?r~rEr�r�rHr�r)	r.r#rGr��hn�drive�uncr�r�s	         r$�
test_UNC_pathzPathsTests.test_UNC_path�s?��
�"�'�,�,�t�y�*<�=�=�s�
C�
C�	2�q�
�G�G�0�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2��#�%�%�%��w���t�y�)�)���
�
�
�
�
�
�
!�
!���Q�����R�R����'���t�A�B�B�x���	��J�s�O�O�O�O���	�	�	��w�5�;���e�l�C�C�C��
�
�
���N�O�O�O������		����
	�����3����	"��_�-�-�C�C���	"�	"�	"��I�I�I����a�a�!�
"�
"�
"�
"�
"�
"�
"�
"�����	"����	
������7�7�7������/�/��4�4�c�l�C�C�C�������sB�A�A�A�C$�$
D6�.AD1�1D6�E*�*
F�4F�FN)r�r�r��SAMPLESrrGr/r1r�rQrRr{r�r�r�r&r$r�r��s�������)�G��D�#�#�#�#�#�#�
&�&�&��X�����0�2D�E�E� � �F�E� � � r&r�c�<�eZdZd�ZeZd�Zd�Zd�Zd�Zd�Z	d�Z
dS)	�RelativeImportTestsc�$�td��dS)Nztest.relimport)rr-s r$r1zRelativeImportTests.tearDown�s���� � � � � r&c�X�ddlm}|�t|d����dS)Nr�)�	relimportr�)r�r�r�rO)r.r�s  r$�test_relimport_starz'RelativeImportTests.test_relimport_star�s7�� � � � � � �����	�+@�A�A�B�B�B�B�Br&c����fd�}tdd����|��tdd����|��tdd����|�t|��tdd����|�t|��tt������|�t|��dS)Nc�(��td���dS)Nzfrom . import relimport)ri)r�s�r$�check_relativez:RelativeImportTests.test_issue3221.<locals>.check_relatives����*�B�/�/�/�/�/r&r�ztest.notarealmodule)�__package__r�znotarealpkg.notarealmoduler�)r�)�dictr4r5�objectrg)r.r�r�s  @r$�test_issue3221z"RelativeImportTests.test_issue3221�s����	0�	0�	0�	0�	0��f�/D�
E�
E�
E��������f�/K�
L�
L�
L��������e�.C�
D�
D�
D�����-�~�>�>�>��e�.J�
K�
K�
K�����-�~�>�>�>��f�h�h�
'�
'�
'�����)�^�4�4�4�4�4r&c�4�tjdddd��dS)Nz-W�ignorer�zfoo = 1; from . import foo)r�assert_python_failurer-s r$�)test_parentless_import_shadowed_by_globalz=RelativeImportTests.test_parentless_import_shadowed_by_globals*���+�D�(�D�(�	*�	*�	*�	*�	*r&c��|�t��5ddlm}|�d��ddd��dS#1swxYwYdS)Nr�)�sepz>explicit relative import triggered an implicit absolute import)r4r?rBr�r~)r.r�s  r$�#test_absolute_import_without_futurez7RelativeImportTests.test_absolute_import_without_future!s����
�
�{�
+�
+�	2�	2��������I�I�1�
2�
2�
2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s�A�A�Ac��tj�tj�t��dd��}tdd��5t
|��5|�t��5ddl	}ddd��n#1swxYwY|�
dtj��|�
dtj��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�package2�
submodule1�
submodule2r)
rBrGrrrHrrr4r?r�rjr{r|)r.rGr�s   r$�test_import_from_non_packagez0RelativeImportTests.test_import_from_non_package*s����w�|�|�B�G�O�O�H�5�5�v�z�J�J��
�\�<�
0�
0�	8�	8�-��2E�2E�	8�	8��"�"�;�/�/�
"�
"�!�!�!�!�
"�
"�
"�
"�
"�
"�
"�
"�
"�
"�
"����
"�
"�
"�
"����\�3�;�7�7�7����\�3�;�7�7�7�		8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s[�C?�$C'�?B�C'�B�C'�B�AC'�C?�'C+	�+C?�.C+	�/C?�?D�Dc�H�tddd��5ttj�tj�t��d����5ddl}|jj	ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr�zpackage2.submodule1zpackage2.submodule2rr)
rrrBrGrrrH�package2.submodule1r�r�)r.r�s  r$�!test_import_from_unloaded_packagez5RelativeImportTests.test_import_from_unloaded_package2s��
�Z�!6�8M�
N�
N�	+�	+�
�2�7�<�<������(A�(A�6�J�J�
K�
K�	+�	+�&�&�&�&���*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�	+�	+s6�AB�"A?�3B�?B	�B�B	�B�B�BN)r�r�r�r1r/r�r�r�r�r�r�r�r&r$r�r��s�������!�!�!��E�C�C�C�
5�5�5�:*�*�*�
2�2�2�8�8�8�+�+�+�+�+r&r�c��eZdZd�ZdS)�OverridingImportBuiltinTestsc��ddl}d�}|�|��|��ttdd���5|�|��d��ddd��n#1swxYwYt	t��dd���5|�|��|��ddd��dS#1swxYwYdS)Nrc��ddl}|Sr3�rBr�s r$r�z?OverridingImportBuiltinTests.test_override_builtin.<locals>.foo>s���I�I�I��Ir&r}c��dS�N�r��r�s r$�<lambda>zDOverridingImportBuiltinTests.test_override_builtin.<locals>.<lambda>Cs��!�r&r�c��dSr�r�r�s r$r�zDOverridingImportBuiltinTests.test_override_builtin.<locals>.<lambda>Is��1�r&)rBrEr�builtinsr	rk)r.rBr�s   r$�test_override_builtinz2OverridingImportBuiltinTests.test_override_builtin:sW���	�	�	�	�	�	�	
��������#�#�#�
�x��|�|�
<�
<�	'�	'����S�S�U�U�A�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'��w�y�y�,���
=�
=�	(�	(����S�S�U�U�B�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s#�A(�(A,�/A,�B=�=C�CN)r�r�r�r�r�r&r$r�r�9s#������(�(�(�(�(r&r�c�X�eZdZd�Zd�Zd�Zed���Zej	e
jdkd��eej
ejejed��d�����������Zed	���Zed
���Zd�Zed���Zed
���Zd�Zd�ZdS)�PycacheTestsc�t�tt��td��t|j��dS)Nr!)r
rrrr�r-s r$�_cleanzPycacheTests._cleanPs1���v�����}�����t�{�����r&c�F�tdz|_|���t|jdd���5}t	d|���ddd��n#1swxYwYt
j�dtj	��tj��dS)Nrr_r`raz/# This is a test file written by test_import.pyrvr)rr�r�rdrxr{rGr�rBr�r+r,)r.�fps  r$r/zPycacheTests.setUpUs����u�n������
�
�
�
�$�+�s�W�
5�
5�
5�	N���C�"�M�M�M�M�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N�	N����	N�	N�	N�	N������2�9�%�%�%��#�%�%�%�%�%s�A�A� Ac��tjdtjks
Jd���tjd=|���dS)NrzUnexpected sys.path[0])r{rGrBr�r�r-s r$r1zPycacheTests.tearDown]s>���x��{�b�i�'�'�'�)A�'�'�'��H�Q�K����
�
�
�
�
r&c���|�tj�d����t	t
��|�tj�d����tj�	|j
��}|�tj�|��d�|t
����dS)Nr!z*bytecode file {!r} for {!r} does not exist)�assertFalserBrGrZr}rr�r+r�r�r�r��r.�pyc_paths  r$�test_import_pyc_pathz!PycacheTests.test_import_pyc_pathbs����������
�6�6�7�7�7��6�����������}�5�5�6�6�6��>�3�3�D�K�@�@���������x�0�0� � &��x�� 8� 8�	:�	:�	:�	:�	:r&rUrVzumask is a stubc��td��5tt��ddd��n#1swxYwY|�tj�d����tj�	|j
��}|�tj�|��d�|t����dS)N�r!z"bytecode file {!r} for {!r} exists)
rr}rr�rBrGrZr+r�r�r�r�r�r�s  r$�test_unwritable_directoryz&PycacheTests.test_unwritable_directoryls�����
�
�	�	��v����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��������}�5�5�6�6�6��>�3�3�D�K�@�@����������1�1�!�!'���&�!9�!9�	;�	;�	;�	;�	;s�1�5�5c��tt��tj�|j��}|�tj�	|����tj
|j��tt��tj��|�
ttt��dSr*)r}rr+r�r�r�r�rBrGrZr�r
r,r4r?)r.r�s  r$�test_missing_sourcez PycacheTests.test_missing_source}s���	�6�����>�3�3�D�K�@�@���������x�0�0�1�1�1�
�	�$�+�����v�����#�%�%�%����+�z�6�:�:�:�:�:r&c	�(�tt��t|j��}t	j|j��t
t��tj��tt��}	|�	|j
tj�t	j
��tj�|������t	j|��dS#t	j|��wxYwr*)r}rrr�rBr�rr+r,rErHrGr�getcwd�relpath�r.r�rus   r$�test_missing_source_legacyz'PycacheTests.test_missing_source_legacy�s���	�6����"�4�;�/�/��
�	�$�+�����v�����#�%�%�%��v����	 ����Q�Z��W�\�\�"�)�+�+�r�w���x�7P�7P�Q�Q�
S�
S�
S�
�I�h�������B�I�h�������s
�>A'C;�;Dc��tt��}tj�tdz��}|�|jtj�	tj
��|����dS)Nr)r}rr+r�r�rE�
__cached__rBrGrr�)r.rur�s   r$�test___cached__zPycacheTests.test___cached__�s\���v�����>�3�3�F�U�N�C�C�������r�w�|�|�B�I�K�K��'J�'J�K�K�K�K�Kr&c	���tt��t|j��}t	j|j��t
t��tj��tt��}|�	|j
tj�t	j
��tj�|������dSr*)r}rrr�rBr�rr+r,rErrGrr�r�rs   r$�test___cached___legacy_pycz'PycacheTests.test___cached___legacy_pyc�s���	�6����"�4�;�/�/��
�	�$�+�����v�����#�%�%�%��v�������������b�i�k�k�2�7�?�?�8�3L�3L�M�M�	O�	O�	O�	O�	Or&c��d�}tjd��|�|��ttj�dd��d��5	ddd��n#1swxYwYttj�dd��d��5	ddd��n#1swxYwYt
j��td��}tj	�
tj�dd����}|�|jtj�tj
��|����tj	�
tj�dd����}|�tjdjtj�tj
��|����dS)Nc�`�td��td��td��dS�N�pep3147�pep3147.foo�rrr�r&r$�cleanupz5PycacheTests.test_package___cached__.<locals>.cleanup��2���9�����=�!�!�!��9�����r&r
�__init__.pyr��foo.pyr)rBr:r�rdrGrr+r,r}r�r�rErr�r{r|�r.r
ru�init_pyc�foo_pycs     r$�test_package___cached__z$PycacheTests.test_package___cached__�s��	�	�	�	���������� � � �
�"�'�,�,�y�-�8�8�$�
?�
?�	�	��	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�"�'�,�,�y�(�3�3�T�
:�
:�	�	��	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��#�%�%�%��}�%�%���>�3�3��G�L�L��M�2�2�4�4�������r�w�|�|�B�I�K�K��'J�'J�K�K�K��.�2�2�2�7�<�<�	�8�3T�3T�U�U�������]�3�>�����b�i�k�k�7�;�;�	=�	=�	=�	=�	=�$�A)�)A-�0A-�"B0�0B4�7B4c�z�d�}tjd��|�|��ttj�dd��d��5	ddd��n#1swxYwYttj�dd��d��5	ddd��n#1swxYwYt
j��td��}td��td��t
j��td��}tj
�tj�dd����}|�|j
tj�tj��|����tj
�tj�dd����}|�tjdj
tj�tj��|����dS)Nc�`�td��td��td��dSr	rr�r&r$r
z>PycacheTests.test_package___cached___from_pyc.<locals>.cleanup�rr&r
rr�rr)rBr:r�rdrGrr+r,r}rr�r�rErr�r{r|rs     r$� test_package___cached___from_pycz-PycacheTests.test_package___cached___from_pyc�s=��	�	�	�	���������� � � �
�"�'�,�,�y�-�8�8�$�
?�
?�	�	��	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�"�'�,�,�y�(�3�3�T�
:�
:�	�	��	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��#�%�%�%��}�%�%���}�����y�����#�%�%�%��}�%�%���>�3�3��G�L�L��M�2�2�4�4�������r�w�|�|�B�I�K�K��'J�'J�K�K�K��.�2�2�2�7�<�<�	�8�3T�3T�U�U�������]�3�>�����b�i�k�k�7�;�;�	=�	=�	=�	=�	=rc�4�tt��tt��t|jdd���5}td|���ddd��n#1swxYwYtt��}|�|jd��dS)Nrr`razx = 5rvr�)r}rrrdr�rxrEr�)r.r�rus   r$�test_recompute_pyc_same_secondz+PycacheTests.test_recompute_pyc_same_second�s���	�6�����v����
�$�+�s�W�
5�
5�
5�	$���'��#�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��v���������a� � � � � s�A�A"�%A"N)r�r�r�r�r/r1rOr�rQrRrBr"rry�skip_if_dac_overriderxrr�r�rrrrrrr�r&r$r�r�Ms~���������
&�&�&����
!�:�:�!� �:��X����G�+�@�B�B� ��(��#��X�_�]�$5�6�6�	;�	;�7�6�$�#�)�(�!� �B�B�	;�!�	;�	;�!� �	;�!� � �!� � �$L�L�L�!�
O�
O�!� �
O�!�=�=�!� �=�,=�=�=�6!�!�!�!�!r&r�c��eZdZdZedzZd�Zd�Zeje	e
d��pe
j��dkd��ej
d�����Zd	S)
�TestSymbolicallyLinkedPackage�samplez-taggedc�v�tj|j��tj|j��tjdd�|_tj|j��|�	tj|j��tj�
|jd��}tj|��tj�|��sJ�tj
|j|jd���|�	tj|j��tj��|�tj�|j��d��tj�tj�
|jd����sJ�dS)NrT)�target_is_directory)rr�tagged�package_namer{rG�
orig_sys_pathrBr:r�r�create_empty_filerZ�symlinkrr+r,rE�isdir�isfile)r.�	init_files  r$r/z#TestSymbolicallyLinkedPackage.setUp�sK������%�%�%����*�+�+�+� �X�a�a�a�[���	����������	�(�$�+�6�6�6��G�L�L���m�<�<�	��#�I�.�.�.��w�~�~�i�(�(�(�(�(�	�
�4�;�� 1�t�L�L�L�L����	�(�$�*;�<�<�<��#�%�%�%��������t�'8�9�9�4�@�@�@��w�~�~�b�g�l�l�4�+<�m�L�L�M�M�M�M�M�M�Mr&c�2�|jtjdd�<dSr*)r#r{rGr-s r$r1z&TestSymbolicallyLinkedPackage.tearDown
s���(��������r&�getwindowsversion)�rzWindows Vista or later requiredc�0�dgtjdd�<tj�|j��sJ�tj�tj�|jd����sJ�t
j|j��dS)N�.r)r{rGrBrZr"rr+r�r-s r$�test_symlinked_dir_importablez;TestSymbolicallyLinkedPackage.test_symlinked_dir_importables{���e��������w�~�~�d�/�0�0�0�0�0��w�~�~�b�g�l�l�4�+<�m�L�L�M�M�M�M�M�	��� 1�2�2�2�2�2r&N)r�r�r�r"r!r/r1rQrRrOr{r*r�skip_unless_symlinkr.r�r&r$rr�s��������L�
�I�
%�F�N�N�N�.)�)�)��X���G�C�,�-�-�-�	-� �3� �"�"�f�,�)�+�+��"�3�3�#�"�	+�+�
3�3�3r&rc�&�eZdZd�Zd�Zd�Zd�ZdS)�ImportlibBootstrapTestsc�T�tjd}|�|��dS)N�_frozen_importlib)r{r|r�r�s  r$�test_frozen_importlibz-ImportlibBootstrapTests.test_frozen_importlib!s'���k�-�.����������r&c�4�ddlm}tjd}|�||��|�|jd��|�|jd��|�|j	�
d��|j	��dS)Nr)�
_bootstrapr3zimportlib._bootstrapr+z
_bootstrap.py)r+r6r{r|r�rEr�r�r�rHr�)r.r6r�s   r$�"test_frozen_importlib_is_bootstrapz:ImportlibBootstrapTests.test_frozen_importlib_is_bootstrap%s���(�(�(�(�(�(��k�-�.���
�
�c�:�&�&�&������'=�>�>�>������+�6�6�6������-�-�o�>�>���M�M�M�M�Mr&c�4�ddlm}tjd}|�||��|�|jd��|�|jd��|�|j	�
d��|j	��dS)Nr)�_bootstrap_external�_frozen_importlib_externalzimportlib._bootstrap_externalr+z_bootstrap_external.py)r+r9r{r|r�rEr�r�r�rHr�)r.r9r�s   r$�4test_frozen_importlib_external_is_bootstrap_externalzLImportlibBootstrapTests.test_frozen_importlib_external_is_bootstrap_external-s���1�1�1�1�1�1��k�6�7���
�
�c�.�/�/�/������'F�G�G�G������+�6�6�6������-�-�.F�G�G���V�V�V�V�Vr&c�v�ddlm}tjd}|�|j|j��dS)Nr)�	machineryr3)r+r=r{r|r��
ModuleSpec)r.r=r�s   r$�test_there_can_be_only_onez2ImportlibBootstrapTests.test_there_can_be_only_one5sB��	(�'�'�'�'�'��k�-�.���
�
�i�*�C�N�;�;�;�;�;r&N)r�r�r�r4r7r;r?r�r&r$r1r1sV���������N�N�N�W�W�W�<�<�<�<�<r&r1c�$�eZdZdZd�Zd�Zd�ZdS)�GetSourcefileTestsz�Test importlib._bootstrap_external._get_sourcefile() as used by the C API.

    Because of the peculiarities of the need of this function, the tests are
    knowingly whitebox tests.

    c���tjd��5}d|_tdz}tdz}|�t|��|��ddd��dS#1swxYwYdS)N�*importlib._bootstrap_external._path_isfileTrr�r�patch�return_valuerrEr)r.�_path_isfilerG�expects    r$�test_get_sourcefilez&GetSourcefileTests.test_get_sourcefileHs����Z�D�
E�
E�	<��(,�L�%��F�?�D��e�^�F����_�T�2�2�F�;�;�;�		<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s�?A!�!A%�(A%c���tjd��5}d|_tdz}|�t|��|��ddd��dS#1swxYwYdS)NrCFrrD)r.rGrGs   r$�test_get_sourcefile_no_sourcez0GetSourcefileTests.test_get_sourcefile_no_sourceQs����Z�D�
E�
E�	:��(-�L�%��F�?�D����_�T�2�2�D�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s�5A�A�Ac�`�tdz}|�t|��|��dS)Nz.bad_ext)rrEr)r.rGs  r$�test_get_sourcefile_bad_extz.GetSourcefileTests.test_get_sourcefile_bad_extYs2���
�"�������.�.��5�5�5�5�5r&N)r�r�r��__doc__rIrKrMr�r&r$rArA>sK��������<�<�<�:�:�:�6�6�6�6�6r&rAc��eZdZd�Zd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zed���Zejed��d���ZdS)�ImportTracebackTestsc��tjt��tjdd�|_tj�dt��dSr3)rBr:rr{rG�old_pathr�r-s r$r/zImportTracebackTests.setUpbs?��
�������������
������6�"�"�"�"�"r&c�Z�|jtjdd�<tt��dSr*)rRr{rGrrr-s r$r1zImportTracebackTests.tearDowngs"���m��������v�����r&rc�0�tj�t||z��}t	|dd���5}|�|��ddd��n#1swxYwY|�t|��tj	��|S)Nr_r`ra)
rBrGrrrdrer�rr+r,)r.r��contentsr��fnamer#s      r$�
create_modulez"ImportTracebackTests.create_moduleks�������V�S�3�Y�/�/��
�%��w�
/�
/�
/�	�1�
�G�G�H����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	������$�$�$��#�%�%�%��s�A�A!�$A!c�F�g}|r?|jj}|j}|r||dkr|�|��|j}|�?|�t
|��t
|��|��t||��D]\}}|�||���dS)Nr�)	�tb_framerr�r��tb_nextrE�len�zipr[)r.�tb�files�
deduped_filesr��fn�pats       r$�assert_tracebackz%ImportTracebackTests.assert_tracebackss����
��	��;�%�D��!�B� �
)�B�-��*;�$;�$;��$�$�R�(�(�(���B��	�	
����]�+�+�S��Z�Z��G�G�G��=�%�0�0�	#�	#�G�B���M�M�#�r�"�"�"�"�	#�	#r&c��	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|t
g��dS)Nr�#ImportError should have been raised)�nonexistent_xyzzyr~r?�
__traceback__rbrH)r.rer�r]s    r$�test_nonexistent_modulez,ImportTracebackTests.test_nonexistent_modules}��	=�$�$�$�$�
�I�I�;�<�<�<�<���	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�*�-�-�-�-�-s��
7�2�7c���|�dd��	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|tdg��dS)Nr�zimport nonexistent_xyzzyrrdr)rWr�r~r?rfrbrH�r.r�r�r]s    r$�test_nonexistent_module_nestedz3ImportTracebackTests.test_nonexistent_module_nested�s������5�"<�=�=�=�	=��J�J�J�
�I�I�;�<�<�<�<���	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�X�"6�7�7�7�7�7��2�
A
�A�A
c���|�dd��	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|tdg��dS)Nr��1/0r�)ZeroDivisionError should have been raisedr�rWr�r~r�rfrbrHris    r$�test_exec_failurez&ImportTracebackTests.test_exec_failure�s������5�%�(�(�(�	C��J�J�J�
�I�I�A�B�B�B�B��!�	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�X�"6�7�7�7�7�7rkc��|�dd��|�dd��	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|tddg��dS)	Nr�z
import bar�barrmrrnr�bar.pyroris    r$�test_exec_failure_nestedz-ImportTracebackTests.test_exec_failure_nested�s������5�,�/�/�/����5�%�(�(�(�	C��J�J�J�
�I�I�A�B�B�B�B��!�	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�X�x�"@�A�A�A�A�As�A�
A#�A�A#c���|�dd��	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|tg��dS)Nr�zinvalid syntax is invalidrz#SyntaxError should have been raised)rWr�r~�SyntaxErrorrfrbrHris    r$�test_syntax_errorz&ImportTracebackTests.test_syntax_error�s������5�"=�>�>�>�	=��J�J�J�
�I�I�;�<�<�<�<���	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�*�-�-�-�-�-rkc�X�d}|�t|��tj�t
|��}tj|��tj�|d��}t|dd���5}|�|��ddd��n#1swxYwYtj�|d��}t|dd���5}|�|��ddd��n#1swxYwYtj
��||fS)N�_parent_foorr_r`rars)r�rrBrGrrr:rdrer+r,)r.�parent�child�pkg_name�pkg_path�	init_pathr#�bar_paths        r$�_setup_broken_packagez*ImportTracebackTests._setup_broken_package�sp�� �������)�)�)��7�<�<���1�1��
�������G�L�L��=�9�9�	�
�)�S�7�
3�
3�
3�	�q�
�G�G�F�O�O�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��7�<�<��(�3�3��
�(�C�'�
2�
2�
2�	�a�
�G�G�E�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��#�%�%�%��(�"�"s$�	B+�+B/�2B/�(D
�
D�Dc���|�dd��\}}	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|t|g��dS)Nr�rmrrn�r��_parent_foo.barr~r�rfrbrH�r.r~rryr�r]s      r$�test_broken_submodulez*ImportTracebackTests.test_broken_submodule�s���"�8�8��U�C�C��	�8�	C�"�"�"�"�
�I�I�A�B�B�B�B��!�	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�X�"6�7�7�7�7�7��5�
A�A�Ac���|�dd��\}}	ddlm}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|t|g��dS)Nr�rmr�rrrd�r�ryrrr~r�rfrbrH�r.r~rrrr�r]s      r$�test_broken_fromz%ImportTracebackTests.test_broken_from�s���"�8�8��U�C�C��	�8�	=�'�'�'�'�'�'�
�I�I�;�<�<�<�<��!�	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�X�"6�7�7�7�7�7��7�
A�A
�
Ac���|�dd��\}}	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|t|g��dS)Nrmr�rrnr�r�s      r$�test_broken_parentz'ImportTracebackTests.test_broken_parent�s���"�8�8���C�C��	�8�	C�"�"�"�"�
�I�I�A�B�B�B�B��!�	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�Y�"7�8�8�8�8�8r�c���|�dd��\}}	ddlm}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|t|g��dS)Nrmr�rr�rnr�r�s      r$�test_broken_parent_fromz,ImportTracebackTests.test_broken_parent_from�s���"�8�8���C�C��	�8�	C�'�'�'�'�'�'�
�I�I�A�B�B�B�B��!�	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�Y�"7�8�8�8�8�8r�c���|�dd��tjd}dt|j��vr
|jj}nd}	d�}||j_	ddl}|�d��n#t$r}|j	}Yd}~nd}~wwxYw|�
|tdtg��|�	|j`dS||j_dS#|�|j`n||j_wxYw)	Nr�r�r:�load_modulec��ddzdS)Nr�rr�)r�s r$�exec_modulez9ImportTracebackTests.test_import_bug.<locals>.exec_module�s���!����r&rrnz<frozen importlib)rWr{r|�vars�SourceLoaderr�r�r~r�rfrbrH)r.r+�old_exec_moduler�r�r�r]s       r$�test_import_bugz$ImportTracebackTests.test_import_bug�s:��	
���5�"�%�%�%��K� <�=�	��D��!7�8�8�8�8�'�4�@�O�O�"�O�	E�
�
�
�1<�I�"�.�
G��
�
�
��	�	�E�F�F�F�F��%�
%�
%�
%��_�����������
%����
�!�!�"�x�1D�h�&O�P�P�P��&��*�6�6�6�5D�	�&�2�2�2���&��*�6�6�5D�	�&�2�D�D�D�Ds6�C�A9�#C�9
B�B�
C�B�&C�C+zneed TESTFN_UNENCODABLEc��tjdtd��}|�t|��|dd�}tjdd|zd���dS)Nr��pass���r�zmod = __import__(%a)F)�
__isolated)rr�rr�rr�)r.�pynamer"s   r$�test_unencodable_filenamez.ImportTracebackTests.test_unencodable_filenamesk���*�2�/A�6�J�J�������'�'�'��c�r�c�{���&�t�-C�d�-J�27�	9�	9�	9�	9�	9�	9r&N)r)r�r�r�r/r1rWrbrgrjrprtrwr�r�r�r�r�r
r�rQrRrr�r�r&r$rPrP`s:������#�#�#�
�������
#�
#�
#�.�.�.�8�8�8�8�8�8�	B�	B�	B�.�.�.�
#�
#�
#�8�8�8�8�8�8�9�9�9�9�9�9��E�E��\�E�4�X��+�-F�G�G�9�9�H�G�9�9�9r&rPc�T�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
S)�CircularImportTestszQSee the docstrings of the modules being imported for the purpose of the
    test.c��ttj�����D]$}|�d��r
tj|=�%dS)zSMake sure no modules pre-exist in sys.modules which are being used to
        test.z&test.test_import.data.circular_importsN)r�r{r|�keysr�)r.�keys  r$r1zCircularImportTests.tearDownsS�����(�(�*�*�+�+�	%�	%�C��~�~�F�G�G�
%��K��$��	%�	%r&c�\�	ddl}dS#t$r|�d��YdSwxYw)Nrz/circular import through relative imports failed)�,test.test_import.data.circular_imports.basicr?r~�r.r�s  r$�test_directzCircularImportTests.test_directsU��	I�?�?�?�?�?�?���	I�	I�	I��I�I�G�H�H�H�H�H�H�	I������+�+c�\�	ddl}dS#t$r|�d��YdSwxYw)Nrz@relative import in module contributing to circular import failed)�/test.test_import.data.circular_imports.indirectr?r~r�s  r$�
test_indirectz!CircularImportTests.test_indirect"s^��	'�B�B�B�B�B�B���	'�	'�	'��I�I�&�
'�
'�
'�
'�
'�
'�	'���r�c�\�	ddl}dS#t$r|�d��YdSwxYw)Nrz-circular import involving a subpackage failed)�1test.test_import.data.circular_imports.subpackager?r~r�s  r$�test_subpackagez#CircularImportTests.test_subpackage)sU��	G�D�D�D�D�D�D���	G�	G�	G��I�I�E�F�F�F�F�F�F�	G���r�c��	ddlmcmcmcm}n%#t
$r|�d��YnwxYwddlm}|�	|j|j��dS)Nrz9circular import with rebinding of module attribute failed)r�)
�0test.test_import.data.circular_imports.rebindingr�r�circular_imports�	rebindingr?r~�-test.test_import.data.circular_imports.subpkgr�r�)r.r�r�s   r$�test_rebindingz"CircularImportTests.test_rebinding/s���	S�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P���	S�	S�	S��I�I�Q�R�R�R�R�R�	S����F�F�F�F�F�F��
�
�d�i���0�0�0�0�0s��4�4c�\�	ddl}dS#t$r|�d��YdSwxYw)Nrz9circular import with binding a submodule to a name failed)�.test.test_import.data.circular_imports.bindingr?r~r�s  r$�test_bindingz CircularImportTests.test_binding7sU��	S�A�A�A�A�A�A���	S�	S�	S��I�I�Q�R�R�R�R�R�R�	S���r�c��ddl}ddl}dSr3)�*test.test_import.data.circular_imports.use�-test.test_import.data.circular_imports.sourcer�s  r$�test_crossreference1z(CircularImportTests.test_crossreference1=s ��9�9�9�9�<�<�<�<�<�<r&c�J�|�t��5}ddl}ddd��n#1swxYwYt|j��}|�d|��|�d|��|�d|��|�d|��dS)Nrz-test.test_import.data.circular_imports.source�spamzpartially initialized modulezcircular import)r4r�r�rJrFr[)r.rKr��errmsgs    r$�test_crossreference2z(CircularImportTests.test_crossreference2As���
�
�
�~�
.�
.�	A�"�@�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A��R�\�"�"���
�
�E�v�N�N�N��
�
�f�f�%�%�%��
�
�4�f�=�=�=��
�
�'��0�0�0�0�0��,�0�0c���|�t��5}ddl}ddd��n#1swxYwY|�dt	|j����dS)Nrz�cannot import name 'b' from partially initialized module 'test.test_import.data.circular_imports.from_cycle1' (most likely due to a circular import))r4r?�2test.test_import.data.circular_imports.from_cycle1r[rJrF�r.rKr�s   r$�test_circular_from_importz-CircularImportTests.test_circular_from_importJs���
�
�
�{�
+�
+�	F�r�E�E�E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F��
�
�
5�
�����		
�	
�	
�	
�	
r�c���|�t��5}ddl}ddd��n#1swxYwY|�dt	|j����dS)Nrz�cannot access submodule 'parent' of module 'test.test_import.data.circular_imports.subpkg2' (most likely due to a circular import))r4r��5test.test_import.data.circular_imports.subpkg2.parentr[rJrFr�s   r$� test_absolute_circular_submodulez4CircularImportTests.test_absolute_circular_submoduleTs���
�
�
�~�
.�
.�	I�"�H�H�H�H�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I�	I����	I�	I�	I�	I��
�
�
5�
�����		
�	
�	
�	
�	
r�c��|�td��|�td��ddlmcmcm}|�t��5ddlm}ddd��n#1swxYwY|�	t|��t��|�t|��t��|�
t��5d|_ddd��dS#1swxYwYdS)Nz test.test_import.data.unwritablez"test.test_import.data.unwritable.xrr��*)r�r� test.test_import.data.unwritabler�r�
unwritable�assertWarns�
ImportWarningr��assertNotEqual�typerrEr4r�)r.r�r�s   r$�test_unwritable_modulez*CircularImportTests.test_unwritable_module^s������� B�C�C�C����� D�E�E�E�=�=�=�=�=�=�=�=�=�=�=�=�
�
�
�m�
,�
,�	;�	;�:�:�:�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	
���D��,�,�j�9�9�9�����a���*�-�-�-�
�
�
�~�
.�
.�	�	��J�L�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s$�A0�0A4�7A4�%C:�:C>�C>N)r�r�r�rNr1r�r�r�r�r�r�r�r�r�r�r�r&r$r�r�s�������
�
�%�%�%�I�I�I�'�'�'�G�G�G�1�1�1�S�S�S�=�=�=�1�1�1�
�
�
�
�
�
�����r&r��__main__)Dr�r�r?�importlib.utilr+�importlib._bootstrap_externalrr�rBr�ryr=r�rAr{r�rr	rQrrLr�rrrrr	r
rr�test.support.import_helperr
rrrrrr�test.support.os_helperrrrrrr�test.test_importlib.utilr�typesrrx�dont_write_bytecoderOr%�TestCaser(rTr{r�r�r�r�rr1rArPr�r��mainr�r&r$�<module>r�s�������������������9�9�9�9�9�9�����	�	�	�	�����
�
�
�
�
�
�
�
���������
�
�
�
���������������������������"�"�"�"�"�"�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
� � � � � � � � � � � � � � � � � � �4�4�4�4�4�4�4�4�4�4�4�4�&�&�&�&�&�&�)�)�)�)�)�)�,�,�,�,�,�,�������.�h�o���4�6�6�����W)�W)�W)�W)�W)�(�#�W)�W)�W)�t�V/�V/�V/�V/�V/�(�+�V/�V/���V/�rVM�VM�VM�VM�VM��)�VM�VM�VM�r3 �3 �3 �3 �3 ��"�3 �3 �3 �lB+�B+�B+�B+�B+�(�+�B+�B+�B+�J(�(�(�(�(�8�#4�(�(�(�(_!�_!�_!�_!�_!�8�$�_!�_!�_!�D+3�+3�+3�+3�+3�H�$5�+3�+3�+3�\�<�<�<�<�<�h�/�<�<���<�@�6�6�6�6�6��*�6�6���6�Bm9�m9�m9�m9�m9�8�,�m9�m9�m9�`Y�Y�Y�Y�Y�(�+�Y�Y�Y�x�z����H�M�O�O�O�O�O��r&