Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.191.62.85
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_imp.cpython-310.pyc
o

`b�G�@s.ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlZddl
Z
e
���e
�de�ddlZWd�n1sQwYddlZdd�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�Zedkr�e��dSdS)�N)�support)�
import_helper)�	os_helper)�
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)�meth�r�6/usr/local/python-3.10/lib/python3.10/test/test_imp.py�requires_load_dynamics
��rc@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��}|�|�t|�D]}t��|�d�qt|�D]}t��q|�|�|sEzt��Wn
ty=YdSw|�d�dSdS)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__rrrrrrrsrc@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�modrrr�setUp>s
zImportTests.setUpcCs2|jD]\}}}t�d|�}|�||j�qdS)Nztest.encoded_modules.module_)r%r#r$r�test)r�modname�encodingZteststrr(rrr�test_import_encoded_moduleCs��z&ImportTests.test_import_encoded_modulec	Cs�|jD]'\}}}t�d||j�d�}|�|j|�Wd�n1s%wYqtj�t	�g}|�
t��t�d|�Wd�dS1sIwYdS)N�module_r�badsyntax_pep3120)r%r�find_moduler'rr,�os�path�dirname�__file__�assertRaises�SyntaxError)rr(r,�_�fdr2rrr�test_find_module_encodingIs��"�z%ImportTests.test_find_module_encodingc	Cs|jD]B\}}}t�d||j�\}}}|�'|�|d�|�|j|�|�|��d�|�|��d|�Wd�n1s@wYqt�d�\}}}|�&|�|d�|�|jd�|�|��d�|�|��d�Wd�dS1sywYdS)Nr.rz# test %s encoding
�tokenize�utf-8z*"""Tokenization help for Python programs.
)	r%rr0r'ZassertNotEqualrr,�tell�readline)rr(r,r7�fp�filename�inforrr�test_issue1267Rs,

����
�"�zImportTests.test_issue1267c
Cs�d}tj�dd�zFt|dddd��
}|�d�Wd�n1s#wYt�|�\}}}|��|�|j	d	�Wtjd=t
�|d�t
�|d
�dStjd=t
�|d�t
�|d
�w)NZtest_imp_helperr�.�.py�wzlatin-1�r,z%# coding: cp1252
u = 'test.test_imp'
�cp1252�.pyc)�sysr2�insert�open�writerr0�closerr,r�unlink)r�
temp_mod_name�filer?r@rrr�test_issue3594es��zImportTests.test_issue3594cCsVt��}ddddddddddd�
}tjdkr|�|d�d	}n|�|�}|s-|�d
|�|�|�}d|}d|}tj�	|d
�}�zEtj�
dtj�t|dddd��
}|�
d�Wd�n1sdwYt�|�\}}	}
|�A|�|�|�|	dd��|��|�|
dd�|�|
dd�|�|
dtj�t�|||	|
�}|�|jd�Wd�n1s�wYt���t�d�t�||d�}Wd�n1s�wY|�|jd�t���t�d�tjs�t�|t�|d��}Wd�n	1�swY|�|jd�tj�|��st�|�t|ddd��
}|�
d�Wd�n	1�s7wYt���t�d�t�||�}Wd�n	1�sWwY|�|j d�Wtjd=dD]}
t!�"||
�t!�"||
��qjt!�#|�t!�#d�dStjd=dD]}
t!�"||
�t!�"||
��q�t!�#|�t!�#d�w)Ns�������)
r;�cp1250�cp1251rF�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258�darwinr;säz2can't run this test with %s as filesystem encodingZtest_imp_helper_Ztest_imp_helper_package_z__init__.pyrrCrDrEza = 1
�����r�rzb = 2
)rCrG�__pycache__)$rH�getfilesystemencoding�platformr�get�skipTest�decoder1r2�joinrI�curdirrJrKrr0ZassertIsNotNoneZ
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�brrM�rmtree)rZfs_encodingZ
known_localesZspecial_charZdecoded_charrNZtest_package_nameZinit_file_namerOr?r@r(�package�extrrr�test_issue5604ss��


�
�
�


�

���
�

�
�
zImportTests.test_issue5604cCs$tj�t�}|�ttjd|g�dS)Nr/)r1r2r3r4r5r6rr0)rr2rrr�test_issue9319�s
�zImportTests.test_issue9319cCs�tj}tj}t���3t�d�}|�|dj�tj	dg|�R�}|�
t|�|�
||j�|�||j�Wd�dS1s@wYdS)Nr1r)r1r2�getenvr�EnvironmentVarGuardrr0�
addCleanuprLrk�assertIsZassertIsNot)r�	orig_pathZorig_getenv�xZnew_osrrr�test_load_from_source�s	

"�z!ImportTests.test_load_from_sourcecCsNd}t�|�}|d}|dur|�|j�tj|g|�R�}|�|j|�dS)N�_heapqr)rr0r}rLrkrr)rZexampler�Zfile_r(rrr�test_issue15828_load_extensions�s
z+ImportTests.test_issue15828_load_extensionscCs�d}t�|�\}}}|��t�||�}t�d|�}t�d|�}|�|j|�|�|jd�|�|jd�|�t��t�d|�Wd�dS1sLwYdS)N�_testimportmultipleZ_testimportmultiple_fooZ_testimportmultiple_barZnonexistent)rr0rLrrrr5�ImportError)r�m�fileobj�pathname�descriptionZmod0Zmod1Zmod2rrr�+test_issue16421_multiple_modules_in_one_dll�s"�z7ImportTests.test_issue16421_multiple_modules_in_one_dllcCsbd}d}|�t��}t�||�Wd�n1swY|�||jj�|�||jj�dS)Nzbogus file path�	extension)	r5r�rrZassertIn�	exceptionr2r�name)rr2r��errrrr�"test_load_dynamic_ImportError_path�s�z.ImportTests.test_load_dynamic_ImportError_pathcCsbd}t�|�}|ddur|d��|ddtjkr!|�d�tj|dg|dd��R�dS)Nr�rraz/found module doesn't appear to be a C extensionr_)rr0rLZC_EXTENSIONrfrk)rr��foundrrr�'test_load_module_extension_file_is_None	s

 z3ImportTests.test_load_module_extension_file_is_NonecCs�d}ztj|=Wn	tyYnwzUt�|�}tj�d�}t�||j	�}|�
|j|�|�
|jj
|�|�
|jj	|j	�|�tt|d�|�
|jd�|�tj||�Wztj|=WdStygYdSwztj|=WwtywYww)Nztest.imp_dummyZ_testmultiphaseZ
dummy_namei�)rH�modules�KeyErrorr#r$�util�	find_specrr�originrr�__spec__r�r5�AttributeError�getattrZ	int_constr~)rr��module�specrrr�3test_issue24748_load_module_skips_sys_modules_checks4�
���z?ImportTests.test_issue24748_load_module_skips_sys_modules_checkz*test meaningful only when writing bytecodecCsZt���tjd}t�|�|�tdtjtjdg�Wd�dS1s&wYdS)NrCz
^No modulerB)	r�temp_cwdZTESTFNr1rt�assertRaisesRegexr�rr0)r�sourcerrr�test_bug7732-s


�"�zImportTests.test_bug7732cCs6t�dtjttjdd��}|�tj�|�tj�dS)Nrr;rE)rZ_LoadSourceCompatibilityr4rJ�get_data)r�loaderrrr�test_multiple_calls_to_get_data6s

�z+ImportTests.test_multiple_calls_to_get_datac	Cs�dt��}ttjt�|�}t�tj||��/|�td��t�	|t
d�Wd�n1s0wYWd�dSWd�dS1sHwYdS)N�tmpz
embedded null�)r�typerHr�rZ	swap_itemr��
ValueErrorrrpr4)rr+r(rrr�test_load_source=s
��"�zImportTests.test_load_sourcecCsTt�td�}Gdd�d�}|�t��||��Wd�dS1s#wYdS)N�create_dynamicc@seZdZdZdZdS)z,ImportTests.test_issue31315.<locals>.BadSpecN�foo)rrr r�r�rrrr�BadSpecKsr�)rZ
get_attributerr5�	TypeError)rr�r�rrr�test_issue31315Fs
"�zImportTests.test_issue31315cCs4ddl}|�|jjd�ddl}|�|jjd�dS)Nr�frozen)�_frozen_importlib_externalrr�r��_frozen_importlib)rr�r�rrr�test_issue_35321QszImportTests.test_issue_35321cCs,|�t�dd�d�|�t�dd�d�dS)N�*shis��Z
:}��+s��65���9)r�_imp�source_hash)rrrr�test_source_hash\szImportTests.test_source_hashcCshgdfddgdfddgdfddgdfg}|D]\}}|ddg}tj|�}|�|j���d�|�qdS)N�defaultz--check-hash-based-pycs�always�neverz-cz.import _imp; print(_imp.check_hash_based_pycs)r;)rZassert_python_okr�out�striprg)r�casesZinterp_argsr�args�resrrr�'test_pyc_invalidation_mode_from_cmdline`s


��
�z3ImportTests.test_pyc_invalidation_mode_from_cmdlinec	Cs�t���?tdd��
}|�d�Wd�n1swYtjddtjjd�tj	ddgd�\}}}t�
d|||�}Wd�n1sFwY|�|jd	�dS)
Nzmymod.py�wbsx = 42
T)�doraise�invalidation_modeZmymodrB)r2r�)
rr�rJrK�
py_compile�compile�PycInvalidationMode�CHECKED_HASHrr0rkrr�)rr>rOr2r�r(rrr�test_find_and_load_checked_pycos
���
z*ImportTests.test_find_and_load_checked_pycN)rrr r)r-r9rArPryrzr�rr�r�r�r�r�r	r
rHrqr�r�r�rrr�r�r�r�r�rrrrr"=s>	W




�
	

r"c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ReloadTestszPVery basic tests to make sure that imp.reload() operates just like
    reload().cCs@t���ddl}t�|�Wd�dS1swYdS)Nr)rr|r1r�reload)rr1rrr�test_source�s
"�zReloadTests.test_sourcecC�Bt�d��ddl}t�|�Wd�dS1swYdS)N�timer)r�CleanImportr�rr�)rr�rrr�test_extension��"�zReloadTests.test_extensioncCr�)N�marshalr)rr�r�rr�)rr�rrr�test_builtin�r�zReloadTests.test_builtincsjddlm}tj�d���fdd�}|�|�|�td��t�	|�Wd�dS1s.wYdS)Nr)�parser�htmlcs�tjd<dS)Nr�)rHr�r�r�rr�cleanup�sz5ReloadTests.test_with_deleted_parent.<locals>.cleanup)
r�r�rHr��popr}r�r�rr�)rr�r�rr�r�test_with_deleted_parent�s
"�z$ReloadTests.test_with_deleted_parentN)rrr r!r�r�r�r�rrrrr�~sr�c@sPeZdZdZe��Ze�e	j
jdud�dd��Ze�e	j
jdud�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�baz�qux.pyrb�
qux.{}.pycT)r1r2rh�format�tagrrrr�rr2�expectrrr�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�rbr�r�)r1r2rhr�r�rr�source_from_cacher�rrr�test_source_from_cache�s

�z#PEP3147Tests.test_source_from_cache)rrr r!rZget_tagr�r	Z
skipUnlessrH�implementation�	cache_tagr�r�rrrrr��s�
�r�c@s&eZdZe�ejdud�dd��ZdS)�NullImporterTestsNzNeed an undecodeable filenamec	Cs>tj}t�|�z|�ttj|�Wt�|�dSt�|�w)N)	r�TESTFN_UNENCODABLEr1rtr5r�rZNullImporter�rmdir)rr�rrr�test_unencodeable�s

z#NullImporterTests.test_unencodeable)rrr r	r
rr�r�rrrrr��s
�r��__main__)r#�importlib.utilr1Zos.pathr�rHr*rZtest.supportrrrr	rmrnro�DeprecationWarningrr�rZTestCaserr"r�r�r�r�mainrrrr�<module>s8

�"C&�
© 2025 GrazzMean