HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/test/__pycache__/test_urllib2net.cpython-36.pyc
3


 \�1�@s�ddlZddlmZddlmZddlZddlZddlZddl	Zddl
Z
ejd�dZdd�Z
dd	�Zejd
ejkd�Zeejjejj�ZGdd
�d
ej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�ej�dS)�N)�support)�sanepathname2urlZnetwork�<cOsNxDtd�D]8}y
|||�S|k
r@}z|}w
WYdd}~Xq
Xq
W|�dS)N�)�range)�func�exc�args�kwargs�i�e�last_exc�r�'/usr/lib64/python3.6/test_urllib2net.py�
_retry_thrices
rcs��fdd�}|S)Ncst��f|�|�S)N)r)r	r
)rrrr�wrappedsz(_wrap_with_retry_thrice.<locals>.wrappedr)rrrr)rrr�_wrap_with_retry_thricesrZTRAVISz%bpo-35411: skip FTP test on Travis CIc@seZdZdZdS)�	AuthTestsz&Tests urllib2 authentication features.N)�__name__�
__module__�__qualname__�__doc__rrrrr+src@seZdZdd�ZdS)�CloseSocketTestc	CsLd}tj|��4t|�}|j}|j|j�|j�|j|j�WdQRXdS)Nzhttp://www.example.com/)r�transient_internet�_urlopen_with_retry�fp�assertFalse�closed�close�
assertTrue)�self�urlZresponseZsockrrr�
test_closeTszCloseSocketTest.test_closeN)rrrr"rrrrrRsrc@sdeZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	e
jd
�dd��Zddd�Z
dd�ZdS)�OtherNetworkTestscCsdS)Nr)r rrr�setUp`szOtherNetworkTests.setUpcCs&dddtjjfg}|j||j��dS)Nzftp://www.pythontest.net/READMEz*ftp://www.pythontest.net/non-existent-file)�urllib�error�URLError�
_test_urls�_extra_handlers)r �urlsrrr�test_ftpiszOtherNetworkTests.test_ftpcCs�tj}t|d�}zL|jd�|j�dttjj|��ddt	j
jfg}|j||j
�dd�Wdtj|�X|jtt	jjd�dS)N�wz	hi there
zfile:zfile:///nonsensename/etc/passwdT)�retryz./relative_path/to/file)r�TESTFN�open�writerr�os�path�abspathr%r&r'r(r)�removeZassertRaises�
ValueError�request�urlopen)r r.�fr*rrr�	test_filers

zOtherNetworkTests.test_filec
CsFd}tj|��.tjj|�}tjj|�}|j|j�d�WdQRXdS)Nz)http://www.pythontest.net/index.html#frag)rrr%r6�Requestr7�assertEqual�geturl)r Zurlwith_frag�req�resrrr�test_urlwithfrag�s
z"OtherNetworkTests.test_urlwithfragc
CsFd}tj|��.tjj|�}tjj|�}|j|j�d�WdQRXdS)Nz*http://www.pythontest.net/redir/with_frag/z)http://www.pythontest.net/elsewhere/#frag)rrr%r6r:r7r;r<)r Zredirect_url_with_fragr=r>rrr�test_redirect_url_withfrag�s
z,OtherNetworkTests.test_redirect_url_withfragc
Cs�d}tj|��ztjj�}tjj|�}|j|j��|j|�|j	|j��|j	|j
d��|jdd�|j|�|j|j
d�d�WdQRXdS)Nzhttp://www.example.comz
User-agentz
User-Agentz
Test-Agent)rrr%r6�build_openerr:rZheader_itemsr/rZ
has_headerZ
add_headerr;Z
get_header)r r!�openerr6rrr�test_custom_headers�s


z%OtherNetworkTests.test_custom_headersz XXX: http://www.imdb.com is gonecCs�d}tj|��xytjj|��}WdQRXWn,tk
rX}z|jd�WYdd}~XnX|j|�tjj|�}|j�}|j|�WdQRXdS)Nzhttp://www.imdb.comzOurlopen failed for site not sending                            Connection:close)	rrr%r6r7r5Zfailr�read)r ZURLr>rr=rrr�test_sites_no_connection_close�s
z0OtherNetworkTests.test_sites_no_connection_closeTc6Cs�ddl}ddl}|jd�j}tjj|�j}|r<t|tj	j
�}�xL|D�]B}|j|d���*t|t
�rp|\}}	}
nd}	}
tj|���y|||	t�}WnNtk
r�}z2|
r�d|
||	t|�|f}
|j||
|
�n�WYdd}~Xn�XyRtj�Btj�0tj�|j�}|dt|��WdQRXWdQRXWdQRXWn*tjk
�r`td|tjd�YnX|j�WdQRX|jd�WdQRXqDWdS)	NrZtest_urllib2)r!z5Didn't get expected error(s) %s for %s %s, got %s: %sz
read %d bytesz
<timeout: %s>)�fileg�������?) �time�loggingZ	getLogger�debugr%r6rAr/rr&r'ZsubTest�
isinstance�tuplerr�TIMEOUT�OSError�typeZassertIsInstanceZtime_outZsocket_peer_resetZioerror_peer_resetrD�len�socket�timeout�print�sys�stderrrZsleep)r r*�handlersr-rGrHrIr7r!r=Zexpected_errr8�err�msgZbufrrrr(�s<
2zOtherNetworkTests._test_urlscCs2g}tjj�}|j|j�|jd�|j|�|S)N�)r%r6ZCacheFTPHandler�
addCleanupZclear_cacheZ
setTimeout�append)r rUZcfhrrrr)�s


z!OtherNetworkTests._extra_handlersN)T)rrrr$�skip_ftp_test_on_travisr+r9r?r@rC�unittest�skiprEr(r)rrrrr#_s		-

'r#c@s`eZdZdd�Zdd�Zdd�Zdd�Zd	Zed
d��Z	edd
��Z
edd��Zedd��ZdS)�TimeoutTestc	CsX|jtj��d}tj|dd��.t|�}|j|j�|j|jj	j
j��WdQRXdS)Nzhttp://www.example.com)rQ)�assertIsNonerP�getdefaulttimeoutrrrrYrr�raw�_sock�
gettimeout)r r!�urrr�test_http_basicszTimeoutTest.test_http_basiccCsr|jtj��d}tj|��Ltjd�zt|�}|j|j�Wdtjd�X|j	|j
jjj
�d�WdQRXdS)Nzhttp://www.example.comr)r_rPr`rr�setdefaulttimeoutrrYrr;rrarbrc)r r!rdrrr�test_http_default_timeouts
z%TimeoutTest.test_http_default_timeoutcCst|jtj��d}tj|��Ntjd�zt|dd�}|j|j�Wdtjd�X|j|j	j
jj��WdQRXdS)Nzhttp://www.example.comr)rQ)
r_rPr`rrrfrrYrrrarbrc)r r!rdrrr�test_http_no_timeouts
z TimeoutTest.test_http_no_timeoutcCsLd}tj|��4t|dd�}|j|j�|j|jjjj	�d�WdQRXdS)Nzhttp://www.example.com�x)rQ)
rrrrYrr;rrarbrc)r r!rdrrr�test_http_timeout$s
zTimeoutTest.test_http_timeoutzftp://www.pythontest.net/c	CsZ|jtj��tj|jdd��2t|j�}|j|j�|j|j	j	j
jj��WdQRXdS)N)rQ)
r_rPr`rr�FTP_HOSTrrYrrrarbrc)r rdrrr�test_ftp_basic-s

zTimeoutTest.test_ftp_basiccCst|jtj��tj|j��Ptjd�zt|j�}|j|j	�Wdtjd�X|j
|jjjj
j�d�WdQRXdS)Nr)r_rPr`rrrkrfrrYrr;rrarbrc)r rdrrr�test_ftp_default_timeout5s

z$TimeoutTest.test_ftp_default_timeoutcCsv|jtj��tj|j��Rtjd�zt|jdd�}|j|j	�Wdtjd�X|j|j
j
jjj
��WdQRXdS)Nr)rQ)r_rPr`rrrkrfrrYrrrarbrc)r rdrrr�test_ftp_no_timeoutAs
zTimeoutTest.test_ftp_no_timeoutcCsNtj|j��8t|jdd�}|j|j�|j|jjjj	j
�d�WdQRXdS)Nr)rQ)rrrkrrYrr;rrarbrc)r rdrrr�test_ftp_timeoutMszTimeoutTest.test_ftp_timeoutN)
rrrrergrhrjrkr[rlrmrnrorrrrr^sr^�__main__)r\ZtestrZtest.test_urllib2rr1rPZurllib.errorr%Zurllib.requestrSZrequiresrLrrZskipIf�environr[r6r7r&r'rZTestCaserrr#r^r�mainrrrr�<module>s,
	
'
%R