HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/test_importlib/__pycache__/test_lazy.cpython-310.opt-1.pyc
o

�iA�@s�ddlZddlmZddlmZddlZddlZddlZddlmZGdd�d�ZGdd�dej	�Z
Gd	d
�d
ejej�Z
Gdd�dej	�Zed
krPe��dSdS)�N)�abc)�util�c@�eZdZdd�Zdd�ZdS)�CollectInitcOs||_||_dS�N)�args�kwargs)�selfrr	�r�:/usr/local/lib/python3.10/test/test_importlib/test_lazy.py�__init__
s
zCollectInit.__init__cCs|Srr�r
�modulerrr�exec_moduleszCollectInit.exec_moduleN)�__name__�
__module__�__qualname__r
rrrrrrsrc@r)�LazyLoaderFactoryTestscCsDtj�t�}|dddd�}|j}|�d|j�|�ddi|j�dS)N�module name�module path�kw)r)rr)r�
LazyLoader�factoryr�loader�assertEqualrr	)r
rZlazy_loaderrrrr�	test_inits
z LazyLoaderFactoryTests.test_initcCs<|�t��tj�t�Wd�dS1swYdSr)�assertRaises�	TypeErrorrrr�object�r
rrr�test_validation s"�z&LazyLoaderFactoryTests.test_validationN)rrrrr!rrrrrs	rc@s4eZdZdZdZdZd�e�Zd	dd�Zdd�Z	dS)
�TestingImporterZlazy_loader_test�changedNzattr = 42; __name__ = {!r}cCs ||jkrdSt�|t�|��Sr)�module_namer�spec_from_loaderr)r
�name�path�targetrrr�	find_spec-s
zTestingImporter.find_speccCst|j|j�||_dSr)�exec�source_code�__dict__�loadedrrrrr2s
zTestingImporter.exec_moduler)
rrrr$�mutated_namer-�formatr+r)rrrrrr"&s

r"c@sfeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�LazyLoaderTestscCs:|�t��t�t�Wd�dS1swYdSr)rrrrrr rrrr9s"�zLazyLoaderTests.test_initNcCsrt�}|dur
||_t�tjt�|��}|j�|�}|dur$t�	tj�}||_
|j|_|j�|�|�
|j�|Sr)r"r+rr%r$rr�
create_module�types�
ModuleType�__spec__�
__loader__r�assertIsNoner-)r
r+r�specrrrr�
new_module>s�zLazyLoaderTests.new_modulec	Cs�t�}t�|j��%tj|gd��t�|j�}Wd�n1s"wYWd�n1s1wY|�|j�|�	|j
|�|�|j�|�	||j�dS)N)�	meta_path)r"�	test_util�uncacher$Zimport_state�	importlib�
import_moduler6r-rr5ZassertIsNotNone)r
Zimporterrrrr�test_e2eNs���zLazyLoaderTests.test_e2ecCs|��}|�tj|j�dSr)r8rr"r.rrrrr�test_attr_unchanged[sz#LazyLoaderTests.test_attr_unchangedcC� |��}d|_|�d|j�dS)N�*)r8Znew_attrrrrrr�
test_new_attraszLazyLoaderTests.test_new_attrcCr@)NZbogus)r8rrrrrr�test_mutated_preexisting_attrg�z-LazyLoaderTests.test_mutated_preexisting_attrcCr@)N�)r8�attrrrrrr�test_mutated_attrnrDz!LazyLoaderTests.test_mutated_attrcC� |��}|`|�t|d��dS)NrF)r8rF�assertFalse�hasattrrrrr�test_delete_eventual_attrusz)LazyLoaderTests.test_delete_eventual_attrcCrH)Nr)r8rrIrJrrrr�test_delete_preexisting_attr{sz,LazyLoaderTests.test_delete_preexisting_attrc	Cs�t�tj��:t�tj�}|tjtj<|��}|�	t
d��|jWd�n1s+wYWd�dSWd�dS1sCwYdS)NZsubstituted)r:r;r"r$r2r3�sys�modulesr8ZassertRaisesRegex�
ValueErrorr)r
Zfresh_modulerrrr�test_module_substitution_error�s��"�z.LazyLoaderTests.test_module_substitution_errorcCsLt�tj��|��}|tjtj<|jWd�dS1swYdSr)r:r;r"r$r8rMrNrrrrr�test_module_already_in_sys�s
"�z*LazyLoaderTests.test_module_already_in_sysr)rrrrr8r>r?rBrCrGrKrLrPrQrrrrr07s

r0�__main__)r<rrrMr2Zunittest�r:rZTestCaserZMetaPathFinder�Loaderr"r0r�mainrrrr�<module>s
Y�