Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_imp.cpython-38.opt-2.pyc
U

>��g�F�	@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
Z
ddlZe���e�
de�ddlZW5QRXddlZdd�ZGdd�de
j�ZGd	d
�d
e
j�ZGdd�de
j�ZGd
d�de
j�ZGdd�de
j�Zedkr�e
��dS)�N)�support)�
script_helper�ignorecCs"t�|�}t�ttd�d�|�S)N�load_dynamiczimp.load_dynamic() required)r�cpython_only�unittest�skipIf�hasattr�imp)�meth�r�,/opt/cppython/lib/python3.8/test/test_imp.py�requires_load_dynamics
��rc@seZdZdd�Zdd�ZdS)�	LockTestscCs|�t��|d|�dS)Nz!expected imp.lock_held() to be %r)�assertEqualr
�	lock_held)�self�expectedrrr
�verify_lock_states�zLockTests.verify_lock_statecCs�d}t��}|�|�t|�D]}t��|�d�qt|�D]}t��q>|�|�|s�zt��Wntk
rzYnX|�d�dS)N�2Tz5release_lock() without lock should raise RuntimeError)r
rr�range�acquire_lock�release_lock�RuntimeErrorZfail)rZLOOPSZlock_held_at_start�irrr
�testLock s


zLockTests.testLockN)�__name__�
__module__�__qualname__rrrrrr
rsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zedd��Z
edd��Zedd��Zedd��Ze�ejd�dd��Zdd�Zd d!�Zejd"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,S)-�ImportTestscCst�d�}|j|_|j|_dS)Nztest.encoded_modules)�	importlib�
import_module�test_strings�__path__�	test_path)r�modrrr
�setUp<s
zImportTests.setUpcCs2|jD]&\}}}t�d|�}|�||j�qdS)Nztest.encoded_modules.module_)r"r r!r�test)r�modname�encodingZteststrr%rrr
�test_import_encoded_moduleAs
�z&ImportTests.test_import_encoded_modulec
Csv|jD]:\}}}t�d||j�d�}|�|j|�W5QRXqtj�t	�g}|�
t��t�d|�W5QRXdS)N�module_r�badsyntax_pep3120)r"r
�find_moduler$rr)�os�path�dirname�__file__�assertRaises�SyntaxError)rr%r)�_�fdr/rrr
�test_find_module_encodingGsz%ImportTests.test_find_module_encodingc
Cs�|jD]p\}}}t�d||j�\}}}|�D|�|d�|�|j|�|�|��d�|�|��d|�W5QRXqt�d�\}}}|�@|�|d�|�|jd�|�|��d�|�|��d�W5QRXdS)Nr+rz# test %s encoding
�tokenize�utf-8z*"""Tokenization help for Python programs.
)	r"r
r-r$ZassertNotEqualrr)�tell�readline)rr%r)r4�fp�filename�inforrr
�test_issue1267Ps&
�
�
�zImportTests.test_issue1267c
Cs�d}tj�dd�zNt|dd��}|�d�W5QRXt�|�\}}}|�	�|�
|jd�W5tjd=t�|d�t�|d�XdS)	NZtest_imp_helperr�.�.py�.pyc�wz%# coding: cp1252
u = 'test.test_imp'
�cp1252)�sysr/�insertr�unlink�open�writer
r-�closerr))r�
temp_mod_name�filer<r=rrr
�test_issue3594cszImportTests.test_issue3594cCs�t��}ddddddddddd�
}tjdkr>|�|d�d	}n
|�|�}|sZ|�d
|�|�|�}d|}d|}tj�	|d
�}�z�tj�
dtj�t|dd��}	|	�d�W5QRXt�|�\}	}
}|	�x|�|	�|�|
dd��|��|�|dd�|�|dd�|�|dtj�t�||	|
|�}|�|jd�W5QRXt��� t�d�t�||d�}W5QRX|�|jd�t���.t�d�tj�s�t�|t�|d��}W5QRX|�|jd�tj� |��s�t�!|�t|d��}	|	�d�W5QRXt���t�d�t�"||�}
W5QRX|�|
j#d�W5tjd=dD]"}t
�||�t
�||��qRt
�|�t
�d�XdS)Ns�������)
r8�cp1250�cp1251rC�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258�darwinr8säz2can't run this test with %s as filesystem encodingZtest_imp_helper_Ztest_imp_helper_package_z__init__.pyr)r@rA�__pycache__r@rBza = 1
�����r�rzb = 2
)$rD�getfilesystemencoding�platformr�get�skipTest�decoder.r/�joinrrF�rmtreerE�curdirrGrHr
r-ZassertIsNotNoneZ
assertTrue�endswithZ	PY_SOURCE�load_module�a�warnings�catch_warnings�simplefilter�load_source�dont_write_bytecodeZ
load_compiled�cache_from_source�exists�mkdirZload_package�b)rZfs_encodingZ
known_localesZspecial_charZdecoded_charrJZtest_package_nameZinit_file_name�extrKr<r=r%�packagerrr
�test_issue5604qs~�

�





�



zImportTests.test_issue5604cCs$tj�t�}|�ttjd|g�dS)Nr,)r.r/r0r1r2r3r
r-)rr/rrr
�test_issue9319�s�zImportTests.test_issue9319c	Csttj}tj}t���Vt�d�}|�|dj�tj	d|��}|�
t|�|�
||j�|�||j�W5QRXdS)Nr.r)r.)r.r/�getenvr�EnvironmentVarGuardr
r-�
addCleanuprIrh�assertIsZassertIsNot)r�	orig_pathZorig_getenv�xZnew_osrrr
�test_load_from_source�s	

z!ImportTests.test_load_from_sourcecCsLd}t�|�}|d}|dk	r*|�|j�tj|f|��}|�|j|�dS)N�_heapqr)r
r-ryrIrhrr)rZexampler|Zfile_r%rrr
�test_issue15828_load_extensions�s
z+ImportTests.test_issue15828_load_extensionsc	Cs�d}t�|�\}}}|��t�||�}t�d|�}t�d|�}|�|j|�|�|jd�|�|jd�|�t��t�d|�W5QRXdS)N�_testimportmultipleZ_testimportmultiple_fooZ_testimportmultiple_barZnonexistent)r
r-rIrrrr2�ImportError)r�m�fileobj�pathname�descriptionZmod0Zmod1Zmod2rrr
�+test_issue16421_multiple_modules_in_one_dll�sz7ImportTests.test_issue16421_multiple_modules_in_one_dllc	CsNd}d}|�t��}t�||�W5QRX|�||jj�|�||jj�dS)Nzbogus file path�	extension)	r2r�r
rZassertIn�	exceptionr/r�name)rr/r��errrrr
�"test_load_dynamic_ImportError_path�sz.ImportTests.test_load_dynamic_ImportError_pathcCs`d}t�|�}|ddk	r&|d��|ddtjkrB|�d�tj|df|dd���dS)Nr�rr^z/found module doesn't appear to be a C extensionr\)r
r-rIZC_EXTENSIONrbrh)rr��foundrrr
�'test_load_module_extension_file_is_Nones

z3ImportTests.test_load_module_extension_file_is_NonecCs�d}ztj|=Wntk
r$YnXz�t�|�}tj�d�}t�||j	�}|�
|j|�|�
|jj
|�|�
|jj	|j	�|�tt|d�|�
|jd�|�tj||�W5ztj|=Wntk
r�YnXXdS)Nztest.imp_dummyZ_testmultiphaseZ
dummy_namei�)rD�modules�KeyErrorr r!�util�	find_specr
r�originrr�__spec__r�r2�AttributeError�getattrZ	int_constrz)rr��module�specrrr
�3test_issue24748_load_module_skips_sys_modules_checks&
z?ImportTests.test_issue24748_load_module_skips_sys_modules_checkz*test meaningful only when writing bytecodec	CsDt���2tjd}t�|�|�tdtjtjdg�W5QRXdS)Nr@z
^No moduler?)	r�temp_cwdZTESTFNr.rq�assertRaisesRegexr�r
r-)r�sourcerrr
�test_bug7732+s


�zImportTests.test_bug7732cCs2t�dtjttj��}|�tj�|�tj�dS)Nr
)r
Z_LoadSourceCompatibilityr1rG�get_data)r�loaderrrr
�test_multiple_calls_to_get_data4s

�z+ImportTests.test_multiple_calls_to_get_datac
Csddt��}ttjt�|�}t�tj||��.|�td��t�	|t
d�W5QRXW5QRXdS)N�tmpz
embedded null�)r�typerDr�rZ	swap_itemr��
ValueErrorr
rmr1)rr(r%rrr
�test_load_source;s

zImportTests.test_load_sourcec	Cs>t�td�}Gdd�d�}|�t��||��W5QRXdS)N�create_dynamicc@seZdZdZdZdS)z,ImportTests.test_issue31315.<locals>.BadSpecN�foo)rrrr�r�rrrr
�BadSpecIsr�)rZ
get_attributer
r2�	TypeError)rr�r�rrr
�test_issue31315DszImportTests.test_issue31315cCs4ddl}|�|jjd�ddl}|�|jjd�dS)Nr�frozen)�_frozen_importlib_externalrr�r��_frozen_importlib)rr�r�rrr
�test_issue_35321OszImportTests.test_issue_35321cCs,|�t�dd�d�|�t�dd�d�dS)N�*shis��Z
:}��+s��65���9)r�_imp�source_hash)rrrr
�test_source_hashZszImportTests.test_source_hashcCshgdfddgdfddgdfddgdfg}|D]6\}}|ddg}tj|�}|�|j���d�|�q,dS)N�defaultz--check-hash-based-pycs�always�neverz-cz.import _imp; print(_imp.check_hash_based_pycs)r8)rZassert_python_okr�out�striprc)rZcasesZinterp_argsr�args�resrrr
�'test_pyc_invalidation_mode_from_cmdline^s


��
z3ImportTests.test_pyc_invalidation_mode_from_cmdlinec
Cs�t���`tdd��}|�d�W5QRXtjddtjjd�tj	ddgd�\}}}t�
d|||�}W5QRX|�|jd	�dS)
Nzmymod.py�wbsx = 42
T)�doraise�invalidation_modeZmymodr?)r/r�)
rr�rGrH�
py_compile�compile�PycInvalidationMode�CHECKED_HASHr
r-rhrr|)rr;rKr/r�r%rrr
�test_find_and_load_checked_pycms
�z*ImportTests.test_find_and_load_checked_pycN)rrrr&r*r6r>rLrurvr}rrr�r�r�r�rrrDrnr�r�r�rrr�r�r�r�r�rrrr
r;s<	W




�
	

rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ReloadTestsc	Cs*t���ddl}t�|�W5QRXdS)Nr)rrxr.r
�reload)rr.rrr
�test_source�s
zReloadTests.test_sourcec	Cs,t�d��ddl}t�|�W5QRXdS)N�timer)r�CleanImportr�r
r�)rr�rrr
�test_extension�szReloadTests.test_extensionc	Cs,t�d��ddl}t�|�W5QRXdS)N�marshalr)rr�r�r
r�)rr�rrr
�test_builtin�szReloadTests.test_builtinc	sTddlm}tj�d���fdd�}|�|�|�td��t�	|�W5QRXdS)Nr)�parser�htmlcs�tjd<dS)Nr�)rDr�r�r�rr
�cleanup�sz5ReloadTests.test_with_deleted_parent.<locals>.cleanup)
r�r�rDr��popryr�r�r
r�)rr�r�rr�r
�test_with_deleted_parent�s
z$ReloadTests.test_with_deleted_parentN)rrrr�r�r�r�rrrr
r�|sr�c@sLeZdZe��Ze�ej	j
dk	d�dd��Ze�ej	j
dk	d�dd��ZdS)�PEP3147TestsNz1requires sys.implementation.cache_tag not be Nonec	CsFtj�dddd�}tj�ddddd�|j��}|�t�|d�|�dS)Nr��bar�baz�qux.pyrZ�
qux.{}.pycT)r.r/rd�format�tagrr
ro�rr/�expectrrr
�test_cache_from_source�s

�z#PEP3147Tests.test_cache_from_sourcez4requires sys.implementation.cache_tag to not be Nonec	CsDtj�ddddd�|j��}tj�dddd�}|�t�|�|�dS)Nr�r�r�rZr�r�)r.r/rdr�r�rr
�source_from_cacher�rrr
�test_source_from_cache�s

�z#PEP3147Tests.test_source_from_cache)
rrrr
Zget_tagr�rZ
skipUnlessrD�implementation�	cache_tagr�r�rrrr
r��s�
�r�c@s&eZdZe�ejdkd�dd��ZdS)�NullImporterTestsNzNeed an undecodeable filenamec	Cs6tj}t�|�z|�ttj|�W5t�|�XdS)N)	r�TESTFN_UNENCODABLEr.rq�rmdirr2r�r
ZNullImporter)rr�rrr
�test_unencodeable�s

z#NullImporterTests.test_unencodeable)rrrrrrr�r�rrrr
r��s�r��__main__)r �importlib.utilr.Zos.pathr�rDr'rZtest.supportrrrjrkrl�DeprecationWarningr
r�rZTestCaserrr�r�r�r�mainrrrr
�<module>s.
"C&

F1le Man4ger