Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/test_importlib/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/test_importlib/__pycache__/test_lazy.cpython-312.opt-2.pyc

�

)Μg���:�ddlZddlmZddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZGd�d�ZGd�dej�ZGd	�d
ejej �ZGd�dej�Zed
k(rej(�yy)�N)�abc)�util)�threading_helperc��eZdZd�Zd�Zy)�CollectInitc� �||_||_y�N)�args�kwargs)�selfr
rs   �:/usr/local/lib/python3.12/test/test_importlib/test_lazy.py�__init__zCollectInit.__init__s����	����c��|Sr	��r�modules  r
�exec_modulezCollectInit.exec_modules���rN)�__name__�
__module__�__qualname__rrrrr
rrs���rrc��eZdZd�Zd�Zy)�LazyLoaderFactoryTestsc���tjjt�}|ddd��}|j}|jd|j�|jddi|j�y)N�module name�module path�kw)r)rr)r�
LazyLoader�factoryr�loader�assertEqualr
r)rr�lazy_loaderr s    r
�	test_initz LazyLoaderFactoryTests.test_inits^���/�/�)�)�+�6���m�]�t�D���#�#�����7����E����$���v�}�}�5rc��|jt�5tjj	t
�ddd�y#1swYyxYwr	)�assertRaises�	TypeErrorrrr�object�rs r
�test_validationz&LazyLoaderFactoryTests.test_validation#s.��
�
�
�y�
)��O�O�#�#�F�+�*�
)�
)�s�$A�AN)rrrr#r)rrr
rrs��6�,rrc�L�eZdZdZdZdZdZdje�Zdd�Z	d�Z
y)	�TestingImporter�lazy_loader_test�changedNrzattr = 42; __name__ = {!r}c�t�||jk7rytj|tj|��Sr	)�module_namer�spec_from_loaderr)r�name�path�targets    r
�	find_speczTestingImporter.find_spec1s/���4�#�#�#���$�$�T�4�?�?�4�+@�A�Arc��tjd�t|j|j�||_|xjdz
c_y)Ng{�G�z�?�)�time�sleep�exec�source_code�__dict__�loaded�
load_countrs  r
rzTestingImporter.exec_module6s7���
�
�4���T�
�
�v���/�������1��rr	)rrrr/�mutated_namer<r=�formatr:r4rrrr
r+r+)s1��$�K��L�
�F��J�.�5�5�l�C�K�B�
rr+c��eZdZd�Zdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
ej�d
��Zd�Zy)�LazyLoaderTestsc��|jt�5tjt�ddd�y#1swYyxYwr	)r%r&rrr'r(s r
r#zLazyLoaderTests.test_init?s(��
�
�
�y�
)��O�O�F�#�*�
)�
)�s	�9�ANc��|�
t�}|�||_tjtjtj
|��}|jj|�}|�#tjtj�}||_
|j|_|j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���>��%�%�o�&A�&A�B�F���� �K�K���������'����&�-�-�(��
rc���t�}tj|j�5tj|g��5tj|j�}ddd�ddd�|j|j�|jj|�|j|j�|j||j�y#1swY��xYw#1swY��xYw)N)�	meta_path)r+�	test_util�uncacher/�import_state�	importlib�
import_modulerIr<r!rH�assertIsNotNone)r�importerrs   r
�test_e2ezLazyLoaderTests.test_e2eUs���"�$��
�
�
�x�3�3�
4��'�'�8�*�=�"�0�0��1E�1E�F��>�5�	
���(�/�/�*�����*�*�H�5����X�_�_�-��������1�
>�=��5�
4�s#�C-� C!�"C-�!C*	�&C-�-C6c�x�|j�}|jtj|j�yr	)rKr!r+r>rrs  r
�test_attr_unchangedz#LazyLoaderTests.test_attr_unchangedbs*�����"������5�5�v���Grc�j�|j�}d|_|jd|j�y)N�*)rK�new_attrr!rs  r
�
test_new_attrzLazyLoaderTests.test_new_attrhs)�����"���������V�_�_�-rc�j�|j�}d|_|jd|j�y)N�bogus)rKrr!rs  r
�test_mutated_preexisting_attrz-LazyLoaderTests.test_mutated_preexisting_attrns+�����"��!�������&�/�/�2rc�j�|j�}d|_|jd|j�y)N�)rK�attrr!rs  r
�test_mutated_attrz!LazyLoaderTests.test_mutated_attrus+�����"���������F�K�K�(rc�^�|j�}|`|jt|d��y)Nra)rKra�assertFalse�hasattrrs  r
�test_delete_eventual_attrz)LazyLoaderTests.test_delete_eventual_attr|s(�����"���K�������0�1rc�^�|j�}|`|jt|d��y)Nr)rKrrdrers  r
�test_delete_preexisting_attrz,LazyLoaderTests.test_delete_preexisting_attr�s(�����"���O�������4�5rc��tjtj�5t	j
tj�}|tjtj<|j�}|jtd�5|jddd�ddd�y#1swY�xYw#1swYyxYw)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�,G�H�L�7C�C�K�K��3�3�4��_�_�&�F��'�'�
�M�B����C�	<�
;�C�B��	<�
;�s$�A+B9�
B-�B9�-B6	�2B9�9Cc���tjtj�5|j	�}|t
jtj<|jddd�y#1swYyxYwr	)rNrOr+r/rKrkrlrrs  r
�test_module_already_in_sysz*LazyLoaderTests.test_module_already_in_sys�sI��
�
�
��:�:�
;��_�_�&�F�7=�C�K�K��3�3�4��O�O�	<�
;�
;�s�>A+�+A4c�6��tjtj�5t�}|j	|���|j|jd�Gd�dtj�}�fd�}g}td�D],}|j||��x}�|j��.|D]-}|j�|j|j��/|j|jd�ddd�y#1swYyxYw)	N)r rc�"��eZdZdZ�fd�Z�xZS)�<LazyLoaderTests.test_module_load_race.<locals>.RaisingThreadNc�^��	t�|��y#t$r}||_Yd}~yd}~wwxYwr	)�super�run�	Exception�exc)rrz�	__class__s  �r
rxz@LazyLoaderTests.test_module_load_race.<locals>.RaisingThread.run�s*���'����
��$�'�#&�����'�s��	,�'�,)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����
�
�
��:�:�
;�$�&�F��_�_�F�_�3�F����V�.�.��2�
'�	� 0� 0�
'�
#��G��1�X������m�)L�L�v�M������
"�����
��!�!�&�*�*�-�"�

���V�.�.��2�7<�
;�
;�s�C!D�Dc���tjD�cgc]}|jd�s�|��}}tj|�5tjd�}tj|j�}||_tj|�}|tjd<|j|�|jd�}|j|i�ddd�ycc}w#1swYyxYw)N�jsonz{})
rkrl�
startswithrNrOrr4rr �module_from_specr�loadsr!)rr1�json_modulesrJr r�	test_loads       r
�"test_lazy_self_referential_modulesz2LazyLoaderTests.test_lazy_self_referential_modules�s���*-���P�������8O����P�
�
�
��
-��>�>�&�)�D��_�_�T�[�[�1�F� �D�K��*�*�4�0�F�"(�C�K�K������v�&����T�*�I����Y��+�.�
-��Q�
-�
-�s�C#�C#�BC(�(C1)NN)rrrr#rKrUrWr[r^rbrfrhrprrr�requires_working_threadingr�r�rrr
rArA=s_��$�
�"2�H�.�3�)�2�6�
 ��1��0�0�2�3�3�3�<,rrA�__main__)rQrrrkr7r�rE�unittest�test.supportr�test.test_importlibrNr�TestCaser�MetaPathFinder�Loaderr+rAr�mainrrr
�<module>r�s������
�����)�1���,�X�.�.�,�"�c�(�(�#�*�*��(H,�h�'�'�H,�V�z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists