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_zipimport.cpython-38.opt-1.pyc
U

>��gu�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZddlZddlZddlZddlZddlZddlmZmZmZzddlZWnek
r�dZYnXdZeedd�ZdZd	d
�Zdd�Z e��Z!eee!e"e��Z#d
Z$dZ%dZ&ej'�(d�Z)ej'�(d�Z*ej+�,e$d�Z-dZ.Gdd�dej/�Z0Gdd�de0�Z1e
j2Gdd�de1��Z3Gdd�dej/�Z4dd�Z5e6dk�r�e5�dS)�N)�support)�ZipFile�ZipInfo�
ZIP_STORED�ZIP_DEFLATED)�
extract_tb�
extract_stack�print_tbzHdef get_name():
    return __name__
def get_file():
    return __file__
�<???>�execz def do_raise(): raise TypeError
cCsdt�|�}t|�td�kr<|dkr,t|�}ntdt|��}tjjt�ddt|�|d@�|}|S)Ngi���l����z<iiirl��)	�marshal�dumps�type�int�	importlib�util�MAGIC_NUMBER�struct�pack)�co�mtime�size�data�pyc�r�2/opt/cppython/lib/python3.8/test/test_zipimport.py�make_pyc#s

��rcCs|�tjd�S)N�.)�replace�os�sep)�pathrrr�module_path_to_dotted_name/sr"Z
ziptestmoduleZziptestpackageZziptestpackage2Z	junk95142z
junk95142.zip�.py�.pycc@seZdZdd�Zdd�ZdS)�ImportHooksBaseTestCasecCsHtjdd�|_tjdd�|_tjdd�|_tj��t��|_dS�N)	�sysr!�	meta_path�
path_hooks�path_importer_cache�clearrZ
modules_setup�modules_before��selfrrr�setUpBs

zImportHooksBaseTestCase.setUpcCsJ|jtjdd�<|jtjdd�<|jtjdd�<tj��tj|j�dSr&)	r!r'r(r)r*r+rZmodules_cleanupr,r-rrr�tearDownIs

z ImportHooksBaseTestCase.tearDownN)�__name__�
__module__�__qualname__r/r0rrrrr%@sr%c@sxeZdZeZdd�Zefdd�Zefdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zej�dd�dd��Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Z d1d2�Z!d3d4�Z"d5d6�Z#d7d8�Z$d9d:�Z%d;d<�Z&d=d>�Z'd?d@�Z(dAdB�Z)dCdD�Z*dEdF�Z+dGdH�Z,e�-e.j/dIkdJ�dKdL��Z0dMdN�Z1dOdP�Z2dQdR�Z3dSdT�Z4dIS)U�UncompressedZipImportTestCasecCs t��tj��t�|�dSr&)�	linecache�
clearcache�	zipimport�_zip_directory_cacher+r%r/r-rrrr/Us
z#UncompressedZipImportTestCase.setUpc	
Cs�|�tj|�|��D]�\}\}}tj�||�}|dtjkrVtj�|�s�t�	|�qtj�
|�}tj�|�sxt�	|�t|d��}|�|�W5QRXqdS)N����wb)
�
addCleanupr�rmtree�itemsrr!�joinr �isdir�makedirs�dirname�open�write)	r.�filesZdirName�namerrr!Zdname�fprrr�makeTree\s
z&UncompressedZipImportTestCase.makeTreec	Ks�|�tj|�t|d��Z}|��D]0\}\}}t|t�|��}|j|_	|�
||�q"|�dd�}	|	dk	rn|	|_W5QRX|�dd�}
|
dk	r�t
|d��}|��}W5QRXt
|d��}|�|
�|�|�W5QRXdS)N�w�comment�stuff�rbr:)r;r�unlinkrr=r�time�	localtime�compression�
compress_type�writestr�getrIrB�readrC)r.rDZzipName�kw�zrErr�zinforIrJ�frrr�makeZipms 
z%UncompressedZipImportTestCase.makeZipcOst|j|f|�tj�dt�t�d�|��}|�d�}|dk	rF||�|rp|�	�}|�
|tjjtf|��|�dS)Nrr�call)rXr'r!�insert�TEMP_ZIPr�
import_moduler>rRZget_file�assertEqualr)r.Zexpected_extrD�modulesrT�modrY�filerrr�doTest�s
��z$UncompressedZipImportTestCase.doTestcCs�dtjkr|�d�dtjkr&tjd=dttfi}z|�d|d�Wn(tk
rl|jt	krh|�
d�YnX|jtkr�|�
d�dS)N�zlibzzlib is a builtin modulezzlib.pyr#z&expected test to not raise ImportErrorz"expected test to raise ImportError)r'�builtin_module_namesZskipTestr^�NOW�test_srcra�ImportErrorrOr�failr�r.rDrrr�
testAFakeZlib�s




z+UncompressedZipImportTestCase.testAFakeZlibcCs"tdttfi}|�d|t�dS�Nr#��TESTMODrdrerarhrrr�testPy�sz$UncompressedZipImportTestCase.testPycCs"ttttfi}|�t|t�dSr&)rl�pyc_extrd�test_pycrarhrrr�testPyc�sz%UncompressedZipImportTestCase.testPyccCs.tdttfttttfi}|�t|t�dSrj)rlrdrernrorarhrrr�testBoth�s
�z&UncompressedZipImportTestCase.testBothcsjd}tj�|�}tj�t|dd�|d�}tdtdftdtd|fi}�fd	d
�}�jd|t|d�dS)N�
state = 'old'�???rFr#�
state = 'new'r$�cs��|jd�dS)N�old�r]�state�r_r-rr�check�szFUncompressedZipImportTestCase.testUncheckedHashBasedPyc.<locals>.check�rY�	rr�source_hash�_bootstrap_external�_code_to_hash_pyc�compilerlrdra�r.�sourcer}�bytecoderDrzrr-r�testUncheckedHashBasedPyc�s
�
�z7UncompressedZipImportTestCase.testUncheckedHashBasedPycz_imp.check_hash_based_pycs�alwayscsjd}tj�|�}tj�t|dd�|d�}tdtdftdtd|fi}�fd	d
�}�jd|t|d�dS)NrrrsrFr#rtr$rucs��|jd�dS)N�newrwryr-rrrz�szOUncompressedZipImportTestCase.test_checked_hash_based_change_pyc.<locals>.checkr{r|r�rr-r�"test_checked_hash_based_change_pyc�s
�
�z@UncompressedZipImportTestCase.test_checked_hash_based_change_pyccCs"tdtdfi}|�d|t�dS)Nr#�)rlrdrarhrrr�testEmptyPy�sz)UncompressedZipImportTestCase.testEmptyPycCsFtt�}|ddN<tdttfttt|fi}|�d|t�dS)Nr�r#��	bytearrayrorlrdrernra�r.Zbadmagic_pycrDrrr�testBadMagic�s�z*UncompressedZipImportTestCase.testBadMagiccCs^tt�}|ddN<ttt|fi}z|�d|t�Wntk
rNYnX|�d�dS)Nrr�r#z)expected ImportError; import from bad pyc)r�rorlrnrdrarfrgr�rrr�
testBadMagic2�sz+UncompressedZipImportTestCase.testBadMagic2cCsFtt�}|ddN<tdttfttt|fi}|�d|t�dS)N��r#r�)r.Zbadtime_pycrDrrr�testBadMTime�s�z*UncompressedZipImportTestCase.testBadMTimecCsBttj}|dtttf|ttttfi}|�t|tt�dS�N�__init__)�TESTPACKrr rnrdrorlra)r.�packdirrDrrr�testPackages

�z)UncompressedZipImportTestCase.testPackagecCsbttj}|ttj}|dtttf|dtttf|ttttfi}|�t|ttt�dSr�)	r�rr �	TESTPACK2rnrdrorlra�r.r��packdir2rDrrr�testSubPackages


�z,UncompressedZipImportTestCase.testSubPackagecCsRttj}|ttj}|tdf|tdf|ttttfi}|�t|ttt�dS�Nr�)	r�rr r�rdrlrnrorar�rrr�testSubNamespacePackages

�z5UncompressedZipImportTestCase.testSubNamespacePackagec
CsRttj}|ttj}|tdtj}|tdf|ttttf|tdf|tdf|ttttf|tdtttf|ttttfi}|tdf|tdtttf|tdf|tdtttf|ttttfi}tj�	d�}|�
||�t}|�||�t
j�d|�t
j�d|�t�t�}|�dt|j��|j\}	}
|�tj�t�|	�tj�d�|�d|
�tj�d�t�|�tjd�dd	��}|�d
t|j��t|j�d�dtj�d
}|�|dd	�|�t�d�ttf��}|�d|j�tj�d�t�d�ttdf��}|�tj�t�|j�tj�d�d�ttf�}t�|�}|�dt|j��|j\}	}
|�tj�t�|	�tj�d�|�d|
�tj�d�t�d�|tf��}|�tj�t�|j�tj�d�t�d�|tdf��}|�tj�t�|j�tj�d�t�d�|tdf��}|�d|j�tj�d�dS)
N�3r��2�	path1.ziprr����rr9�������)r�rr r�rdrlrnror!�abspathrX�TEMP_DIRrGr'rZrr\r]�len�__path__�basename�splitr�listr>�__file__)
r.r�r��packdir3�files1�files2�zip1�zip2r_�p1�p2�mpath�subpkgrrr�testMixedNamespacePackages�



�
�

 �

 ��z7UncompressedZipImportTestCase.testMixedNamespacePackagec
Cs2ttj}|ttj}|tdtj}|tdf|ttttf|tdf|tdf|ttttf|tdtttf|ttttfi}tj�	d�}|�
||�|tdf|tdtttf|tdf|tdtttf|ttttfi}tj�	d�}|�
||�tj�d|�tj�d|�t
�t�}|�dt|j��|j\}	}
|�d|	�tj�d�|�d|
�tj�d�t
�|�tjd	�dd
��}|�dt|j��t|j�d�dtj�d}|�|dd
�|�t
�d	�ttf��}|�d|j�tj�d�t
�d	�ttdf��}|�d|j�tj�d�d	�ttf�}t
�|�}|�dt|j��|j\}	}
|�d|	�tj�d�|�d|
�tj�d�t
�d	�|tf��}|�d|j�tj�d
�t
�d	�|tdf��}|�d|j�tj�d
�t
�d	�|tdf��}|�d|j�tj�d
�dS)Nr�r�r�r�z	path2.ziprr�r�rr9r�r�r�)r�rr r�rdrlrnror!r�rXr'rZrr\r]r�r�r�rr�r>r�)
r.r�r�r�r�r�r�r�r_r�r�r�r�rrr�testNamespacePackagehst



�
�



z2UncompressedZipImportTestCase.testNamespacePackagec	Cs�ttj}|ttj}|dtttf|dtttf|ttttfdtttfi}|�t	j
t�ttd��F}|�
�D]6\}\}}t|t�|��}|j|_d|_|�||�qzW5QRXt�t�}	|�|	jt�|�|	�t�d�|	�d�}
|�|
�|�|
tj�|�|
�d��|
�d�}|�|
�d�|j �|	�t�}|�|	�t�|j �t!�"t�j#d}
tj$�%tt�}|�|
|�|�|	�|d�d�|�|	�|t�d�|�|	�|t�d�|t}t&|�}t!�"|�}|�'|t(j)k�|�|	�*t�d�|�|	�*|�d�|�|	�|�|j �|j+}|�|�*|�d�|�|�|�|j �t�ttjt�}|�|jt�|�|j,ttj�dS)Nr�ZspamrHsspamTrF)-r�rr r�rnrdrorlr;rrLr[rr=rrMrNrOrPrIrQr7�zipimporterr]�archive�
is_package�find_module�assertIsNotNone�assertIsInstance�assertFalse�load_module�get_filenamer�rr\r�r!r>r"�
assertTruer'r^�
get_source�
__loader__�prefix)r.r�r�rDrUrErrrV�ziZfind_mod�load_modr_Zexisting_pack_pathZexpected_path_path�mod_path�mod_name�loader�zi2rrr�testZipImporterMethods�s^


�





z4UncompressedZipImportTestCase.testZipImporterMethodsc	Cs<ttj}|ttj}|dtttf|ttttfi}|�t	j
t�ttd��F}|�
�D]6\}\}}t|t�|��}|j|_d|_|�||�q^W5QRXt�ttj|�}	|�|	jt�|�|	j|�|�|	�t�d�|	�t�}
|�|	�t�|
j�|�|	�ttjd�d�|�|	�ttjt�d�ttj|t}t�|�}|�t�}
|�|
�|� |
tj�|�!|�t��|
�t�}|�|
�t�|j�ttjt}t"|�}t#�$|�}
|�%|t&j'k�|�|	�(t�d�|�|	�(|�d�|�|	�|�|
j�|
j)}|�|�(|�d�|�|�|�|
j�dS)Nr�rHseggsTF)*r�rr r�rnrdrorlr;rrLr[rr=rrMrNrOrPrIrQr7r�r]r�r�r�r�r�r�r�r�r�r�r"rr\r�r'r^r�r�)r.r�r�rDrUrErrrVr�r_Zpkg_pathr�Zfind_mod_dottedr�r�r�r�rrr�$testZipImporterMethodsInSubDirectory�s`

�
��



�
zBUncompressedZipImportTestCase.testZipImporterMethodsInSubDirectoryc	Cs�|�tjt�ttd��4}|j|_d}tdd�td�D��}|�||�W5QRXt	�
t�}|�||�|��|�
dt|��dS)NrHztestdata.datcss|]
}|VqdSr&r)�.0�xrrr�	<genexpr>sz<UncompressedZipImportTestCase.testGetData.<locals>.<genexpr>�zzipimporter object)r;rrLr[rrO�bytes�rangerQr7r�r]�get_dataZassertIn�repr)r.rUrErr�rrr�testGetDatas
z)UncompressedZipImportTestCase.testGetDatacCsFd}tt|dd�tt|��}ttt|fdtdfi}|�t|t�dS)Nz�if 1:  # indent hack
        def get_file():
            return __file__
        if __loader__.get_data("some.data") != b"some data":
            raise AssertionError("bad data")
r
rz	some.dataz	some data)rr�rdr�rlrnra)r.�srcrrDrrr�testImporterAttr&s�z.UncompressedZipImportTestCase.testImporterAttrcCs\d}tdt|fi}|�|�tj�dt�t�t�}|�	|�
d�d�|�t|j
d�dS)Nz[if 1:  # indent hack
        def test(val):
            assert(val)
            return val
r#rr�F)
rlrdrXr'r!rZr[rr\r]�test�assertRaises�AssertionError)r.r�rDr_rrr�testDefaultOptimizationLevel1s

z:UncompressedZipImportTestCase.testDefaultOptimizationLevelcCs&tdttfi}|jd|tdd�dS)Nr#s6Some StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome StuffSome Stuff)rJrkrhrrr�testImport_WithStuff>s
�z2UncompressedZipImportTestCase.testImport_WithStuffcCs|�t�|�t�dSr&)r]�inspectZ	getsourcere)r.�modulerrr�assertModuleSourceEsz0UncompressedZipImportTestCase.assertModuleSourcecCs(tdttfi}|jd|t|jd�dS�Nr#r{)rlrdrerar�rhrrr�
testGetSourceHsz+UncompressedZipImportTestCase.testGetSourcecCsLtttdd�ttt��}tdttfttt|fi}|jt|t|jd�dS)Nr
rr#r{)	rr�rerdr�rlrnrar�)r.rrDrrr�testGetCompiledSourceLs�z3UncompressedZipImportTestCase.testGetCompiledSourcecCs.tdttfdtdfi}|jd|t|d�dS)Nr#�xyz.txtz>>> log.append(True)
r{rk)r.�callbackrDrrr�
runDoctestRs
�z(UncompressedZipImportTestCase.runDoctestcCsFg}tjd}t_ztjd|dt�d�W5|t_X|�|dg�dS�Nr�T)�packageZmodule_relativeZglobs)�doctestZmasterZtestfile�localsr])r.r��logZ
old_masterrrr�
doDoctestFileWs�
z+UncompressedZipImportTestCase.doDoctestFilecCs|�|j�dSr&)r�r�r-rrr�testDoctestFilecsz-UncompressedZipImportTestCase.testDoctestFilecCs.g}tjd|dt�d���|�|dg�dSr�)r�ZDocFileTestr��runr])r.r�r�rrr�doDoctestSuitefs�
z,UncompressedZipImportTestCase.doDoctestSuitecCs|�|j�dSr&)r�r�r-rrr�testDoctestSuitensz.UncompressedZipImportTestCase.testDoctestSuitecCs�z|��Wn�t��dj}t|d�d\}}}}|�|t���t|j	d�d\}}}}|�|t���t
��}t|d|�|�
|���t��Yn
Xtd��dS)Nr�r�rzThis ought to be impossible)Zdo_raiser'�exc_info�tb_nextrr]�	raise_src�stripr�tb_frame�io�StringIOr	r��getvalue�endswithr�)r.r��tbrW�lno�n�line�srrr�doTracebackqsz)UncompressedZipImportTestCase.doTracebackcCs(tdttfi}|jd|t|jd�dSr�)rlrdr�rar�rhrrr�
testTraceback�sz+UncompressedZipImportTestCase.testTracebackNzneed an unencodable filenamec	Csjtjd}|�tj|�t|d��.}ttdt�t	��}|j
|_|�|t
�W5QRXt�|��t�dS�Nz.ziprHr#)r�TESTFN_UNENCODABLEr;rLrrrlrMrNrdrOrPrQrer7r�r��r.�filenamerUrVrrr�testUnencodable�s
z-UncompressedZipImportTestCase.testUnencodablec	Cs�tjd}|�tj|�t|d��.}ttdt�t	��}|j
|_|�|t
�W5QRXt�|�t�t�|��|�t��t�tt�|���W5QRX|�t��t�tt�|���W5QRXdSr)rZTESTFNr;rLrrrlrMrNrdrOrPrQrer7r�r�fsencoder��	TypeErrorr��
memoryviewrrrr�
testBytesPath�s

z+UncompressedZipImportTestCase.testBytesPathcCs&tdttfi}|jd|tdd�dS)Nr#scomment�rIrkrhrrr�testComment�sz)UncompressedZipImportTestCase.testCommentcCs(tdttfi}|jd|tddd�dS)Nr#s@cruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftcruftshi)rJrIrkrhrrr�testBeginningCruftAndComment�sz:UncompressedZipImportTestCase.testBeginningCruftAndCommentcCs*tdttfi}|jd|tddd�dS)Nr#�ci��r	rkrhrrr�testLargestPossibleComment�sz8UncompressedZipImportTestCase.testLargestPossibleComment)5r1r2r3rrOr/r�rGr[rXrarirmrprqr��unittestZmockZpatchr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZskipIfrrrrr
rr
rrrrr4QsZ 
	
MI81
�
	r4c@seZdZeZdS)�CompressedZipImportTestCaseN)r1r2r3rrOrrrrr�src@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�BadFileZipImportTestCasecCs|�tjtj|�dSr&)r�r7�ZipImportErrorr�)r.rrrr�assertZipFailure�s�z)BadFileZipImportTestCase.assertZipFailurecCs|�d�dS)NZAdfjdkFJKDFJjdklfjs�rr-rrr�
testNoFile�sz#BadFileZipImportTestCase.testNoFilecCs|�d�dSr�rr-rrr�testEmptyFilename�sz*BadFileZipImportTestCase.testEmptyFilenamecCsB|�ttjd�|jttjtdd�|�ttjtt�t���dS)N)Zkwd)r�rr7r�rlr�rrr-rrr�testBadArgs�s

�z$BadFileZipImportTestCase.testBadArgscCs|�dd�dS)N�Ai�rr-rrr�testFilenameTooLong�sz,BadFileZipImportTestCase.testFilenameTooLongcCs"t�t�t�t�|�t�dSr&)rrLrlZcreate_empty_filerr-rrr�
testEmptyFile�s

z&BadFileZipImportTestCase.testEmptyFilec
Csht�t�t�ttjd�}z0t�|�|�t	j
��}t	�t�W5QRXW5t�td�t�t�XdS)Nri�)rrLrlrrB�O_CREAT�chmod�closer�r7rr�)r.�fd�cmrrr�testFileUnreadable�s

z+BadFileZipImportTestCase.testFileUnreadablecCs4t�t�ttd�}|�d�|��|�t�dS)N�w+Zaaaaaaaaaaaaaaaaaaaaaa)rrLrlrBrCrr)r.rFrrr�testNotZipFile�s



z'BadFileZipImportTestCase.testNotZipFilecCs t�t�ttd�}|�t�dd��|�d�|��t�	t�}z�|�t
|jd�|�t
|jd�|�t
|jd�|�t
|jd�|�t
|jd�|�t
|jd�tj}|�|�d�d�|�||jd�|�||jd�|�t|jd�|�||jd�|�||jd�W5tj
��XdS)Nr z=IiPKZaaaaaaaaaaaaaaaaaa�abc)rrLrlrBrCrrrr7r�r8r+r�rr�r�r��get_coder�r�rr]�OSError)r.rFrU�errorrrr�_testBogusZipFile�s*



z*BadFileZipImportTestCase._testBogusZipFileN)r1r2r3rrrrrrrr!r&rrrrr�src	Cs$zt�ttt�W5t�t�XdSr&)rrLrlZrun_unittestr4rrrrrr�	test_main�s�r'�__main__)7r'rrr�importlib.utilrrMrZ
unittest.mockr�r�zipfilerrrrr7r5r�r�r��	tracebackrrr	rbrfrer�Ztest_cor�rr"rdr�rorlr�r�r!r�r�r[r�cache_from_sourceZpyc_filernZTestCaser%r4Z
requires_zlibrrr'r1rrrr�<module>s\
aK



F1le Man4ger