HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/test_import/__pycache__/__init__.cpython-311.pyc
�

��VcA����ddlZddlZddlZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZmZmZmZmZmZmZddlmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*ddlm+Z+dd	lm,Z,dd
l-m.Z.ddl/m0Z0ej1ej2d��Z3d
�Z4ej5d)d���Z6Gd�dej7��Z8e3Gd�dej7����Z9Gd�dej7��Z:Gd�dej7��Z;Gd�dej7��Z<Gd�dej7��Z=Gd�dej7��Z>Gd�dej7��Z?eGd �d!ej7����Z@eGd"�d#ej7����ZAGd$�d%ej7��ZBGd&�d'ej7��ZCeDd(krejE��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�
DirsOnSysPath�CleanImport)�TESTFN�rmtree�
temp_umask�TESTFN_UNENCODABLE�temp_dir)�
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  �-D:\Python311\Lib\test\test_import\__init__.py�remove_filesr%'sS���U�l��V�m��V�m��[� �"����	�q�	�	�	�	�
�=�������c#�K�|pd}t��5}tj|||��}tj�|d��}	tj�d|��||fV�tj�|��|�|tj|<nN|tjvr
tj|=n2#|�|tj|<n|tjvr
tj|=wxYwddd��dS#1swxYwYdS)N�spamr)	rr�make_script�sys�modules�pop�path�insert�remove)r"�source�tempdirr.�
old_modules     r$�_ready_to_importr40sT�����>�6�D�	���&�w��(��$��?�?���[�_�_�T�4�0�0�
�	&��H�O�O�A�w�'�'�'���*�����H�O�O�G�$�$�$��
&�$.���D�!�!����$�
&��K��%����
&�$.���D�!�!����$�
&��K��%�%�%�%�%�&�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&�&�&s*�7C?�
AC�.C?�/C/�/C?�?D�Dc�~�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"S)$�ImportTestsc�T�tt��tj��dS�N)r%r�	importlib�invalidate_caches��selfs r$�setUpzImportTests.setUpGs%���V�����#�%�%�%�%�%r&c�.�tt��dSr8)rrr;s r$�tearDownzImportTests.tearDownKs���v�����r&c�t�|�t��5ddl}ddd��dS#1swxYwYdS�Nr)�assertRaises�ModuleNotFoundError�(something_that_should_not_exist_anywhere�r<rDs  r$�&test_import_raises_ModuleNotFoundErrorz2ImportTests.test_import_raises_ModuleNotFoundErrorNs���
�
�
�2�
3�
3�	<�	<�;�;�;�;�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<��-�1�1c�x�|�t��5ddlm}ddd��dS#1swxYwYdS)Nr)�blah)rBrCrDrI)r<rIs  r$�:test_from_import_missing_module_raises_ModuleNotFoundErrorzFImportTests.test_from_import_missing_module_raises_ModuleNotFoundErrorRs���
�
�
�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)rD)rB�ImportErrorr9rDrEs  r$�0test_from_import_missing_attr_raises_ImportErrorz<ImportTests.test_from_import_missing_attr_raises_ImportErrorVs���
�
�
�{�
+�
+�	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�	KrKc��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\))rrPrBrMrR�assertEqual�	exceptionr"r.�__file__�assertRegex�str)r<rP�cmrRs    r$�/test_from_import_missing_attr_has_name_and_pathz;ImportTests.test_from_import_missing_attr_has_name_and_pathZsG��
��
�
�	,�	,��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)NrrQ�	_testcapirUzCcannot import name 'i_dont_exist' from '_testcapi' \(.*\.(so|pyd)\)zEcannot import name 'i_dont_exist' from '_testcapi' (unknown location))r[rBrMrRrSrTr"�hasattrr.rUrVrW)r<r[rXrRs    r$�2test_from_import_missing_attr_has_name_and_so_pathz>ImportTests.test_from_import_missing_attr_has_name_and_so_pathcs7������
�
�
�{�
+�
+�	/�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)NrrQ�_warning)	rBrMr_rRrSrTr"�assertIsNoner.�r<rXrRs   r$�&test_from_import_missing_attr_has_namez2ImportTests.test_from_import_missing_attr_has_nameus���
�
�
�{�
+�
+�	.�r�-�-�-�-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	
�����*�J�7�7�7����"�,�+�,�,�,�,�,��.�2�2c���|�t��5}ddlm}ddd��n#1swxYwY|�|jjddh��|�|j��dS)NrrQ�	posixpath�ntpath)rBrM�os.pathrR�assertInrTr"�assertIsNotNoneras   r$�/test_from_import_missing_attr_path_is_canonicalz;ImportTests.test_from_import_missing_attr_path_is_canonical|s���
�
�
�{�
+�
+�	-�r�,�,�,�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��
�
�b�l�'�+�x�)@�A�A�A����R�\�*�*�*�*�*rcc��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)	�rer4�open�write�assertRaisesRegex�	TypeError�escape�exec�assertNotIn)r<rpr"r.r#�globalss      r$�"test_from_import_star_invalid_typez.ImportTests.test_from_import_star_invalid_type�s`���	�	�	�
�
�
�	7�<�D�$��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�<�D�$��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#1swxYwYdSrA)rBrM�RAnDoM)r<r{s  r$�test_case_sensitivityz!ImportTests.test_case_sensitivity�s����
�
�{�
+�
+�	�	��M�M�M�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	rGc��ddlm}dS)Nr)�double_const)�testr~)r<r~s  r$�test_double_constzImportTests.test_double_const�s��	&�%�%�%�%�%�%�%r&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 rrlrmrnz)# This tests Python's ability to import azfile.��filei�za =zb =zimport from z	 failed: z'module loaded (%s) but contents invalid)rrrq�print�random�	randranger+r,r9r:�
__import__rM�failrS�a�br
r)	�extr1�pycr#r�r��mod�errr<s	        �r$�test_with_extensionz4ImportTests.test_import.<locals>.test_with_extension�s4����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+r.r/rP�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)Nrrlrmrnzd = [
i�z"",
�]r'zimport ����c�o)rqrr�range�
py_compile�compilerr+r.�appendr9r:rrv�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)
Nrrlrmrnza = 1/0r�r)���z'damaged module in sys.modules on %i try)rrqr�r+r.r/rPr�r9r:r,rB�ZeroDivisionErrorr�rwr%)r<r1r#r�s    r$�test_failing_import_sticksz&ImportTests.test_failing_import_sticks�sj���%���
�&�#��
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)NrrU)r�test.support�assertIs�__name__�
assertTruer\�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�	�2�2�2�2�2�2�2�2�2�
��F�A��"�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�pyrlrmrnz
a = 1
b=2
rr�z!module has wrong attribute valuesr�za = 10
b=20//0
z$expected module to be in sys.modulesr�)rrP�extseprqrrr+r.r/r�r�rhr,rSr�r�r%rBr�r9�reload�getrir)r<r1r#r�s    r$�test_failing_reloadzImportTests.test_failing_reload&sb���"�)�#�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)Nrrlrmrnztest = None
rr)rrqrrr+r.r/rPr�r�r�rU�endswithr0r,rr9r:�splitextrSr%)r<r1r#r��baser�s      r$�test_file_to_sourcezImportTests.test_file_to_sourceLs����%���
�&�#��
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 {})
rPr.�abspathrr+�getfilesystemencoding�encode�UnicodeEncodeError�skipTest�formatrBrMr�)r<r.ror�s    r$�test_import_by_filenamez#ImportTests.test_import_by_filenameds���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())
            )rr*r�textwrap�dedent�assert_python_ok)r<�testfns  r$�!test_import_in_del_does_not_crashz-ImportTests.test_import_in_del_does_not_crashnsE���*�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)Nrrrlrmrn)���r�z-cannot set modification time to large integer�	EOVERFLOW�EINVALz2cannot set modification time to large integer ({}))r+r.r/rPr�rr9�util�cache_from_sourcerq�utime�
OverflowErrorr��OSError�errno�getattrr�r��statr%)r<r1�compiledr#�es     r$�test_timestamp_overflowz#ImportTests.test_timestamp_overflowys���	�����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����
�
�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�httprI)�fromlistzfromlist must allow bogus names)r�rMr�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�communicaterh)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)rsrM�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�)rsrMrpr�)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�r8)�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,rBrMrrrSrWrT)r<r�module_namerXrs     r$rz+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)rrPrBrMrr�)r<rs  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�sD�����
 �5�<�#7�>�#I�
 ��
�3������
 �
 �
 �
 r&r�datac���tj�������	ddl}n#t$r}|�Yd}~nd}~wwxYwtjd��dSrA)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+r.r/rP�join�dirnamerUr�r�Eventr�
start_threads�setrrr,r-)r<r��threadsrrrrs   @@@@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�)�upperrP�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+�	dllhandler9r��	find_spec�originrPr.r"r#r�rr�mkdir�basename�
executable�shutil�copy�globru�prefixr2r�
subprocess�
check_call�STDOUT)
r<r,�dllname�pydname�depname�tmp�tmp2�pyexer#r7s
          r$�test_dll_dependency_importz&ImportTests.test_dll_dependency_import�s���-�-�-�-�-�-�#�#�C�M�2�2���.�*�*�:�6�6�=���'�,�,��G�O�O�G�$�$��"�"�4�7�?�#B�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-N)r�))r�r�r�r=r?rFrJrNrYr
r]rbrjryr|r�r�r�r�r�r�r��skip_if_dont_write_bytecoder�r�r�r�r�r�r�r�rrr�requires_working_threadingr(�unittest�
skipUnlessr+r�rMr�r&r$r6r6Esl������&�&�&����<�<�<�F�F�F�K�K�K�h�h�h�����\��"-�-�-�+�+�+�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�*@�*@�*@r&r6c�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�)rr4r9r�r�r�rPr.�existsr�r�rS�oct�S_IMODE�st_mode)r<�maskr"r.�cached_pathr��	stat_infos       r$�test_creation_modez&FilePermissionTests.test_creation_modes|����
��
�
�	-�	-�/�1�1�	-�\�d�D�#�.�:�:�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�rWrX�rr4r9r�r�rP�chmodr�r.rYr�r�rSrZr[r\)r<�moder"r.r^r_s      r$�test_cached_mode_issue_2051z/FilePermissionTests.test_cached_mode_issue_2051.s|��
��
��
�
�	-�	-� 0� 2� 2�	-�l�t�T�#�.�:�:�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�rWrX�rc)r<rer"r.r^r_�expecteds       r$�test_cached_readonlyz(FilePermissionTests.test_cached_readonly?s�����
��
�
�	-�	-� 0� 2� 2�	-�l�t�T�#�.�:�:�4�@�@�K��H�T�4� � � ��t�����7�>�>�+�.�.�
)��	�	�(�)�)�)����,�,�I�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-��%�<������T�\�)�*;�<�<�=�=�s�8�}�}�M�M�M�M�Mrgc�*�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)Nrlrmrnzx = 'original'
i�ri�originalrbzx = 'rewritten'
�	rewrittenr�)r4rqrrrPr�r��st_atime�st_mtimerdr�rSr�rr9r:r�renamer�r�)r<r"r.r#�s�m�
bytecode_onlys       r$�test_pyc_always_writablez,FilePermissionTests.test_pyc_always_writablePs����
�
�	/�<�D�$��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�rPrQrPr"�skipIfrrr`r�skip_unless_working_chmodrfrlrvr�r&r$rSrSs"�������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&rSc���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)Nrlrmrnr)r+r.�sys_pathr,r-r�orig_modulerPr=�dir_namerq�	file_namerr�
module_sourcer/r9r:)r<r#s  r$r=zPycRewritingTests.setUp�s����������
��;�?�?�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��dSr8)r}r+r.r~r,rrrr��
compiled_namerrr;s r$r?zPycRewritingTests.tearDown�s{���m���������	%�,0�,<�C�K��(�)�)��4�#�$�$�$��t�~�����t�!�"�"�"��t�}�����r&c�x�t��}t|j||��tj|jSr8)rxr�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��dSr8)	r�rS�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�rSr�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�rPr0rr9r:r�rSr�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�rqr��read�marshal�load�listr�r9r��__code__�index�replace�tuplerr�dumprS�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�rPr.r�rrr"r�r�r9r�r�r�r=r?r�r�r�r�r�r�r&r$rzrzos�������
)�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&rzc�n�eZdZdZeZd�Zd�Zd�Ze	j
ejdkd��d���Z
dS)	�
PathsTests)rutestäöüßutestéèu
test°³²c�j�tj|j��tjdd�|_dSr8)rPr=r.r+�syspathr;s r$r=zPathsTests.setUp�s)��
��������x����{����r&c�Z�t|j��|jtjdd�<dSr8)rr.r�r+r;s r$r?zPathsTests.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.pyrlrmrnz testdata = 'test_trailing_slash'�/�test_trailing_slash)rqrPr.r"rrr+r�r�rS�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.pyrlztestdata = 'test_unc_path'rz\\�\�$r�z#cannot access administrative share �
test_unc_pathz&could not import 'test_unc_path' from z: )rqrPr.r"rrr9r:r��socket�gethostname�listdirr�r��EPERM�EACCES�ENOENTr�r+r/r�rMr�rSr�r�rUr�r)	r<r#r.r��hn�drive�uncr�r�s	         r$�
test_UNC_pathzPathsTests.test_UNC_path�sB��
�"�'�,�,�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�
P��
�
�
���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��SAMPLESrr.r=r?r�rPrQr+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$r?zRelativeImportTests.tearDowns���� � � � � r&c�X�ddlm}|�t|d����dS)Nr�)�	relimportr�)r'r�r�r\)r<r�s  r$�test_relimport_starz'RelativeImportTests.test_relimport_stars7�� � � � � � �����	�+@�A�A�B�B�B�B�Br&c����fd�}tdd����|��tdd����|��tdd����|�t|��tdd����|�t|��tt������|�t|��dS)Nc�(��td���dS)Nzfrom . import relimport)rv)r�s�r$�check_relativez:RelativeImportTests.test_issue3221.<locals>.check_relatives����*�B�/�/�/�/�/r&rztest.notarealmodule)�__package__r�znotarealpkg.notarealmoduler�)r�)�dictrBrC�objectrt)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_global&s*���+�D�(�D�(�	*�	*�	*�	*�	*r&c��|�t��5ddlm}|�d��ddd��dS#1swxYwYdS)Nr�)�sepz>explicit relative import triggered an implicit absolute import)rBrMrPr�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)
rPr.r"r#rUrrrBrMr�rwr+r,)r<r.r�s   r$�test_import_from_non_packagez0RelativeImportTests.test_import_from_non_package4s����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)
rrrPr.r"r#rU�package2.submodule1r�r�)r<r�s  r$�!test_import_from_unloaded_packagez5RelativeImportTests.test_import_from_unloaded_package<s��
�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�r?r=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}|SrA�rPr�s r$r�z?OverridingImportBuiltinTests.test_override_builtin.<locals>.fooHs���I�I�I��Ir&r�c��dS�N�r��r�s r$�<lambda>zDOverridingImportBuiltinTests.test_override_builtin.<locals>.<lambda>Ms��!�r&r�c��dSr�r�r�s r$r�zDOverridingImportBuiltinTests.test_override_builtin.<locals>.<lambda>Ss��1�r&)rPrSr�builtinsr	rx)r<rPr�s   r$�test_override_builtinz2OverridingImportBuiltinTests.test_override_builtinDsW���	�	�	�	�	�	�	
��������#�#�#�
�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�Cs#������(�(�(�(�(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
rrrr1r;s r$�_cleanzPycacheTests._cleanZs1���v�����}�����t�{�����r&c�F�tdz|_|���t|jdd���5}t	d|���ddd��n#1swxYwYt
j�dtj	��tj��dS)Nrrlrmrnz/# This is a test file written by test_import.pyr�r)rr1r�rqr�r+r.r/rPr�r9r:)r<�fps  r$r=zPycacheTests.setUp_s����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+r.rPr�r�r;s r$r?zPycacheTests.tearDowngs>���x��{�b�i�'�A�A�)A�A�A�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)�assertFalserPr.rYr�rr�r9r�r�r1r��r<�pyc_paths  r$�test_import_pyc_pathz!PycacheTests.test_import_pyc_pathls����������
�6�6�7�7�7��6�����������}�5�5�6�6�6��>�3�3�D�K�@�@���������x�0�0� � &��x�� 8� 8�	:�	:�	:�	:�	:r&rTrUzumask 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�rPr.rYr9r�r�r1r�r�r�s  r$�test_unwritable_directoryz&PycacheTests.test_unwritable_directoryvs�����
�
�	�	��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��dSr8)r�rr9r�r�r1r�rPr.rYr0r
r:rBrM)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|��wxYwr8)r�rrr1rPr0rr9r:rSrUr.r"�getcwd�relpath�r<r�rts   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�rr9r�r�rS�
__cached__rPr.r"r�)r<rtr�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�|������dSr8)r�rrr1rPr0rr9r:rSrr.r"r�r�r�s   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
)rPr=rrqr.r"r9r:r�r�r�rSrr�r+r,�r<rrt�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��dSrrr�r&r$rz>PycacheTests.test_package___cached___from_pyc.<locals>.cleanup�r
r&r	rr�rr
)rPr=rrqr.r"r9r:r�rr�r�rSrr�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)Nr�rmrnzx = 5r�r�)r�rrrqr1r�rSr�)r<r�rts   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=r?rNr�rPrQrPr"rrx�skip_if_dac_overriderwrr�r�rrrrrrr�r&r$r�r�Ws~���������
&�&�&����
!�:�:�!� �:��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+r.�
orig_sys_pathrPr=rr"�create_empty_filerY�symlinkrr9r:rS�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�<dSr8)r"r+r.r;s r$r?z&TestSymbolicallyLinkedPackage.tearDowns���(��������r&�getwindowsversion)�rzWindows Vista or later requiredc�0�dgtjdd�<tj�|j��sJ�tj�tj�|jd����sJ�t
j|j��dS)N�.r)r+r.rPrYr!r"r9r�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=r?rPrQr\r+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)�
_bootstrapr2zimportlib._bootstrapr9z
_bootstrap.py)r9r5r+r,r�rSr�r�r�rUr�)r<r5r�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_externalr9z_bootstrap_external.py)r9r8r+r,r�rSr�r�r�rUr�)r<r8r�s   r$�4test_frozen_importlib_external_is_bootstrap_externalzLImportlibBootstrapTests.test_frozen_importlib_external_is_bootstrap_external7s���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)�	machineryr2)r9r<r+r,r��
ModuleSpec)r<r<r�s   r$�test_there_can_be_only_onez2ImportlibBootstrapTests.test_there_can_be_only_one?sB��	(�'�'�'�'�'��k�-�.���
�
�i�*�C�N�;�;�;�;�;r&N)r�r�r�r3r6r:r>r�r&r$r0r0'sV���������N�N�N�W�W�W�<�<�<�<�<r&r0c�$�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_valuerrSr)r<�_path_isfiler.�expects    r$�test_get_sourcefilez&GetSourcefileTests.test_get_sourcefileRs����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)NrBFrrC)r<rFr.s   r$�test_get_sourcefile_no_sourcez0GetSourcefileTests.test_get_sourcefile_no_source[s����Z�D�
E�
E�	:��(-�L�%��F�?�D����_�T�2�2�D�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s�5A�A�Ac�`�tdz}|�t|��|��dS)Nz.bad_ext)rrSr)r<r.s  r$�test_get_sourcefile_bad_extz.GetSourcefileTests.test_get_sourcefile_bad_extcs2���
�"�������.�.��5�5�5�5�5r&N)r�r�r��__doc__rHrJrLr�r&r$r@r@HsK��������<�<�<�:�:�:�6�6�6�6�6r&r@c��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��dSrA)rPr=rr+r.�old_pathr/r;s r$r=zImportTracebackTests.setUpls?��
�������������
������6�"�"�"�"�"r&c�Z�|jtjdd�<tt��dSr8)rQr+r.rrr;s r$r?zImportTracebackTests.tearDownqs"���m��������v�����r&rc�0�tj�t||z��}t	|dd���5}|�|��ddd��n#1swxYwY|�t|��tj	��|S)Nrlrmrn)
rPr.r"rrqrrrrr9r:)r<r��contentsr��fnamer#s      r$�
create_modulez"ImportTracebackTests.create_moduleus�������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_framerr�r��tb_nextrS�len�ziprh)r<�tb�files�
deduped_filesr��fn�pats       r$�assert_tracebackz%ImportTracebackTests.assert_traceback}s����
��	��;�%�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�rM�
__traceback__rarU)r<rdr�r\s    r$�test_nonexistent_modulez,ImportTracebackTests.test_nonexistent_module�s}��	=�$�$�$�$�
�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_xyzzyrrcr)rVr�r�rMrerarU�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�rVr�r�r�rerarUrhs    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�7rjc��|�dd��|�dd��	ddl}|�d��n#t$r}|j}Yd}~nd}~wwxYw|�|tddg��dS)	Nr�z
import bar�barrlrrmr�bar.pyrnrhs    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)rVr�r��SyntaxErrorrerarUrhs    r$�test_syntax_errorz&ImportTracebackTests.test_syntax_error�s������5�"=�>�>�>�	=��J�J�J�
�I�I�;�<�<�<�<���	!�	!�	!���B�B�B�B�B�B�����	!����	
���b�8�*�-�-�-�-�-rjc�X�d}|�t|��tj�t
|��}tj|��tj�|d��}t|dd���5}|�|��ddd��n#1swxYwYtj�|d��}t|dd���5}|�|��ddd��n#1swxYwYtj
��||fS)N�_parent_foorrlrmrnrr)rrrPr.r"rr=rqrrr9r:)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'rlrrm�r�_parent_foo.barr�r�rerarU�r<r}r~rxr�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'rlr�rqrc�rrxrqr�r�rerarU�r<r}r~rqr�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)Nrlr'rrmr�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)Nrlr'rr�rmr�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'r9�load_modulec��ddzdS)Nr�rr�)r�s r$�exec_modulez9ImportTracebackTests.test_import_bug.<locals>.exec_module�s���!����r&rrmz<frozen importlib)rVr+r,�vars�SourceLoaderr�r�r�r�rerarU)r<r9�old_exec_moduler�r�r�r\s       r$�test_import_bugz$ImportTracebackTests.test_import_bug�sB��	
���5�"�%�%�%��K� <�=�	��D��!7�8�8�8�	#�'�4�@�O�O�"�O�	E�
�
�
�1<�I�"�.�
G��
�
�
��	�	�E�F�F�F�F��%�
%�
%�
%��_�����������
%����
�!�!�"�x�1D�h�&O�P�P�P��
E��*�6�6�6�5D�	�&�2�2�2���
E��*�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*rrrr�)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=r?rVrarfrirorsrvrr�r�r�r�r
r�rPrQrr�r�r&r$rOrOjs:������#�#�#�
�������
#�
#�
#�.�.�.�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&rOc�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$r?zCircularImportTests.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.basicrMr��r<rs  r$�test_directzCircularImportTests.test_direct&sU��	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.indirectrMr�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.subpackagerMr�r�s  r$�test_subpackagez#CircularImportTests.test_subpackage3sU��	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�	rebindingrMr��-test.test_import.data.circular_imports.subpkgr�r�)r<r�r�s   r$�test_rebindingz"CircularImportTests.test_rebinding9s���	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.bindingrMr�r�s  r$�test_bindingz CircularImportTests.test_bindingAsU��	S�A�A�A�A�A�A���	S�	S�	S��I�I�Q�R�R�R�R�R�R�	S���r�c��ddl}ddl}dSrA)�*test.test_import.data.circular_imports.use�-test.test_import.data.circular_imports.sourcer�s  r$�test_crossreference1z(CircularImportTests.test_crossreference1Gs ��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.sourcer)zpartially initialized modulezcircular import)rBr�r�rWrTrh)r<rXr�errmsgs    r$�test_crossreference2z(CircularImportTests.test_crossreference2Ks���
�
�
�~�
.�
.�	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))rBrM�2test.test_import.data.circular_imports.from_cycle1rhrWrT�r<rXrs   r$�test_circular_from_importz-CircularImportTests.test_circular_from_importTs���
�
�
�{�
+�
+�	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))rBr��5test.test_import.data.circular_imports.subpkg2.parentrhrWrTr�s   r$� test_absolute_circular_submodulez4CircularImportTests.test_absolute_circular_submodule^s���
�
�
�~�
.�
.�	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��*)rr� test.test_import.data.unwritabler�r�
unwritable�assertWarns�
ImportWarningr��assertNotEqual�typerrSrBr�)r<r�r�s   r$�test_unwritable_modulez*CircularImportTests.test_unwritable_modulehs������� 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�rMr?r�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__)Nr')Fr��
contextlibr�rB�importlib.utilr9�importlib._bootstrap_externalrr�rPr�r�r@r�rDr+r�rrrPrr�rrrrr	r
rr�test.support.import_helperr
rrrrr�test.support.os_helperrrrrrrr�test.test_importlib.utilr�typesrrw�dont_write_bytecoderNr%�contextmanagerr4�TestCaser6rSrzr�r�r�r�rr0r@rOr�r��mainr�r&r$�<module>r�s;����������������������9�9�9�9�9�9�����	�	�	�	�����
�
�
�
�
�
�
�
���������
�
�
�
�����������������������"�"�"�"�"�"�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�I�>�>�>�>�>�>�>�>�>�>�>�>�>�>�&�&�&�&�&�&�)�)�)�)�)�)�,�,�,�,�,�,�������.�h�o���4�6�6�������&�&�&���&�(M@�M@�M@�M@�M@�(�#�M@�M@�M@�`�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&