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_urllib2net.cpython-39.opt-2.pyc

a

��g�2�@s�ddlZddlmZddlmZddlmZddlZddlZddl	Z
ddlZ
ddlZe�
d�dd�Zdd	�Ze�d
ejvd�Zee
jje
jj�ZGdd
�d
ej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�e��dS)�N)�support)�
socket_helper)�sanepathname2url�networkcOs`td�D]N}z||i|��WS|yT}z|}WYd}~qWYd}~qd}~00q|�dS)N�)�range)�func�exc�args�kwargs�i�e�last_exc�r�0/usr/local/lib/python3.9/test/test_urllib2net.py�
_retry_thrices$rcs��fdd�}|S)Ncst��g|�Ri|��S�N)r)r
r�r	rrr�wrappedsz(_wrap_with_retry_thrice.<locals>.wrappedr)rr	rrrr�_wrap_with_retry_thricesrZTRAVISz%bpo-35411: skip FTP test on Travis CIc@seZdZdS)�	AuthTestsN)�__name__�
__module__�__qualname__rrrrr*src@seZdZdd�ZdS)�CloseSocketTestcCsp|�tjj�tj}t�|��>t|�}|j	}|�
|j�|��|�
|j�Wd�n1sb0YdSr)�
addCleanup�urllib�request�
urlcleanupr�
TEST_HTTP_URLr�transient_internet�_urlopen_with_retry�fp�assertFalse�closed�close�
assertTrue)�self�url�response�sockrrr�
test_closeSszCloseSocketTest.test_closeN)rrrr+rrrrrQsrc@sdeZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	e
�d
�dd��Zddd�Z
dd�ZdS)�OtherNetworkTestscCsdSrr�r'rrr�setUpbszOtherNetworkTests.setUpcCs&dddtjjfg}|�||���dS)Nzftp://www.pythontest.net/READMEz*ftp://www.pythontest.net/non-existent-file)r�error�URLError�
_test_urls�_extra_handlers)r'�urlsrrr�test_ftpks��zOtherNetworkTests.test_ftpc	Cs�tj}t|d�}zV|�d�|��dttj�|��ddt	j
jfg}|j||�
�dd�Wt�|�nt�|�0|�tt	jjd�dS)N�wz	hi there
zfile:zfile:///nonsensename/etc/passwdT)�retryz./relative_path/to/file)r�TESTFN�open�writer%r�os�path�abspathrr/r0r1r2�removeZassertRaises�
ValueErrorr�urlopen)r'r7�fr3rrr�	test_filets

��zOtherNetworkTests.test_filecCsZd}t�|��8tj�|�}tj�|�}|�|��d�Wd�n1sL0YdS)Nz)http://www.pythontest.net/index.html#frag�rr rr�Requestr?�assertEqual�geturl)r'Zurlwith_frag�req�resrrr�test_urlwithfrag�s
�z"OtherNetworkTests.test_urlwithfragcCsZd}t�|��8tj�|�}tj�|�}|�|��d�Wd�n1sL0YdS)Nz*http://www.pythontest.net/redir/with_frag/z)http://www.pythontest.net/elsewhere/#fragrB)r'Zredirect_url_with_fragrFrGrrr�test_redirect_url_withfrag�s
�z,OtherNetworkTests.test_redirect_url_withfragcCs�tj}t�|���tj��}tj�|�}|�|�	��|�
|�|�|�	��|�|�d��|�
dd�|�
|�|�|�d�d�Wd�n1s�0YdS)Nz
User-agentz
User-Agentz
Test-Agent)rrrr rr�build_openerrCr#Zheader_itemsr8r&Z
has_headerZ
add_headerrDZ
get_header)r'r(�openerrrrr�test_custom_headers�s


z%OtherNetworkTests.test_custom_headersz XXX: http://www.imdb.com is gonec	Cs�d}t�|���z0tj�|��}Wd�n1s40YWnty\|�d�Yn0|�|�tj�|�}|��}|�|�Wd�n1s�0YdS)Nzhttp://www.imdb.comzOurlopen failed for site not sending                            Connection:close)	rr rrr?r>Zfailr&�read)r'ZURLrGrFrrr�test_sites_no_connection_close�s"
z0OtherNetworkTests.test_sites_no_connection_closeTc
Cs�ddl}ddl}|�d�j}tjj|�j}|r<t|tj	j
�}|D�]�}|j|d����t|t
�rl|\}}	}
nd}	}
t�|���:z|||	tj�}WnPty�}z8|
r�d|
||	t|�|f}
|�||
|
�n�WYd}~n�d}~00z�tj�xtj�Ptj�(|��}|dt|��Wd�n1�s.0YWd�n1�sN0YWd�n1�sn0YWn(tj�y�td|tjd�Yn0|��Wd�n1�s�0Y|� d�Wd�q@1�s�0Yq@dS)	NrZtest_urllib2)r(z5Didn't get expected error(s) %s for %s %s, got %s: %sz
read %d bytesz
<timeout: %s>)�fileg�������?)!�time�logging�	getLogger�debugrrrJr8rr/r0ZsubTest�
isinstance�tuplerr rZINTERNET_TIMEOUT�OSError�typeZassertIsInstanceZtime_outZsocket_peer_resetZioerror_peer_resetrM�len�socket�timeout�print�sys�stderrr%�sleep)r'r3�handlersr6rPrQrSr?r(rFZexpected_errr@�err�msg�bufrrrr1�sB

���t(zOtherNetworkTests._test_urlscCs2g}tj��}|�|j�|�d�|�|�|S)N�)rrZCacheFTPHandlerr�clear_cacheZ
setTimeout�append)r'r_Zcfhrrrr2�s


z!OtherNetworkTests._extra_handlersN)T)rrrr.�skip_ftp_test_on_travisr4rArHrIrL�unittest�skiprNr1r2rrrrr,as	
-


'r,c@sheZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdZe	dd
��Z
e	dd��Ze	dd��Ze	dd��Z
dS)�TimeoutTestcCs|�tjj�dSr)rrrrr-rrrr.szTimeoutTest.setUpcCsn|�t���tj}tj|dd��8t|�}|�|j	�|�|j
jj�
��Wd�n1s`0YdS�N�rZ)�assertIsNonerY�getdefaulttimeoutrrrr r!rr%r"�raw�_sock�
gettimeout�r'r(�urrr�test_http_basic
szTimeoutTest.test_http_basicc
Cs�|�t���tj}t�|��`t�d�z"t|�}|�	|j
�Wt�d�nt�d�0|�|jj
j��d�Wd�n1s�0YdS�N�<)rlrYrmrrrr �setdefaulttimeoutr!rr%rDr"rnrorprqrrr�test_http_default_timeouts
z%TimeoutTest.test_http_default_timeoutc
Cs�|�t���tj}t�|��bt�d�z&t|dd�}|�	|j
�Wt�d�nt�d�0|�|jjj
���Wd�n1s�0YdS�Nrurk)rlrYrmrrrr rvr!rr%r"rnrorprqrrr�test_http_no_timeouts
z TimeoutTest.test_http_no_timeoutcCsbtj}t�|��>t|dd�}|�|j�|�|jj	j
��d�Wd�n1sT0YdS)N�xrk)rrrr r!rr%rDr"rnrorprqrrr�test_http_timeout*s
zTimeoutTest.test_http_timeoutzftp://www.pythontest.net/cCsn|�t���tj|jdd��<t|j�}|�|j�|�|j	j	j
j���Wd�n1s`0YdSrj)
rlrYrmrr �FTP_HOSTr!rr%r"rnrorp�r'rrrrr�test_ftp_basic3s

zTimeoutTest.test_ftp_basicc
Cs�|�t���t�|j��dt�d�z$t|j�}|�|j	�Wt�d�nt�d�0|�
|jjjj
��d�Wd�n1s�0YdSrt)rlrYrmrr r|rvr!rr%rDr"rnrorpr}rrr�test_ftp_default_timeout;s

z$TimeoutTest.test_ftp_default_timeoutc
Cs�|�t���t�|j��ft�d�z(t|jdd�}|�|j	�Wt�d�nt�d�0|�|j
j
jj�
��Wd�n1s�0YdSrx)rlrYrmrr r|rvr!rr%r"rnrorpr}rrr�test_ftp_no_timeoutGs
zTimeoutTest.test_ftp_no_timeoutcCsbt�|j��Bt|jdd�}|�|j�|�|jjjj	�
�d�Wd�n1sT0YdSrx)rr r|r!rr%rDr"rnrorpr}rrr�test_ftp_timeoutSszTimeoutTest.test_ftp_timeoutN)rrrr.rsrwryr{r|rfr~rr�r�rrrrris


ri�__main__)rg�testrZtest.supportrZtest.test_urllib2rr:rYZurllib.errorrZurllib.requestr\ZrequiresrrZskipIf�environrfrr?r/r0r!ZTestCaserrr,rir�mainrrrr�<module>s0
	��'%V

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