Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_zipimport.cpython-34.pyo

�
h f�F�@sddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
mZddlZddlZddlZddlZddlZddlmZmZmZdZeedd�ZdZd	d
�Zdd�Zej�Zeeeee��Z d
Z!dZ"dZ#ej$j%d�Z&ej'j(e!d�Z)e*r~dndZ+Gdd�dej,�Z-Gdd�de-�Z.e	j/Gdd�de.��Z0Gdd�dej,�Z1dd�Z2e3dkr
e2�ndS)�N)�support)�ZipFile�ZipInfo�
ZIP_STORED�ZIP_DEFLATED)�
extract_tb�
extract_stack�print_tbzHdef get_name():
    return __name__
def get_file():
    return __file__
z<???>�execz def do_raise(): raise TypeError
cCs�tj|�}t|�td�kr[|dkrBt|�}q[tdt|��}ntjjtjdt|�|d@�|}|S)Ngi���lz<iil��l����)	�marshal�dumps�type�int�	importlib�util�MAGIC_NUMBER�struct�pack)�co�mtime�size�data�pyc�r�8/opt/alt/python34/lib64/python3.4/test/test_zipimport.py�make_pycs-rcCs|jtjd�S)N�.)�replace�os�sep)�pathrrr�module_path_to_dotted_name)sr!Z
ziptestmoduleZziptestpackageZziptestpackage2z
junk95142.zipz.pyz.pycz.pyoc@s(eZdZdd�Zdd�ZdS)�ImportHooksBaseTestCasecCsbtjdd�|_tjdd�|_tjdd�|_tjj�tj�|_dS)N)	�sysr �	meta_path�
path_hooks�path_importer_cache�clearrZ
modules_setup�modules_before)�selfrrr�setUp;s

zImportHooksBaseTestCase.setUpcCsc|jtjdd�<|jtjdd�<|jtjdd�<tjj�tj|j�dS)N)	r r#r$r%r&r'rZmodules_cleanupr()r)rrr�tearDownBs

z ImportHooksBaseTestCase.tearDownN)�__name__�
__module__�__qualname__r*r+rrrrr"9sr"c@s�eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Ze j!e"j#d7kd8�d9d:��Z$d7S);�UncompressedZipImportTestCasecCs(tj�tjj�tj|�dS)N)�	linecache�
clearcache�	zipimport�_zip_directory_cacher'r"r*)r)rrrr*Ns

z#UncompressedZipImportTestCase.setUpcOs�ttd�}zvxT|j�D]F\}\}}t|tj|��}	|j|	_|j|	|�qW|j	�|j
dd�}
|
dk	r�ttd��}|j�}WdQXttd��!}|j
|
�|j
|�WdQXntjjdt�tdj|�t�t�dg�}|j
d�}
|
dk	rL|
|�n|r�|j�}|j|tjjt|�|�nWd|j	�tjt�XdS)	N�w�stuff�rb�wbrrZ	__dummy__�call)r�TEMP_ZIP�itemsr�time�	localtime�compression�
compress_type�writestr�close�get�open�read�writer#r �insert�
__import__�join�globals�localsZget_file�assertEqualr�remove)r)Zexpected_ext�files�modules�kw�z�namerr�zinfor5�f�modr8�filerrr�doTestUs4



z$UncompressedZipImportTestCase.doTestcCs�dtjkr|jd�ndtjkr;tjd=nittfd6}y|jd|d�Wn1tk
r�|jt	kr�|j
d�nYn X|jtkr�|j
d�ndS)N�zlibzzlib is a builtin modulezzlib.pyz.pyz&expected test to not raise ImportErrorz"expected test to raise ImportError)r#�builtin_module_namesZskipTestrM�NOW�test_srcrU�ImportErrorr=r�failr)r)rLrrr�
testAFakeZlibxs

z+UncompressedZipImportTestCase.testAFakeZlibcCs.ittftd6}|jd|t�dS)Nz.py)rXrY�TESTMODrU)r)rLrrr�testPy�sz$UncompressedZipImportTestCase.testPycCs.ittftt6}|jt|t�dS)N)rX�test_pycr]�pyc_extrU)r)rLrrr�testPyc�sz%UncompressedZipImportTestCase.testPyccCs?ittftd6ttftt6}|jt|t�dS)Nz.py)rXrYr]r_r`rU)r)rLrrr�testBoth�sz&UncompressedZipImportTestCase.testBothcCs.itdftd6}|jd|t�dS)N�z.py)rXr]rU)r)rLrrr�testEmptyPy�sz)UncompressedZipImportTestCase.testEmptyPycCsYtt�}|ddN<ittftd6t|ftt6}|jd|t�dS)Nr�z.py)�	bytearrayr_rXrYr]r`rU)r)�badmagic_pycrLrrr�testBadMagic�s
z*UncompressedZipImportTestCase.testBadMagiccCsntt�}|ddN<it|ftt6}y|jd|t�Wntk
r\YnX|jd�dS)Nrrez.pyz)expected ImportError; import from bad pyc)rfr_rXr]r`rUrZr[)r)rgrLrrr�
testBadMagic2�s
z+UncompressedZipImportTestCase.testBadMagic2cCsYtt�}|ddN<ittftd6t|ftt6}|jd|t�dS)N��z.py)rfr_rXrYr]r`rU)r)Zbadtime_pycrLrrr�testBadMTime�s
z*UncompressedZipImportTestCase.testBadMTimecCsWttj}ittf|dt6ttf|tt6}|jt|tt�dS)N�__init__)�TESTPACKrrrXr_r`r]rU)r)�packdirrLrrr�testPackage�s
z)UncompressedZipImportTestCase.testPackagecCs�ttj}|ttj}ittf|dt6ttf|dt6ttf|tt6}|jt|ttt�dS)Nrm)	rnrr�	TESTPACK2rXr_r`r]rU)r)ro�packdir2rLrrr�testDeepPackage�s
z-UncompressedZipImportTestCase.testDeepPackagecCs�ttj}|ttj}ittf|dt6ttf|dt6ttf|tt6}tt	d�}zcx]|j
�D]O\}\}}t|tj
|��}|j|_d|_|j||�q�W|j�tjt	�}	|j|	jt	�|j|	jt�d�|	jt�}
|j|	jt�|
j�tt�jd}tjjt	t�}|j||�|j|	j|d�d�|j|	j|t�d�|j|	j|t�d�|t}
t|
�}t|�t j!|}
|j|	j"t�d�|j|	j"|
�d�|j|	j|
�|
j�|
j#}|j|j"|�d�|j|j|�|
j�tjt	tjt�}|j|jt	�|j|j$ttj�Wd|j�tj%t	�XdS)Nrmr4sspamTrF)&rnrrrqrXr_r`r]rr9r:rr;r<r=r>�commentr?r@r2�zipimporterrJ�archive�
is_package�load_module�get_filename�__file__rF�__path__r rGr!r#rM�
get_source�
__loader__�prefixrK)r)rorrrLrOrPrrrQ�zirSZexisting_pack_pathZexpected_path_path�mod_path�mod_name�loaderZzi2rrr�testZipImporterMethods�sN
	



	
z4UncompressedZipImportTestCase.testZipImporterMethodscCsvttj}|ttj}ittf|dt6ttf|tt6}tt	d�}z�x]|j
�D]O\}\}}t|tj
|��}|j|_d|_|j||�qmW|j�tjt	tj|�}	|j|	jt	�|j|	j|�|j|	jt�d�|	jt�}
|j|	jt�|
j�|j|	jttjd�d�|j|	jttjt�d�ttjt}t|�}t|�tj|}
|j|	j t�d�|j|	j |�d�|j|	j|�|
j�|
j!}
|j|
j |�d�|j|
j|�|
j�Wd|j�tj"t	�XdS)Nrmr4seggsTF)#rnrrrqrXr_r`r]rr9r:rr;r<r=r>rtr?r@r2rurJrvr~rwrxryrzr!rFr#rMr|r}rK)r)rorrrLrOrPrrrQrrSr�r�r�rrr�$testZipImporterMethodsInSubDirectorysD
	


	 
zBUncompressedZipImportTestCase.testZipImporterMethodsInSubDirectorycCs�ttd�}|j|_z�d}tdd�td�D��}|j||�|j�tjt�}|j	||j
|��|jdt|��Wd|j�t
jt�XdS)Nr4ztestdata.datcss|]}|VqdS)Nr)�.0�xrrr�	<genexpr>7sz<UncompressedZipImportTestCase.testGetData.<locals>.<genexpr>�zzipimporter object)rr9r=�bytes�ranger?r@r2rurJ�get_dataZassertIn�reprrrK)r)rOrPrrrrr�testGetData2s

z)UncompressedZipImportTestCase.testGetDatacCsed}tt|dd�tt|��}it|ftt6tdfd6}|jt|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")
z<???>r
z	some dataz	some.data)r�compilerX�lenr]r`rU)r)�srcrrLrrr�testImporterAttrAs
$z.UncompressedZipImportTestCase.testImporterAttrcCs8ittftd6}|jd|tddd�dS)Nz.pyr5s
Some Stuff�)rXrYr]rU)r)rLrrr�testImport_WithStuffLsz2UncompressedZipImportTestCase.testImport_WithStuffcCs|jtj|�t�dS)N)rJ�inspectZ	getsourcerY)r)�modulerrr�assertModuleSourceSsz0UncompressedZipImportTestCase.assertModuleSourcecCs7ittftd6}|jd|td|j�dS)Nz.pyr8)rXrYr]rUr�)r)rLrrr�
testGetSourceVsz+UncompressedZipImportTestCase.testGetSourcecCsltttdd�ttt��}ittftd6t|ftt6}|jt|td|j�dS)Nz<???>r
z.pyr8)	rr�rYrXr�r]r`rUr�)r)rrLrrr�testGetCompiledSourceZs$z3UncompressedZipImportTestCase.testGetCompiledSourcecCsAittftd6tdfd6}|jd|td|�dS)Nz.pyz>>> log.append(True)
zxyz.txtr8)rXrYr]rU)r)�callbackrLrrr�
runDoctest`sz(UncompressedZipImportTestCase.runDoctestcCscg}tjd}t_z&tjdd|dddt��Wd|t_X|j|dg�dS)Nzxyz.txt�package�module_relativeT�globs)�doctestZmasterZtestfilerIrJ)r)r��logZ
old_masterrrr�
doDoctestFilees
z+UncompressedZipImportTestCase.doDoctestFilecCs|j|j�dS)N)r�r�)r)rrr�testDoctestFileqsz-UncompressedZipImportTestCase.testDoctestFilecCsEg}tjdd|dddt��j�|j|dg�dS)Nzxyz.txtr�r�Tr�)r�ZDocFileTestrIZrunrJ)r)r�r�rrr�doDoctestSuitets
z,UncompressedZipImportTestCase.doDoctestSuitecCs|j|j�dS)N)r�r�)r)rrr�testDoctestSuite|sz.UncompressedZipImportTestCase.testDoctestSuitec
Cs�y|j�Wn�tj�dj}t|d�d\}}}}|j|tj��t|j	d�d\}}}}|j|tj��t
j�}t|d|�|j
|j�jt��Yn
Xtd��dS)Nrk�rzThis ought to be impossible)Zdo_raiser#�exc_info�tb_nextrrJ�	raise_src�stripr�tb_frame�io�StringIOr	Z
assertTrue�getvalue�endswith�AssertionError)r)r��tbrRZlno�n�line�srrr�doTracebacks"!z)UncompressedZipImportTestCase.doTracebackcCs7ittftd6}|jd|td|j�dS)Nz.pyr8)rXr�r]rUr�)r)rLrrr�
testTraceback�sz+UncompressedZipImportTestCase.testTracebackNzneed an unencodable filenamecCs�tjd}t|d�}ttdtjt��}|j|_	|j
|t�|j�zt
j|�Wdtj|�XdS)Nz.zipr4z.py)r�TESTFN_UNENCODABLErrr]r;r<rXr=r>r?rYr@r2rurrK)r)�filenamerOrQrrr�testUnencodable�s

z-UncompressedZipImportTestCase.testUnencodable)%r,r-r.rr=r*rUr\r^rarbrdrhrirlrprsr�r�r�r�r�r�r�r�r�r�r�r�r�r�r��unittestZskipIfrr�r�rrrrr/Js<# 	3+r/c@seZdZeZdS)�CompressedZipImportTestCaseN)r,r-r.rr=rrrrr��sr�c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�BadFileZipImportTestCasecCs|jtjtj|�dS)N)�assertRaisesr2�ZipImportErrorru)r)r�rrr�assertZipFailure�sz)BadFileZipImportTestCase.assertZipFailurecCs|jd�dS)NZAdfjdkFJKDFJjdklfjs)r�)r)rrr�
testNoFile�sz#BadFileZipImportTestCase.testNoFilecCs|jd�dS)Nrc)r�)r)rrr�testEmptyFilename�sz*BadFileZipImportTestCase.testEmptyFilenamecCs6|jttjd�|jttjtdd�dS)NZkwd)r��	TypeErrorr2rur])r)rrr�testBadArgs�sz$BadFileZipImportTestCase.testBadArgscCs|jdd�dS)N�Ai�)r�)r)rrr�testFilenameTooLong�sz,BadFileZipImportTestCase.testFilenameTooLongcCs+tjt�tjt�|jt�dS)N)r�unlinkr]Zcreate_empty_filer�)r)rrr�
testEmptyFile�s

z&BadFileZipImportTestCase.testEmptyFilecCshtjt�tjttjd�}ztj|�|jt�Wdtjtd�tjt�XdS)Nri�)	rr�r]rrB�O_CREATr@r��chmod)r)�fdrrr�testFileUnreadable�s

z+BadFileZipImportTestCase.testFileUnreadablecCsHtjt�ttd�}|jdd�|j�|jt�dS)Nzw+�a�)rr�r]rBrDr@r�)r)�fprrr�testNotZipFile�s


z'BadFileZipImportTestCase.testNotZipFilec
Cs�tjt�ttd�}|jtjdd��|jd�|j�tj	t�}z|j
t|jd�|j
t|j
d�|j
t|jd�|j
t|jd�|j
t|jd�|j
t|jd�tj}|j|jd�d�|j
||j
d�|j
||jd�|j
t|jd�|j
||jd�|j
||jd�Wdtjj�XdS)Nzw+z=IiPKr���abcZaaaaaaaaaaaaaaaaaa)rr�r]rBrDrrr@r2rur�r��find_modulerxrw�get_coder�r|r�rJ�OSErrorr3r')r)r�rO�errorrrr�_testBogusZipFile�s*


	z*BadFileZipImportTestCase._testBogusZipFileN)r,r-r.r�r�r�r�r�r�r�r�r�rrrrr��sr�cCs,ztjttt�Wdtjt�XdS)N)rZrun_unittestr/r�r�r�r]rrrr�	test_main�sr��__main__)4r#rr�importlib.utilrrr;r�ZtestrZzipfilerrrrr2r0r�r�r��	tracebackrrr	rYr�Ztest_cor�rr!rXr�r_r]rnrqr �abspathr9r�cache_from_sourceZpyc_file�	__debug__r`ZTestCaser"r/Z
requires_zlibr�r�r�r,rrrr�<module>sH"�[G