Your IP : 216.73.216.213


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

�

�0�i���,�ddlZddlmZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZGd�d��ZGd�dej
��ZGd	�d
ejej��ZGd�dej
��Zed
krej��dSdS)�N)�abc)�util)�threading_helperc��eZdZd�Zd�ZdS)�CollectInitc�"�||_||_dS�N)�args�kwargs)�selfr
rs   �D/opt/alt/python311/lib64/python3.11/test/test_importlib/test_lazy.py�__init__zCollectInit.__init__s����	������c��|Sr	��r�modules  r
�exec_modulezCollectInit.exec_modules���rN)�__name__�
__module__�__qualname__rrrrr
rrs2�������������rrc��eZdZd�Zd�ZdS)�LazyLoaderFactoryTestsc���tj�t��}|ddd���}|j}|�d|j��|�ddi|j��dS)N�module name�module path�kw)r)rr)r�
LazyLoader�factoryr�loader�assertEqualr
r)rr�lazy_loaderr s    r
�	test_initz LazyLoaderFactoryTests.test_initsr���/�)�)�+�6�6���g�m�]�t�D�D�D���#�����7���E�E�E����$���v�}�5�5�5�5�5rc��|�t��5tj�t
��ddd��dS#1swxYwYdSr	)�assertRaises�	TypeErrorrrr�object�rs r
�test_validationz&LazyLoaderFactoryTests.test_validation#s���
�
�
�y�
)�
)�	,�	,��O�#�#�F�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�%A
�
A�AN)rrrr#r)rrr
rrs2������6�6�6�,�,�,�,�,rrc�V�eZdZdZdZdZdZd�e��Zdd�Z	d�Z
dS)	�TestingImporter�lazy_loader_test�changedNrzattr = 42; __name__ = {!r}c�j�||jkrdStj|tj|����Sr	)�module_namer�spec_from_loaderr)r�name�path�targets    r
�	find_speczTestingImporter.find_spec1s2���4�#�#�#��4��$�T�4�?�4�+@�+@�A�A�Arc��tjd��t|j|j��||_|xjdz
c_dS)Ng{�G�z�?�)�time�sleep�exec�source_code�__dict__�loaded�
load_countrs  r
rzTestingImporter.exec_module6sB���
�4�����T�
�v��/�/�/�������1�����rr	)rrrr/�mutated_namer<r=�formatr:r4rrrr
r+r+)sb������$�K��L�
�F��J�.�5�5�l�C�C�K�B�B�B�B�
����rr+c��eZdZd�Zdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
ej��d
���Zd�ZdS)�LazyLoaderTestsc��|�t��5tjt��ddd��dS#1swxYwYdSr	)r%r&rrr'r(s r
r#zLazyLoaderTests.test_init?s���
�
�
�y�
)�
)�	$�	$��O�F�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s�A�A�	ANc��|�t��}|�||_tjtjtj|����}|j�|��}|�tj	tj��}||_
|j|_|j�|��|�
|j��|Sr	)r+r:rr0r/rr �
create_module�types�
ModuleType�__spec__�
__loader__r�assertIsNoner<)rr:r �specrs     r
�
new_modulezLazyLoaderTests.new_moduleDs����>�$�&�&�F��"�!,�F���$�_�%@�%)�_�V�%<�%<�>�>����*�*�4�0�0���>��%�o�&A�B�B�F���� �K��������'�'�'����&�-�(�(�(��
rc��t��}|j�J�tj|j��5tj|g���5t
j|j��}ddd��n#1swxYwYddd��n#1swxYwY|�|j��|�	|j
|��|�|j��|�	||j��dS)N)�	meta_path)r+r<�	test_util�uncacher/�import_state�	importlib�
import_modulerIr!rH�assertIsNotNone)r�importerrs   r
�test_e2ezLazyLoaderTests.test_e2eUs���"�$�$����&�&�&�
�
�x�3�
4�
4�	G�	G��'�8�*�=�=�=�
G�
G�"�0��1E�F�F��
G�
G�
G�
G�
G�
G�
G�
G�
G�
G�
G����
G�
G�
G�
G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G�	
���(�/�*�*�*�����*�H�5�5�5����X�_�-�-�-�������1�1�1�1�1s5�B�A.�"B�.A2	�2B�5A2	�6B�B	�B	c�x�|���}|�tj|j��dSr	)rKr!r+r>rrs  r
�test_attr_unchangedz#LazyLoaderTests.test_attr_unchangedbs4�����"�"������5�v��G�G�G�G�Grc�r�|���}d|_|�d|j��dS)N�*)rK�new_attrr!rs  r
�
test_new_attrzLazyLoaderTests.test_new_attrhs6�����"�"���������V�_�-�-�-�-�-rc�r�|���}d|_|�d|j��dS)N�bogus)rKrr!rs  r
�test_mutated_preexisting_attrz-LazyLoaderTests.test_mutated_preexisting_attrns8�����"�"��!�������&�/�2�2�2�2�2rc�r�|���}d|_|�d|j��dS)N�)rK�attrr!rs  r
�test_mutated_attrz!LazyLoaderTests.test_mutated_attrus8�����"�"���������F�K�(�(�(�(�(rc�x�|���}|`|�t|d����dS)Nra)rKra�assertFalse�hasattrrs  r
�test_delete_eventual_attrz)LazyLoaderTests.test_delete_eventual_attr|s:�����"�"���K�������0�0�1�1�1�1�1rc�x�|���}|`|�t|d����dS)Nr)rKrrdrers  r
�test_delete_preexisting_attrz,LazyLoaderTests.test_delete_preexisting_attr�s:�����"�"���O�������4�4�5�5�5�5�5rc�~�tjtj��5t	jtj��}|tjtj<|���}|�	td��5|jddd��n#1swxYwYddd��dS#1swxYwYdS)N�substituted)rNrOr+r/rErF�sys�modulesrK�assertRaisesRegex�
ValueErrorr)r�fresh_modulers   r
�test_module_substitution_errorz.LazyLoaderTests.test_module_substitution_error�s��
�
��:�
;�
;�	 �	 � �+�O�,G�H�H�L�7C�C�K��3�4��_�_�&�&�F��'�'�
�M�B�B�
 �
 ����
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 ����
 �
 �
 �
 �		 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �	 �	 s6�A'B2�B�B2�B	�B2�!B	�"B2�2B6�9B6c���tjtj��5|���}|t
jtj<|jddd��dS#1swxYwYdSr	)rNrOr+r/rKrkrlrrs  r
�test_module_already_in_sysz*LazyLoaderTests.test_module_already_in_sys�s���
�
��:�
;�
;�	�	��_�_�&�&�F�7=�C�K��3�4��O�O�		�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�5A!�!A%�(A%c�\��tjtj��5t��}|�|����|�|jd��Gd�dtj��}�fd�}g}td��D]7}|�
||���x}��|����8|D]0}|���|�
|j���1|�|jd��ddd��dS#1swxYwYdS)	N)r rc�"��eZdZdZ�fd�Z�xZS)�<LazyLoaderTests.test_module_load_race.<locals>.RaisingThreadNc���	t�����dS#t$r}||_Yd}~dSd}~wwxYwr	)�super�run�	Exception�exc)rrz�	__class__s  �r
rxz@LazyLoaderTests.test_module_load_race.<locals>.RaisingThread.run�sO���'������
�
�
�
�
��$�'�'�'�#&�������������'���s� %�
A�<�A)rrrrzrx�
__classcell__)r{s@r
�
RaisingThreadru�s=���������'�'�'�'�'�'�'�'�'rr}c����jSr	)ra)rs�r
�
access_modulez<LazyLoaderTests.test_module_load_race.<locals>.access_module�s����{�"r�)r3r6)rNrOr+r/rKr!r=�	threading�Thread�range�append�start�joinrIrz)rr r}r�threads�_�threadrs       @r
�test_module_load_racez%LazyLoaderTests.test_module_load_race�s����
�
��:�
;�
;�	3�	3�$�&�&�F��_�_�F�_�3�3�F����V�.��2�2�2�
'�
'�
'�
'�
'�	� 0�
'�
'�
'�
#�
#�
#�
#�
#��G��1�X�X�
�
�������m�)L�)L�)L�L�v�M�M�M��������"�
.�
.�����
�
�
��!�!�&�*�-�-�-�-�
���V�.��2�2�2�7	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s�C4D!�!D%�(D%c��d�tjD��}tj|�5t	jd��}t	j|j��}||_t	j|��}|tjd<|�	|��|�
d��}|�|i��ddd��dS#1swxYwYdS)Nc�<�g|]}|�d���|��S)�json)�
startswith)�.0r1s  r
�
<listcomp>zFLazyLoaderTests.test_lazy_self_referential_modules.<locals>.<listcomp>�s)��P�P�P������8O�8O�P��P�P�Prr�z{})rkrlrNrOrr4rr �module_from_specr�loadsr!)r�json_modulesrJr r�	test_loads      r
�"test_lazy_self_referential_modulesz2LazyLoaderTests.test_lazy_self_referential_modules�s��Q�P���P�P�P��
�
��
-�	,�	,��>�&�)�)�D��_�T�[�1�1�F� �D�K��*�4�0�0�F�"(�C�K������v�&�&�&����T�*�*�I����Y��+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�BC
�
C�C)NN)rrrr#rKrUrWr[r^rbrfrhrprrr�requires_working_threadingr�r�rrr
rArA=s�������$�$�$�
����"2�2�2�H�H�H�.�.�.�3�3�3�)�)�)�2�2�2�6�6�6�
 � � ����1��0�2�2�3�3�3�2�3�<,�,�,�,�,rrA�__main__)rQrrrkr7r�rE�unittest�test.supportr�test.test_importlibrNr�TestCaser�MetaPathFinder�Loaderr+rAr�mainrrr
�<module>r�sk������������������
�
�
�
�����������������)�)�)�)�)�)�1�1�1�1�1�1���������,�,�,�,�,�X�.�,�,�,�"�����c�(�#�*����(H,�H,�H,�H,�H,�h�'�H,�H,�H,�V�z����H�M�O�O�O�O�O��r