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.7/test/__pycache__/test_imp.cpython-37.opt-1.pyc
B

��gDE�	@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
Z
ddlZe���e�
de�ddlZWdQRXddlZdd�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)zXDecorator to skip a test if not running under CPython or lacking
    imp.load_dynamic().�load_dynamiczimp.load_dynamic() required)r�cpython_only�unittest�skipIf�hasattr�imp)Zmeth�r�)/usr/local/lib/python3.7/test/test_imp.py�requires_load_dynamics
r
c@s eZdZdZdd�Zdd�ZdS)�	LockTestsz)Very basic test of import lock functions.cCs|�t��|d|�dS)Nz!expected imp.lock_held() to be %r)�assertEqualr
�	lock_held)�self�expectedrrr�verify_lock_stateszLockTests.verify_lock_statecCs�d}t��}|�|�x"t|�D]}t��|�d�q Wxt|�D]}t��qDW|�|�|s�yt��Wntk
r�YnX|�d�dS)N�2Tz5release_lock() without lock should raise RuntimeError)r
rr�range�acquire_lock�release_lock�RuntimeErrorZfail)rZLOOPSZlock_held_at_start�irrr�testLock s

zLockTests.testLockN)�__name__�
__module__�__qualname__�__doc__rrrrrr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*S)+�ImportTestscCst�d�}|j|_|j|_dS)Nztest.encoded_modules)�	importlib�
import_module�test_strings�__path__�	test_path)r�modrrr�setUp<s
zImportTests.setUpcCs6x0|jD]&\}}}t�d|�}|�||j�qWdS)Nztest.encoded_modules.module_)r"r r!r�test)r�modname�encodingZteststrr%rrr�test_import_encoded_moduleAsz&ImportTests.test_import_encoded_modulec
CszxD|jD]:\}}}t�d||j�d�}|�|j|�WdQRXqWtj�t	�g}|�
t��t�d|�WdQRXdS)N�module_r�badsyntax_pep3120)r"r
�find_moduler$rr)�os�path�dirname�__file__�assertRaises�SyntaxError)rr%r)�_�fdr/rrr�test_find_module_encodingGsz%ImportTests.test_find_module_encodingc
Cs�xz|jD]p\}}}t�d||j�\}}}|�D|�|d�|�|j|�|�|��d�|�|��d|�WdQRXqWt�d�\}}}|�@|�|d�|�|jd�|�|��d�|�|��d�WdQRXdS)Nr+rz# test %s encoding
�tokenizezutf-8z*"""Tokenization help for Python programs.
)	r"r
r-r$ZassertNotEqualrr)�tell�readline)rr%r)r4�fp�filename�inforrr�test_issue1267Ps 

zImportTests.test_issue1267c
Cs�d}tj�dd�zNt|dd��}|�d�WdQRXt�|�\}}}|��|�|j	d�Wdtjd=t
�|d�t
�|d�XdS)	NZtest_imp_helperr�.z.py�wz%# coding: cp1252
u = 'test.test_imp'
�cp1252z.pyc)�sysr/�insert�open�writer
r-�closerr)r�unlink)r�
temp_mod_name�filer;r<rrr�test_issue3594cszImportTests.test_issue3594cCs�t��}ddddddddddd�
}tjdkr>|�|d�d	}n
|�|�}|sZ|�d
|�|�|�}d|}d|}tj�	|d
�}�z�tj�
dtj�t|dd��}|�
d�WdQRXt�|�\}}	}
|�x|�|�|�|	dd��|��|�|
dd�|�|
dd�|�|
dtj�t�|||	|
�}|�|jd�WdQRXt��� t�d�t�||d�}WdQRX|�|jd�t���.t�d�tj�s�t�|t�|d��}WdQRX|�|jd�tj�|��s�t�|�t|d��}|�
d�WdQRXt���t�d�t�||�}WdQRX|�|j d�Wdtjd=x*dD]"}
t!�"||
�t!�"||
��qTWt!�#|�t!�#d�XdS)Ns�������)
zutf-8�cp1250�cp1251r@�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258�darwinzutf-8säz2can't run this test with %s as filesystem encodingZtest_imp_helper_Ztest_imp_helper_package_z__init__.pyrz.pyr?za = 1
�����r�rzb = 2
)z.pyz.pyc�__pycache__)$rA�getfilesystemencoding�platformr�get�skipTest�decoder.r/�joinrB�curdirrCrDr
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�brrFZrmtree)rZfs_encodingZ
known_localesZspecial_charZdecoded_charrGZtest_package_nameZinit_file_namerHr;r<r%�packageZextrrr�test_issue5604qsx












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

z!ImportTests.test_load_from_sourcecCsLd}t�|�}|d}|dk	r*|�|j�tj|f|��}|�|j|�dS)N�_heapqr)r
r-rtrErdrr)rZexamplerwZfile_r%rrr�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|�WdQRXdS)N�_testimportmultipleZ_testimportmultiple_fooZ_testimportmultiple_barZnonexistent)r
r-rErrrr2�ImportError)r�mZfileobj�pathname�descriptionZmod0Zmod1Zmod2rrr�+test_issue16421_multiple_modules_in_one_dll�sz7ImportTests.test_issue16421_multiple_modules_in_one_dllc	CsNd}d}|�t��}t�||�WdQRX|�||jj�|�||jj�dS)Nzbogus file path�	extension)	r2r|r
rZassertInZ	exceptionr/r�name)rr/r��errrrr�"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{rrZz/found module doesn't appear to be a C extensionrX)r
r-rEZC_EXTENSIONr_rd)rr��foundrrr�'test_load_module_extension_file_is_Nones

z3ImportTests.test_load_module_extension_file_is_NonecCs�d}ytj|=Wntk
r$YnXz�t�|�}tj�d�}t�||j	�}|�
|j|�|�
|jj
|�|�
|jj	|j	�|�tt|d�|�
|jd�|�tj||�Wdytj|=Wntk
r�YnXXdS)Nztest.imp_dummyZ_testmultiphaseZ
dummy_namei�)rA�modules�KeyErrorr r!�util�	find_specr
r�originrr�__spec__r�r2�AttributeError�getattrZ	int_constru)rr��module�specrrr�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�WdQRXdS)Nz.pyz
^No moduler>)	r�temp_cwdZTESTFNr.rm�assertRaisesRegexr|r
r-)r�sourcerrr�test_bug7732+s



zImportTests.test_bug7732cCs2t�dtjttj��}|�tj�|�tj�dS)Nr
)r
Z_LoadSourceCompatibilityr1rC�get_data)r�loaderrrr�test_multiple_calls_to_get_data4s
z+ImportTests.test_multiple_calls_to_get_datac
Csddt��}ttjt�|�}t�tj||��.|�td��t�	|t
d�WdQRXWdQRXdS)NZtmpz
embedded null�)r�typerAr�rZ	swap_itemr��
ValueErrorr
rir1)rr(r%rrr�test_load_source;s

zImportTests.test_load_sourcec	Cs>t�td�}Gdd�d�}|�t��||��WdQRXdS)N�create_dynamicc@seZdZdZdZdS)z,ImportTests.test_issue31315.<locals>.BadSpecN�foo)rrrr�r�rrrr�BadSpecIsr�)rZ
get_attributer
r2�	TypeError)rr�r�rrr�test_issue31315DszImportTests.test_issue31315cCs,|�t�dd�d�|�t�dd�d�dS)N�*shis��Z
:}��+s��65���9)r�_imp�source_hash)rrrr�test_source_hashOszImportTests.test_source_hashcCslgdfddgdfddgdfddgdfg}x>|D]6\}}|ddg}tj|�}|�|j���d�|�q.WdS)N�defaultz--check-hash-based-pycs�always�neverz-cz.import _imp; print(_imp.check_hash_based_pycs)zutf-8)rZassert_python_okr�out�stripr`)rZcasesZinterp_argsr�argsZresrrr�'test_pyc_invalidation_mode_from_cmdlineSs


z3ImportTests.test_pyc_invalidation_mode_from_cmdlinec
Cs�t���`tdd��}|�d�WdQRXtjddtjjd�tj	ddgd�\}}}t�
d|||�}WdQRX|�|jd	�dS)
Nzmymod.py�wbsx = 42
T)�doraise�invalidation_modeZmymodr>)r/r�)
rr�rCrD�
py_compile�compile�PycInvalidationMode�CHECKED_HASHr
r-rdrrw)rr:rHr/rr%rrr�test_find_and_load_checked_pycbs
z*ImportTests.test_find_and_load_checked_pycN)rrrr&r*r6r=rIrprqrxr
rzr�r�r�r�rrrArjr�r�r�rrr�r�r�r�rrrrr;s*	W
	rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ReloadTestszPVery basic tests to make sure that imp.reload() operates just like
    reload().c	Cs*t���ddl}t�|�WdQRXdS)Nr)rrsr.r
�reload)rr.rrr�test_sourcevs
zReloadTests.test_sourcec	Cs,t�d��ddl}t�|�WdQRXdS)N�timer)r�CleanImportr�r
r�)rr�rrr�test_extension�szReloadTests.test_extensionc	Cs,t�d��ddl}t�|�WdQRXdS)N�marshalr)rr�r�r
r�)rr�rrr�test_builtin�szReloadTests.test_builtinc	sTddlm}tj�d���fdd�}|�|�|�td��t�	|�WdQRXdS)Nr)�parser�htmlcs�tjd<dS)Nr�)rAr�r)r�rr�cleanup�sz5ReloadTests.test_with_deleted_parent.<locals>.cleanup)
r�r�rAr��poprtr�r|r
r�)rr�r�r)r�r�test_with_deleted_parent�s
z$ReloadTests.test_with_deleted_parentN)rrrrr�r�r�r�rrrrr�qs
r�c@sPeZdZdZe��Ze�e	j
jdk	d�dd��Ze�e	j
jdk	d�dd��Z
dS)	�PEP3147TestszTests of PEP 3147.Nz1requires sys.implementation.cache_tag not be Nonec	CsFtj�dddd�}tj�ddddd�|j��}|�t�|d�|�dS)Nr��bar�bazzqux.pyr[z
qux.{}.pycT)r.r/ra�format�tagrr
rk)rr/�expectrrr�test_cache_from_source�sz#PEP3147Tests.test_cache_from_sourcez4requires sys.implementation.cache_tag to not be Nonec	CsDtj�ddddd�|j��}tj�dddd�}|�t�|�|�dS)Nr�r�r�r[z
qux.{}.pyczqux.py)r.r/rar�r�rr
�source_from_cache)rr/r�rrr�test_source_from_cache�sz#PEP3147Tests.test_source_from_cache)rrrrr
Zget_tagr�rZ
skipUnlessrA�implementation�	cache_tagr�r�rrrrr��s	r�c@s&eZdZe�ejdkd�dd��ZdS)�NullImporterTestsNzNeed an undecodeable filenamec	Cs6tj}t�|�z|�ttj|�Wdt�|�XdS)N)	r�TESTFN_UNENCODABLEr.rmr2r|r
ZNullImporter�rmdir)rr�rrr�test_unencodeable�s

z#NullImporterTests.test_unencodeable)rrrrrrr�r�rrrrr��sr��__main__)r �importlib.utilr.Zos.pathr�rAr'rZtest.supportrrrfrgrh�DeprecationWarningr
r�r
ZTestCaserrr�r�r�r�mainrrrr�<module>s.
"8&