Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_urllib2net.cpython-312.opt-1.pyc

�

'Μg�7��n�ddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddl
Z
ddlZddlZ
ddlZ
ddlZej d�d�Zd	�Zee
j&j(e
j*j,�ZGd
�de�Zeeej6��Zeeej:��Zeeej:��ZGd
�dej@�Z!Gd�dej@�Z"Gd�dej@�Z#Gd�dej@�Z$e%dk(rejL�yy)�N)�support)�	os_helper)�
socket_helper)�ResourceDenied)�sanepathname2url�networkc�b�td�D]}	||i|��cS�#|$r}|}Yd}~�d}~wwxYw)N�)�range)�func�exc�args�kwargs�i�e�last_excs       �1/usr/local/lib/python3.12/test/test_urllib2net.py�
_retry_thricersF��
�1�X��	���(��(�(���N���	��H���	�s��.�)�.c������fd�}|S)Nc�$��t��g|��i|��S�N)r)rrr
rs  ��r�wrappedz(_wrap_with_retry_thrice.<locals>.wrappeds����T�3�8��8��8�8��)rr
rs`` r�_wrap_with_retry_thricers
���9��Nrc�$�eZdZdZd�Zd�Zdd�Zy)�TransientResourcez�Raise ResourceDenied if an exception is raised while the context manager
    is in effect that matches the specified exception and attributes.c� �||_||_yr)r
�attrs)�selfr
rs   r�__init__zTransientResource.__init__+s�������
rc��|Srr�r s r�	__enter__zTransientResource.__enter__/s���rNc���|�ct|j|�rL|jj�D]$\}}t	||�syt||�|k7s�$yt
d��yy)z�If type_ is a subclass of self.exc and value has attributes matching
        self.attrs, raise ResourceDenied.  Otherwise let the exception
        propagate (if any).Nz%an optional resource is not available)�
issubclassr
r�items�hasattr�getattrr)r �type_�value�	traceback�attr�
attr_values      r�__exit__zTransientResource.__exit__2sh�����D�H�H�e�!<�$(�J�J�$4�$4�$6� ��j��u�d�+���5�$�'�:�5��	%7�%�%L�M�M�"=�r)NNN)�__name__�
__module__�__qualname__�__doc__r!r$r/rrrrr&s��I���Nrr)�errnoc��eZdZdZy)�	AuthTestsz&Tests urllib2 authentication features.N)r0r1r2r3rrrr6r6Gs��0rr6c��eZdZd�Zy)�CloseSocketTestc��|jtjj�tj
}t
j|�5t|�}|j}|j|j�|j�|j|j�ddd�y#1swYyxYwr)�
addCleanup�urllib�request�
urlcleanupr�
TEST_HTTP_URLr�transient_internet�_urlopen_with_retry�fp�assertFalse�closed�close�
assertTrue)r �url�response�socks    r�
test_closezCloseSocketTest.test_closeps~��������1�1�2��#�#��
�
-�
-�c�
2�*�3�/�H��;�;�D����T�[�[�)��N�N���O�O�D�K�K�(�3�
2�
2�s
�AB6�6B?N)r0r1r2rIrrrr8r8ns��)rr8c���eZdZd�Zej
d�d��Zd�Zd�Zej
d�d��Z	d�Z
ejd�d	��Z
d
d
�Zd�Zy)�OtherNetworkTestsc��yr)�logging�	getLogger�
addHandler�
StreamHandler)r rM�loggers   r�setUpzOtherNetworkTests.setUps��r�walltimec��ddddtjjfg}|j||j	��y)Nzftp://www.pythontest.net/READMEz*ftp://www.pythontest.net/non-existent-file)r;�error�URLError�
_test_urls�_extra_handlers)r �urlss  r�test_ftpzOtherNetworkTests.test_ftp�sA��
.�-�
9�
�6�<�<�(�(�
*���	
����d�2�2�4�5rc��tj}t|d�}	|jd�|j	�dttjj|��zddtjjfg}|j||j�d��t
j|�|jt tj"j$d�y#t
j|�wxYw)N�wz	hi there
zfile:zfile:///nonsensename/etc/passwdT)�retryz./relative_path/to/file)r�TESTFN�open�writerDr�os�path�abspathr;rUrVrWrX�remove�assertRaises�
ValueErrorr<�urlopen)r r^�frYs    r�	test_filezOtherNetworkTests.test_file�s����!�!�������
	�
�G�G�L�!�
�G�G�I��*�2�7�7�?�?�6�+B�C�C�2�D����&�&�(��D�

�O�O�D�$�"6�"6�"8��O�E��I�I�f�����*�f�n�n�&<�&<�=V�W��
�I�I�f��s�BC.�.Dc��d}tj|�5tjj	|�}tjj|�}|j
|j�d�ddd�y#1swYyxYw)Nz)http://www.pythontest.net/index.html#frag�rr?r;r<�Requestrg�assertEqual�geturl)r �urlwith_frag�req�ress    r�test_urlwithfragz"OtherNetworkTests.test_urlwithfrag�sc��B��
�
-�
-�l�
;��.�.�(�(��6�C��.�.�(�(��-�C����S�Z�Z�\�?�
A�<�
;�
;���AB�B	c��d}tj|�5tjj	|�}tjj|�}|j
|j�d�ddd�y#1swYyxYw)Nz*http://www.pythontest.net/redir/with_frag/z)http://www.pythontest.net/elsewhere/#fragrk)r �redirect_url_with_fragrprqs    r�test_redirect_url_withfragz,OtherNetworkTests.test_redirect_url_withfrag�sg��!M��
�
-�
-�.D�
E��.�.�(�(�)?�@�C��.�.�(�(��-�C����S�Z�Z�\�?�
A�F�
E�
E�rsc�X�tj}tj|�5tj
j
�}tj
j|�}|j|j��|j|�|j|j��|j|jd��|jdd�|j|�|j|jd�d�ddd�y#1swYyxYw)Nz
User-agentz
User-Agentz
Test-Agent)rr>rr?r;r<�build_openerrlrB�header_itemsr_rE�
has_header�
add_headerrm�
get_header)r rF�openerr<s    r�test_custom_headersz%OtherNetworkTests.test_custom_headers�s����#�#��
�
-�
-�c�
2��^�^�0�0�2�F��n�n�,�,�S�1�G����W�1�1�3�4��K�K�� ��O�O�G�0�0�2�3��O�O�G�.�.�|�<�=����|�L�9��K�K�� ����W�/�/��=�l�K�3�
2�
2�s�C1D � D)z XXX: http://www.imdb.com is gonec��d}tj|�5	tjj	|�5}	ddd�|j�tjj	|�}|j�}|j|�ddd�y#1swY�cxYw#t$r|jd�Y�qwxYw#1swYyxYw)Nzhttp://www.imdb.comzOurlopen failed for site not sending                            Connection:close)	rr?r;r<rgrErf�fail�read)r �URLrqrps    r�test_sites_no_connection_closez0OtherNetworkTests.test_sites_no_connection_close�s���
$��
�
-�
-�c�
2�
%��^�^�+�+�C�0�C��1�����$��.�.�(�(��-�C��(�(�*�C��O�O�C� �3�
2�0�0���
.��	�	�-�.�
.��	3�
2�sE�C	�B)�B�B)�AC	�B&	�"B)�)C�C	�C�C	�	Cc��ddl}ddl}|jd�j}t	j
j|�j}|r$t|tjj�}|D]�}|j|��5t|t�r|\}}	}
ndx}	}
tj|�5	|||	t j"�}	t$5t&5t(5|j+�}|dt-|�z�ddd�ddd�ddd�|j7�ddd�|j?d�ddd���y#1swY�MxYw#1swY�QxYw#1swY�UxYw#t.$r!t1d|zt2j4��Y��wxYw#t8$r;}
|
r.d|
�d|�d	|	�d
t;|
��d|
��
}|j=|
|
|�n�Yd}
~
��d}
~
wwxYw#1swY��xYw#1swY���xYw)
Nr�test_urllib2)rFz
read %d bytesz
<timeout: %s>)�filezDidn't get expected error(s) z for � z, got z: g�������?) �timerMrN�debugr;r<rxr_rrUrV�subTest�
isinstance�tuplerr?r�INTERNET_TIMEOUT�time_out�socket_peer_reset�ioerror_peer_resetr��len�TimeoutError�print�sys�stderrrD�OSError�type�assertIsInstance�sleep)r rY�handlersr]r�rMr�rgrFrp�expected_errrh�buf�err�msgs               rrWzOtherNetworkTests._test_urls�s������!�!�.�1�7�7���.�.�-�-�x�8�=�=���-�g�v�|�|�7L�7L�M�G��C����#��&��c�5�)�-0�*�C��l�)-�-�C�,�"�5�5�c�:�"�#�C��g�.F�.F�G��J�!)�!2�!3�&'�f�f�h�� %�o��C��&@� A�"4�"3�"*����	�);�*�
�
�3��7'�&��,"4�!3��"3�!2��"*���
 ,�J�!�/�C�"7�c�j�j�I�J��#�"�'�$0�#�s�D��I�s�$L�C� �1�1�#�|�S�I�!�J��	"��	;�:��
'�&�s��1G<�8G0�:F)�E<�E0	� E$�'%E
�E$�E0	�E<�$G0�4G<�E!�E$�$E-�)E0	�0E9
�5E<�<'F&	�#G0�%F&	�&G0�)	G-	�21G(	�#G0�(G-	�-G0�0G9�5G<�<H	c��g}tjj�}|j|j�|jd�|j
|�|S)N�)r;r<�CacheFTPHandlerr:�clear_cache�
setTimeout�append)r r��cfhs   rrXz!OtherNetworkTests._extra_handlerssF�����n�n�,�,�.��������(����q��������rN)T)r0r1r2rRr�requires_resourcerZrirrrvr~�unittest�skipr�rWrXrrrrKrK~s���7��W���z�*�6�+�6�X�ZA��W���z�*�A�+�A�L��X�]�]�5�6�!�7�!�(% �NrrKc���eZdZd�Zd�Zd�Zd�Zd�ZdZe	jd�d��Zd	�Ze	jd�d
��Z
e	jd�d��Zy)
�TimeoutTestc�V�|jtjj�yr)r:r;r<r=r#s rrRzTimeoutTest.setUp&s��������1�1�2rc��|jtj��tj}tj|d��5t|�}|j|j�|j|jjjj��ddd�y#1swYyxYw�N��timeout)�assertIsNone�socket�getdefaulttimeoutrr>rr?r@r:rDrA�raw�_sock�
gettimeout�r rF�us   r�test_http_basiczTimeoutTest.test_http_basic*s~�����&�2�2�4�5��#�#��
�
-�
-�c�4�
@�#�C�(�A��O�O�A�G�G�$����a�d�d�h�h�n�n�7�7�9�:�A�
@�
@�s
�A$B8�8Cc��|jtj��tj}tj|�5tjd�	t|�}|j|j�tjd�|j|jjjj�d�ddd�y#tjd�wxYw#1swYyxYw�N�<)r�r�r�rr>rr?�setdefaulttimeoutr@r:rDrmrAr�r�r�r�s   r�test_http_default_timeoutz%TimeoutTest.test_http_default_timeout2s������&�2�2�4�5��#�#��
�
-�
-�c�
2��$�$�R�(�
/�'��,��������(��(�(��.����Q�T�T�X�X�^�^�6�6�8�"�=�3�
2���(�(��.��
3�
2�s%�	C<� &C"�AC<�"C9�9C<�<Dc��|jtj��tj}tj|�5tjd�	t|d��}|j|j�tjd�|j|jjjj��ddd�y#tjd�wxYw#1swYyxYw�Nr�r�)r�r�r�rr>rr?r�r@r:rDrAr�r�r�r�s   r�test_http_no_timeoutz TimeoutTest.test_http_no_timeout>s������&�2�2�4�5��#�#��
�
-�
-�c�
2��$�$�R�(�
/�'��T�:��������(��(�(��.����a�d�d�h�h�n�n�7�7�9�:�3�
2���(�(��.��
3�
2�s%�	C=� (C#�AC=�#C:�:C=�=Dc�D�tj}tj|�5t	|d��}|j|j�|j|jjjj�d�ddd�y#1swYyxYw)N�xr�)rr>rr?r@r:rDrmrAr�r�r�r�s   r�test_http_timeoutzTimeoutTest.test_http_timeoutJsh���#�#��
�
-�
-�c�
2�#�C��5�A��O�O�A�G�G�$����Q�T�T�X�X�^�^�6�6�8�#�>�3�
2�
2�s�A'B�Bzftp://www.pythontest.net/rSc��|jtj��tj|j
d��5t
|j
�}|j|j�|j|jjjjj��ddd�y#1swYyxYwr�)
r�r�r�rr?�FTP_HOSTr@r:rDrAr�r�r��r r�s  r�test_ftp_basiczTimeoutTest.test_ftp_basicSs������&�2�2�4�5�
�
-�
-�d�m�m�T�
J�#�D�M�M�2�A��O�O�A�G�G�$����a�d�d�g�g�k�k�/�/�:�:�<�=�K�
J�
J�s
�A8C�Cc�,�|jtj��tj|j
�5tjd�	t|j
�}|j|j�tjd�|j|jjjjj�d�ddd�y#tjd�wxYw#1swYyxYwr�)r�r�r�rr?r�r�r@r:rDrmrAr�r�r�r�s  r�test_ftp_default_timeoutz$TimeoutTest.test_ftp_default_timeout[s������&�2�2�4�5�
�
-�
-�d�m�m�
<��$�$�R�(�
/�'��
�
�6��������(��(�(��.����Q�T�T�W�W�[�[�.�.�9�9�;�R�@�=�
<���(�(��.��
=�
<�s%�D
�0C0�
AD
�0D�D
�
Dc�.�|jtj��tj|j
�5tjd�	t|j
d��}|j|j�tjd�|j|jjjjj��ddd�y#tjd�wxYw#1swYyxYwr�)r�r�r�rr?r�r�r@r:rDrAr�r�r�r�s  r�test_ftp_no_timeoutzTimeoutTest.test_ftp_no_timeoutfs������&�2�2�4�5�
�
-�
-�d�m�m�
<��$�$�R�(�
/�'��
�
�t�D��������(��(�(��.����a�d�d�g�g�k�k�/�/�:�:�<�=�=�
<���(�(��.��
=�
<�s%�D�2C1�AD�1D�D�Dc�`�tj|j�5t|jd��}|j	|j
�|j
|jjjjj�d�ddd�y#1swYyxYwr�)rr?r�r@r:rDrmrAr�r�r�r�s  r�test_ftp_timeoutzTimeoutTest.test_ftp_timeoutrsk��
�
-�
-�d�m�m�
<�#�D�M�M�2�>�A��O�O�A�G�G�$����Q�T�T�W�W�[�[�.�.�9�9�;�R�@�=�
<�
<�s�A;B$�$B-N)r0r1r2rRr�r�r�r�r�rr�r�r�r�r�rrrr�r�%s���3�;�
>�
;�?�+�H��W���z�*�>�+�>�	A��W���z�*�	>�+�	>��W���z�*�A�+�Arr��__main__)'r4r��testr�test.supportrrr�test.test_urllib2rrar��urllib.errorr;�urllib.requestr��requiresrrr<rgrUrVr@�objectrr��	ETIMEDOUTr��
ECONNRESETr�r��TestCaser6r8rKr�r0�mainrrr�<module>r�s�����"�&�'�.�	�
���
���������.�f�n�n�.D�.D�.4�l�l�.C�.C�E��N��N�8�W�E�O�O�<��%�g�U�5E�5E�F��&�w�e�6F�6F�G��1��!�!�1�N)�h�'�'�)� d��)�)�d�NRA�(�#�#�RA�j�z���H�M�M�O�r

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