Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_zipimport.cpython-39.pyc

a

��g1u�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZddlZddlZddlZddlZddlZddlmZmZmZzddlZWney�dZYn0dZeedd�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
�2�Gdd�de1��Z3Gdd�dej/�Z4dd�Z5e6dk�r�e�7�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
cCs6t�|�}tjjt�ddt|�d@|d@�|}|S)Nz<iLLr���)�marshal�dumps�	importlib�util�MAGIC_NUMBER�struct�pack�int)�co�mtime�size�data�pyc�r�//usr/local/lib/python3.9/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�setUp=s

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

z ImportHooksBaseTestCase.tearDownN)�__name__�
__module__�__qualname__r/r0rrrrr%;sr%c@s�eZdZeZdd�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,dIdJ�Z-e�.e/j0dKudL�dMdN��Z1dOdP�Z2dQdR�Z3dSdT�Z4dUdV�Z5dKS)W�UncompressedZipImportTestCasecCs t��tj��t�|�dSr&)�	linecache�
clearcache�	zipimport�_zip_directory_cacher+r%r/r-rrrr/Ps
z#UncompressedZipImportTestCase.setUpc		Cs�|�tj|�|��D]�\}\}}tj�||�}|dtjkrVtj�|�s�t�	|�qtj�
|�}tj�|�sxt�	|�t|d��}|�|�Wd�q1s�0YqdS)N����wb)
�
addCleanupr�rmtree�itemsrr!�joinr �isdir�makedirs�dirname�open�write)	r.�filesZdirName�namerrr!Zdname�fprrr�makeTreeWs
z&UncompressedZipImportTestCase.makeTreecKs|�tj|�t|d��d}|��D]0\}\}}t|t�|��}|j|_	|�
||�q"|�dd�}	|	durn|	|_Wd�n1s�0Y|�dd�}
|
du�rt
|d��}|��}Wd�n1s�0Yt
|d��$}|�|
�|�|�Wd�n1�s
0YdS)N�w�comment�stuff�rbr:)r;r�unlinkrr=r�time�	localtime�compression�
compress_type�writestr�getrIrB�readrC)r.rDZzipName�kw�zrErr�zinforIrJ�frrr�makeZiphs $
&
z%UncompressedZipImportTestCase.makeZipcOsz|j|fi|��tj�dt�t�d�|��}|�d�}|durJ||�|rv|�	�}|�
|tjjtg|�R�|�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�dtjvr|�d�dtjvr&tjd=dttfi}z|�d|d�Wn&tyj|jt	krf|�
d�Yn0|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�WntyLYn0|�d�dS)Nrr�r#z)expected ImportError; import from bad pyc)r�rorlrnrdrarfrgr�rrr�
testBadMagic2�sz+UncompressedZipImportTestCase.testBadMagic2cCsFtt�}|ddN<tdttfttt|fi}|�d|t�dS)N��r#r�)r.Zbadtime_pycrDrrr�testBadMTime�s�z*UncompressedZipImportTestCase.testBadMTimecCs>ttdtt��}tdttfttt|fi}|�d|t�dS)Nrr#)r�test_co�lenrerlrdrnra)r.Ztwenty_thirty_eight_pycrDrrr�
test2038MTime�s
�z+UncompressedZipImportTestCase.test2038MTimecCsBttj}|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�testSubPackage	s
�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]r��__path__�basename�splitr�listr>�__file__)
r.r�r��packdir3�files1�files2�zip1�zip2r_�p1�p2�mpath�subpkgrrr�testMixedNamespacePackagesl
��

 �

 ��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�testNamespacePackageks`
��



z2UncompressedZipImportTestCase.testNamespacePackagec	Cs�ttj}|ttj}|dtttf|dtttf|ttttfdtttfi}|�t	j
t�ttd��P}|�
�D]6\}\}}t|t�|��}|j|_d|_|�||�qzWd�n1s�0Yt�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)v�|�|	�*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�sX
�,





z4UncompressedZipImportTestCase.testZipImporterMethodscCsPttj}|ttj}|dtttf|ttttfi}|�t	j
t�ttd��P}|�
�D]6\}\}}t|t�|��}|j|_d|_|�||�q^Wd�n1s�0Yt�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'v�|�|	�(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�sX
�,
��



�
zBUncompressedZipImportTestCase.testZipImporterMethodsInSubDirectorycCs�|�tjt�ttd��>}|j|_d}tdd�td�D��}|�||�Wd�n1s\0Yt	�
t�}|�||�|��|�
dt|��dS)NrHztestdata.datcss|]
}|VqdSr&r)�.0�xrrr�	<genexpr>"�z<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�testDefaultOptimizationLevel4s

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_WithStuffAs
�z2UncompressedZipImportTestCase.testImport_WithStuffcCs|�t�|�t�dSr&)r]�inspectZ	getsourcere)r.�modulerrr�assertModuleSourceHsz0UncompressedZipImportTestCase.assertModuleSourcecCs(tdttfi}|jd|t|jd�dS�Nr#r{)rlrdrerar�rhrrr�
testGetSourceKsz+UncompressedZipImportTestCase.testGetSourcecCsLtttdd�ttt��}tdttfttt|fi}|jt|t|jd�dS)Nr
rr#r{)	rr�rerdr�rlrnrar�)r.rrDrrr�testGetCompiledSourceOs
�z3UncompressedZipImportTestCase.testGetCompiledSourcecCs.tdttfdtdfi}|jd|t|d�dS)Nr#�xyz.txtz>>> log.append(True)
r{rk)r.�callbackrDrrr�
runDoctestUs�z(UncompressedZipImportTestCase.runDoctestcCsLg}tjd}t_ztjd|dt�d�W|t_n|t_0|�|dg�dS�Nr�T)�packageZmodule_relativeZglobs)�doctestZmasterZtestfile�localsr])r.r��logZ
old_masterrrr�
doDoctestFileZs�z+UncompressedZipImportTestCase.doDoctestFilecCs|�|j�dSr&)r�r�r-rrr�testDoctestFilefsz-UncompressedZipImportTestCase.testDoctestFilecCs.g}tjd|dt�d���|�|dg�dSr�)r�ZDocFileTestr��runr])r.r�r�rrr�doDoctestSuiteis�
z,UncompressedZipImportTestCase.doDoctestSuitecCs|�|j�dSr&)r�r�r-rrr�testDoctestSuiteqsz.UncompressedZipImportTestCase.testDoctestSuitec	
Cs�z|��Wn�ty�}z�|jj}t|d�d\}}}}|�|t���t|j	d�d\}}}}|�|t���t
��}t|d|�|�
|���t��WYd}~nd}~00td��dS)Nr�rzThis ought to be impossible)Zdo_raise�	Exception�
__traceback__�tb_nextrr]�	raise_src�stripr�tb_frame�io�StringIOr	r��getvalue�endswithr�)	r.r��e�tbrW�lno�n�line�srrr�doTracebackts*z)UncompressedZipImportTestCase.doTracebackcCs(tdttfi}|jd|t|jd�dSr�)rlrdr�rarrhrrr�
testTraceback�sz+UncompressedZipImportTestCase.testTracebackNzneed an unencodable filenamecCs~tjd}|�tj|�t|d��8}ttdt�t	��}|j
|_|�|t
�Wd�n1s`0Yt�|��t�dS�Nz.ziprHr#)r�TESTFN_UNENCODABLEr;rLrrrlrMrNrdrOrPrQrer7r�r��r.�filenamerUrVrrr�testUnencodable�s
*z-UncompressedZipImportTestCase.testUnencodablecCstjd}|�tj|�t|d��8}ttdt�t	��}|j
|_|�|t
�Wd�n1s`0Yt�|�t�t�|��|�t��$t�tt�|���Wd�n1s�0Y|�t��$t�tt�|���Wd�n1s�0YdSr)rZTESTFNr;rLrrrlrMrNrdrOrPrQrer7r�r�fsencoder��	TypeErrorr��
memoryviewrrrr�
testBytesPath�s
*
2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��rrkrhrrr�testLargestPossibleComment�sz8UncompressedZipImportTestCase.testLargestPossibleComment)6r1r2r3rrOr/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�rrZskipIfrrr	r
rrrrrrrr4Ls\ 
	
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�rr
r-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
Cs�t�t�t�ttjd�}zZt�|�|�tj	��}t�
t�Wd�n1sR0YWt�td�t�t�nt�td�t�t�0dS)Nri�)rrLrlrrB�O_CREAT�closer�r7rr��chmod)r.�fd�cmrrr�testFileUnreadable�s

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



z'BadFileZipImportTestCase.testNotZipFilecCs*t�t�ttd�}|�t�dd��|�d�|��t�	t�}z�|�
t|jd�|�
t|j
d�|�
t|jd�|�
t|jd�|�
t|jd�|�
t|jd�tj}|�|�d�d�|�
||j
d�|�
||jd�|�
t|jd�|�
||jd�|�
||jd�Wtj��ntj��0dS)Nr%z=IiPKZaaaaaaaaaaaaaaaaaa�abc)rrLrlrBrCrrr r7r�r�rr�r�r��get_coder�r�rr]�OSErrorr8r+)r.rFrU�errorrrr�_testBogusZipFile�s*



z*BadFileZipImportTestCase._testBogusZipFileN)r1r2r3rrrrrrr$r&r+rrrrr�srcCst�t�dSr&)rrLrlrrrr�tearDownModulesr,�__main__)8r'rr
r�importlib.utilrrMrZ
unittest.mockr�r�zipfilerrrrr7r5r�r�r��	tracebackrrr	rbrfrer�r�r�rr"rdr�rorlr�r�r!r�r�r[r�cache_from_sourceZpyc_filernZTestCaser%r4Z
requires_zlibrrr,r1�mainrrrr�<module>s\
iK


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists