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_urllib.cpython-312.opt-2.pyc

�

'Μg���:�	ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZddlZ	ddlZddlZddlZddlmZmZddlmZddlZej:se	j<d	��d
�Zda d3d�Z!d�Z"d4d
�Z#Gd�de$�Z%Gd�de$�Z&Gd�de	jN�Z(Gd�de	jN�Z)Gd�de	jN�Z*Gd�de	jNe%e&�Z+Gd�de	jN�Z,Gd�de	jN�Z-Gd�de	jNe%�Z.Gd �d!e	jN�Z/Gd"�d#e	jN�Z0Gd$�d%e	jN�Z1Gd&�d'e	jN�Z2Gd(�d)e	jN�Z3Gd*�d+e%e	jN�Z4Gd,�d-e	jN�Z5Gd.�d/e	jN�Z6Gd0�d1e	jN�Z7e8d2k(re	jr�yy#e$rdZY���wxYw)5�N)�patch)�support)�	os_helper)�
socket_helper)�warnings_helper)�url2pathname�pathname2url)�	b64encodeztest requires gethostname()c�~�	tt|��ddj�}t|�dk(rd|z}d|zS)N��z0%s�%)�hex�ord�upper�len)�char�hex_reprs  �-/usr/local/lib/python3.12/test/test_urllib.py�	hexescaper sB��+��3�t�9�~�a�b�!�'�'�)�H�
�8�}����8�#����>��c���	|�!tjj|��}nts
t�}|ant}|�|j	|�S|j	||�S)N)�proxies)�urllib�request�FancyURLopener�
_urlopener�open)�url�datar�openers    r�urlopenr"+s\��8������.�.�w�.�?��
��!���
����|��{�{�3����{�{�3��%�%rc��tjdtf�5tjj�cddd�S#1swYyxYw)Nz8FancyURLopener style of invoking requests is deprecated.)r�check_warnings�DeprecationWarningrrr�rrrr;s=��	�	'�	'�
G��
 �
!��~�~�,�,�.�
!�
!�
!�s�A�A
c�����G�fd�dtj��G��fd�dtjj��|�_�S)Nc�8��eZdZdZ�fd�Zd�Zdd�Zdd�Zd�Zy)	�fakehttp.<locals>.FakeSocketr
c���|�_y�N)�buf)�selfr �FakeHTTPConnections  �r�sendallz$fakehttp.<locals>.FakeSocket.sendallFs���%)��"rc�0�|xjdz
c_|S)Nr
)�io_refs)r-�args�kwdss   r�makefilez%fakehttp.<locals>.FakeSocket.makefileIs���L�L�A��L��KrNc�\�|jrytjj||�S�Nr)�closed�io�BytesIO�read)r-�amts  rr:z!fakehttp.<locals>.FakeSocket.readMs!���{�{���:�:�?�?�4��-�-rc�\�|jrytjj||�Sr6)r7r8r9�readline)r-�lengths  rr=z%fakehttp.<locals>.FakeSocket.readlineRs#���{�{���:�:�&�&�t�V�4�4rc��|xjdzc_|jdk(r tjj|�yy)Nr
r)r1r8r9�close�r-s rr@z"fakehttp.<locals>.FakeSocket.closeWs3���L�L�A��L��|�|�q� ��
�
� � ��&�!rr+)	�__name__�
__module__�__qualname__r1r/r4r:r=r@)r.s�r�
FakeSocketr)Cs!�����	*�	�	.�
	5�
	'rrEc�*��eZdZdZ�fd�ZW�rd�Zyy)�$fakehttp.<locals>.FakeHTTPConnectionNc�h���|j�|_|jt|�_yr+)�fakedata�sock�type�fakesock)r-rEs �r�connectz,fakehttp.<locals>.FakeHTTPConnection.connectas#���"�4�=�=�1�D�I�"&�)�)�D��J�rc��yr+r&rAs rr@z*fakehttp.<locals>.FakeHTTPConnection.closej���r)rBrCrDr,rMr@)rE�
mock_closes��rr.rG\s�����	,��

�rr.)r8r9�http�client�HTTPConnectionrI)rIrPr.rEs `@@r�fakehttprTBs:���'�R�Z�Z�'�2�T�[�[�7�7�� #+����rc��eZdZdd�Zd�Zy)�
FakeHTTPMixinc��t||��}tjj|_|tj_y)N�rP)rTrQrRrS�_connection_class)r-rIrP�fake_http_classs    rrTzFakeHTTPMixin.fakehttprs,��"�8�
�C��!%���!;�!;���%4����"rc�B�|jtj_yr+)rYrQrRrSrAs r�
unfakehttpzFakeHTTPMixin.unfakehttpws��%)�%;�%;����"rN�F)rBrCrDrTr\r&rrrVrVqs��5�
<rrVc��eZdZd�Zd�Zy)�FakeFTPMixinc��Gd�dt�}tjj|_|tj_y)Nc�$�eZdZ		dd�Zd�Zd�Zy)�,FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapperNc��yr+r&)r-�user�passwd�host�port�dirs�timeout�
persistents        r�__init__z5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.__init__~s��rc�.�tj�dfS)Nr)r8r9)r-�filerKs   r�retrfilez5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfile�s���z�z�|�Q��&rc��yr+r&rAs rr@z2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.close�rOr)NT)rBrCrDrkrnr@r&rr�FakeFtpWrapperrb}s��HL� $�
�
'�
rrp)�objectrr�
ftpwrapper�_ftpwrapper_class)r-rps  r�fakeftpzFakeFTPMixin.fakeftp|s.��		�V�		�"(���!:�!:���$2����!rc�B�|jtj_yr+)rsrrrrrAs r�	unfakeftpzFakeFTPMixin.unfakeftp�s��$(�$:�$:����!rN)rBrCrDrtrvr&rrr_r_{s��
3�;rr_c�n�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�urlopen_FileTestsc���td|jjzd�|_t	t
jd�}	|j|j�|j�t
j|_	tjj|j�|_
td|jz�|_y#|j�wxYw)Nztest_urllib: %s
�ascii�wb�file:%s)�bytes�	__class__rB�textrr�TESTFN�writer@�pathnamer�parse�quote�quoted_pathnamer"�returned_obj)r-�fs  r�setUpzurlopen_FileTests.setUp�s����-����0G�0G�G�!�#��	���!�!�4�(��	�
�G�G�D�I�I��
�G�G�I�!�(�(��
�%�|�|�1�1�$�-�-�@���#�I��0D�0D�$D�E����
�G�G�I�s�C�C"c��	|jj�tjtj
�yr+)r�r@�os�removerr�rAs r�tearDownzurlopen_FileTests.tearDown�s)��'������!�
�	�	�)�"�"�#rc�d�dD]+}|jt|j|�d|z��-y)N)	r:r=�	readlines�filenor@�info�geturl�getcode�__iter__�/object returned by urlopen() lacks %s attribute)�
assertTrue�hasattrr��r-�attrs  r�test_interfacez urlopen_FileTests.test_interface�s6��G�D��O�O�G�D�$5�$5�t�<�J���
�Grc�l�|j|j|jj��yr+)�assertEqualrr�r:rAs r�	test_readzurlopen_FileTests.test_read�s%��������D�$5�$5�$:�$:�$<�=rc���|j|j|jj��|jd|jj�d�y)NrzKcalling readline() after exhausting the file did not return an empty string)r�rr�r=rAs r�
test_readlinezurlopen_FileTests.test_readline�sK��������D�$5�$5�$>�$>�$@�A�����d�/�/�8�8�:�3�	4rc��|jj�}|jt|�dd�|j|d|jd�y)Nr
z.readlines() returned the wrong number of linesrz"readlines() returned improper text)r�r�r�rr)r-�
lines_lists  r�test_readlinesz urlopen_FileTests.test_readlines�sM���&�&�0�0�2�
�����Z��!�I�	K�����A���	�	�=�	?rc���|jj�}|j|td�|j	tj|t|j��|jd�y)Nzfileno() did not return an intzTReading on the file descriptor returned by fileno() did not return the expected text)	r�r��assertIsInstance�intr�r�r:rr)r-�file_nums  r�test_filenozurlopen_FileTests.test_fileno�sW���$�$�+�+�-�����h��-M�N��������3�t�y�y�>�:�D�I�I�<�	=rc�8�|jj�yr+)r�r@rAs r�
test_closezurlopen_FileTests.test_close�s��	
�����!rc��|j|jjtjj
�yr+)r�r��headers�email�message�MessagerAs r�test_headerszurlopen_FileTests.test_headers�s(�����d�/�/�7�7����9N�9N�Orc�d�|j|jj|j�yr+)r�r�rr�rAs r�test_urlzurlopen_FileTests.test_url�s$������*�*�.�.��0D�0D�Erc�N�|j|jj�yr+)�assertIsNoner��statusrAs r�test_statuszurlopen_FileTests.test_status�s�����$�+�+�2�2�3rc��|j|jj�tjj
�yr+)r�r�r�r�r�r�rAs r�	test_infozurlopen_FileTests.test_info�s+�����d�/�/�4�4�6��
�
�8M�8M�Nrc�l�|j|jj�|j�yr+)r�r�r�r�rAs r�test_geturlzurlopen_FileTests.test_geturl�s'������*�*�1�1�3�T�5I�5I�Jrc�V�|j|jj��yr+)r�r�r�rAs r�test_getcodezurlopen_FileTests.test_getcode�s�����$�+�+�3�3�5�6rc�^�|jD]}|j||j�� yr+)r�r�r)r-�lines  r�	test_iterzurlopen_FileTests.test_iter�s(���%�%�D����T�4�9�9�-�&rc�|�|jttjjd|j
z�y)Nz./)�assertRaises�
ValueErrorrrr"r�rAs r�test_relativelocalfilez(urlopen_FileTests.test_relativelocalfile�s'�����*�V�^�^�%;�%;�D�4�=�=�<P�QrN)rBrCrDr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r&rrrxrx�s]���F�$�
�>�4�?�=�"�
P�F�4�O�K�7�.�Rrrxc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�
ProxyTestsc���|jtj��|_t	t
j�D]0}d|j�vs�|jj|��2y)N�proxy)	�enterContextr�EnvironmentVarGuard�env�listr��environ�lower�unset)r-�ks  rr�zProxyTests.setUp�sN���$�$�Y�%B�%B�%D�E����b�j�j�!�A��!�'�'�)�#������q�!�"rc���|jjdd�tjj	�}|jd|d�|jjdd�|j
tjjd��|j
tjjd��|j
tjjd��y)N�NO_PROXY�	localhost�no�0localhost, anotherdomain.com, newdomain.com:1234�anotherdomain.com�anotherdomain.com:8888�newdomain.com:1234)r��setrr�getproxies_environmentr�r��proxy_bypass_environment�r-rs  r�+test_getproxies_environment_keep_no_proxiesz6ProxyTests.test_getproxies_environment_keep_no_proxies�s��������Z��-��.�.�7�7�9������g�d�m�4������Z�!S�T�������?�?�@S�T�U�������?�?�@X�Y�Z�������?�?�@T�U�Vrc��	|jjdd�tjj	�}|jd|d�|jjdd�tjj	�}|j
d|�|jjd�|jjd�y#|jjd�|jjd�wxYw)N�
HTTP_PROXY�http://somewhere:3128rQ�REQUEST_METHOD�GET)r�r�rrr�r��assertNotInr�r�s  r�test_proxy_cgi_ignorez ProxyTests.test_proxy_cgi_ignores���		)��H�H�L�L��'>�?��n�n�;�;�=�G����4�g�f�o�F��H�H�L�L�)�5�1��n�n�;�;�=�G����V�W�-��H�H�N�N�+�,��H�H�N�N�<�(��
�H�H�N�N�+�,��H�H�N�N�<�(�s�BC�8Dc���tjj}|jj	dd�|j|d��|j|d��|j|d��|j|d��|j|d��|j|d��|j|d	��|j|d
��|j|d��|j|d��|j|d
��|j
|d��|j
|d��|j
|d��y)Nr�z8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tr��	LocalHost�	LOCALHOSTz
.localhostr�z.newdomain.com:1234z	foo.d.o.tzd.o.tr�z.anotherdomain.com:8888zwww.newdomain.com:1234�prelocalhost�
newdomain.comznewdomain.com:1235�rrr�r�r�r��assertFalse�r-�bypasss  r�(test_proxy_bypass_environment_host_matchz3ProxyTests.test_proxy_bypass_environment_host_match
s �����8�8�������Z�O�	Q�����{�+�,�����{�+�,�����{�+�,�����|�,�-�����3�4�5�����4�5�6�����{�+�,�����w��(�����7�8�9�����8�9�:�����7�8�9������/�0������0�1����� 4�5�6rc��tjj}|jj	dd�|j|d��|j|d��|jj	dd�|j|d��|j
|d��|j
|d��y)Nr��*r�r�z*, anotherdomain.comr�r�r�s  r�*test_proxy_bypass_environment_always_matchz5ProxyTests.test_proxy_bypass_environment_always_match s������8�8�������Z��%������/�0�����3�4�5������Z�!7�8�����2�3�4������0�1����� 4�5�6rc��tjj}|jj	dd�|j|d��|j|d��|j|d��y)Nr�r�z
localhost
zanotherdomain.com:8888
znewdomain.com:1234
)rrr�r�r�r�r�s  r�%test_proxy_bypass_environment_newlinez0ProxyTests.test_proxy_bypass_environment_newline*sb�����8�8�������Z�G�	I�����
�.�/����� :�;�<����� 6�7�8rN)	rBrCrDr�r�r�r�r�r�r&rrr�r��s!��"�	W�
)�7�&7�9rr�c��eZdZd�Zd�Zd�Zy)�ProxyTests_withOrderedEnvc�h�tj|_tj�t_yr+)r�r��
_saved_env�collections�OrderedDictrAs rr�zProxyTests_withOrderedEnv.setUp5s���*�*��� �,�,�.��
rc�.�|jt_yr+)r�r�r�rAs rr�z"ProxyTests_withOrderedEnv.tearDown;s
���_�_��
rc�~�dtjd<dtjd<|jtjjd��|jtjjd��dtjd<dtjd<tjj
�}|ji|�d	tjd<d
tjd<|jtjjd��|jtjjd��|jtjjd��|jtjjd
��|jtjjd��dtjd<dtjd<tjj
�}|jd|d�y)N��no_proxyr��No_Proxy�	arbitrary�
http_proxyr�r�z%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z
my.proxy:1234zmy.proxyzhttp://somewhereelse:3128�
Http_ProxyrQ)	r�r�r�rrr�r�r�r�r�s  r�,test_getproxies_environment_prefer_lowercasezFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercase>s���!#��
�
�:��!,��
�
�:��������@�@��M�N�������@�@��M�N�#%��
�
�<� �#:��
�
�<� ��.�.�7�7�9������W�%�!H��
�
�:��!*��
�
�:��������?�?��L�M�������?�?�@R�S�T�������?�?��P�Q�������@�@��L�M�������@�@��M�N�#:��
�
�<� �#>��
�
�<� ��.�.�7�7�9�����0�'�&�/�BrN)rBrCrDr�r�r�r&rrr�r�3s��/�%�Crr�c��eZdZ	d�Zd�Zd�Zejed�d��Z	ejed�d��Z
ejed�d��Zejed�d��Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zej2ej6dd�d��Zd�Zd�Zd�Zejed�d��Z y)�urlopen_HttpTestsc��|jd|zdz�	td�}|j|j�d�|j|j�d�|j|j	�d�|j|j�d�|j
�y#|j
�wxYw)NsHTTP/s 200 OK

Hello!�http://python.org/�Hello!r���rTr"r�r=r�r�r\)r-�ver�fps   r�
check_readzurlopen_HttpTests.check_readZs����
�
�h��n�'?�?�@�	��-�.�B����R�[�[�]�I�6����R�[�[�]�C�0����R�Y�Y�[�*>�?����R�Z�Z�\�3�/��O�O���D�O�O��s�BB5�5Cc���d}|jd�	tjj|�}|j	|j�|�|j
�y#|j
�wxYw)Nz-http://docs.python.org/library/urllib.html#OK�HTTP/1.1 200 OK

Hello!)rTrrr"r�r�r\)r-rrs   r�test_url_fragmentz#urlopen_HttpTests.test_url_fragmentesX��=���
�
�6�7�	����'�'��,�B����R�Y�Y�[�#�.��O�O���D�O�O��s�?A%�%A7c���|jd�	td�}|j|jj�|j�y#|j�wxYw)Nr�http://www.python.org)rTr"r�r�
will_closer\)r-�resps  r�test_willclosez urlopen_HttpTests.test_willcloseosJ���
�
�6�7�	��2�3�D��O�O�D�G�G�.�.�/��O�O���D�O�O��s�0A�A&zssl module requiredc���ttdd��dgzD�]}t|�}d|�d�}|jd�	t	|�jdd�}tjj}|j|d	|���5tjjd
|���ddd�|j|d	|���5tjjd|���ddd�td
|���}|j||j��|j���y#1swY��xYw#1swY�WxYw#|j�wxYw)Nr�!�z//localhost:7777/test�/�HTTP/1.1 200 OK

Hello.�\�\\�contain control.*�http:�https:)r��range�chrrT�repr�replacerQrR�
InvalidURL�assertRaisesRegexrrr"r�r�r\)r-�char_nor�schemeless_url�escaped_char_reprr rs       r�(test_url_path_with_control_char_rejectedz:urlopen_HttpTests.test_url_path_with_control_char_rejectedwsH���E�!�T�N�+�t�f�4�G��w�<�D�4�T�F�!�<�N��M�M�:�;�
"�%)��J�$6�$6�t�U�$C�!�!�[�[�3�3�
��+�+��"3�4E�3F� G�I��N�N�*�*�U�>�2B�+C�D�I��+�+��"3�4E�3F� G�I��N�N�*�*�V�N�3C�+D�E�I���~�&6�7�8��� � ��t�{�{�}�5����!�/5�I�I��I�I�����!�s=�A
E�#D8�.E�#E�.6E�8E	�=E�E
	�	E�E"c��|jd�d}d|zdz}	tjj}|j	|d�5t
jjd|���ddd�|j	|d�5t
jjd|���ddd�td|���}|jd	|j��|jd
|j��|jd|j��|j�y#1swY��xYw#1swY��xYw#|j�wxYw)Nrz:localhost:7777?a=1 HTTP/1.1
X-injected: header
TEST: 123�//�:8080/test/?test=az*contain control.*\\r.*(found at least . .)r�contain control.*\\nr� �
�
)rTrQrRr r!rrr"r�r�r\)r-rfr#r rs     r�4test_url_path_with_newline_header_injection_rejectedzFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejected�s%���
�
�6�7�O�����';�;��	����/�/�J��'�'��I�K����&�&��~�.>�'?�@�K��'�'�
�4K�L����&�&���/?�'@�A�M��U�>�"2�3�4�D����S�$�+�+�-�0����T�4�;�;�=�1����T�4�;�;�=�1��O�O��K�K��M�L��
�O�O��s<�,E�	#D0�,E�#D<�)A6E�0D9�5E�<E�E�Ec��ttdd��dgzD]�}t|�}d|�d�}|jd�	t	|�jdd�}tjj}|j|d	|���5td
|���ddd�|j|d	|���5td|���ddd�|j���y#1swY�HxYw#1swY�(xYw#|j�wxYw)Nrrrz//localhostz/test/rrrrrr)r�rrrTrrrQrRr r!r"r\)r-r"rr#r$r s      r�(test_url_host_with_control_char_rejectedz:urlopen_HttpTests.test_url_host_with_control_char_rejected�s���E�!�T�N�+�t�f�4�G��w�<�D�*�4�&��7�N��M�M�:�;�	
"�$(��J�$6�$6�t�U�$C�!�!�[�[�3�3�
��+�+��"3�4E�3F� G�I��e�N�#3�4�5�I��+�+�J�:K�L]�K^�8_�`��f�^�$4�5�6�a����!�5�I�I��a�`�����!�s=�A
C8�
C �C8�6C,�C8� C)	�%C8�,C5	�1C8�8D
c��|jd�d}d|zdz}	tjj}|j	|d�5td|���ddd�|j	|d�5td|���ddd�|j
�y#1swY�CxYw#1swY�&xYw#|j
�wxYw)	Nrzlocalhost
X-injected: header
r'r(zcontain control.*\\rrr)r)rTrQrRr r!r"r\)r-rfr#r s    r�4test_url_host_with_newline_header_injection_rejectedzFurlopen_HttpTests.test_url_host_with_newline_header_injection_rejected�s����
�
�6�7�4�����';�;��	����/�/�J��'�'��3�5��%��/�0�1�5��'�'�
�4K�L��&�� 0�1�2�M�
�O�O��
5�5��M�L��
�O�O��s;�,B2�	B�B2�2B&�B2�B#�B2�&B/�+B2�2Cc�&�|jd�y)Ns0.9�r	rAs r�
test_read_0_9zurlopen_HttpTests.test_read_0_9�s��	
����rc�&�|jd�y)Ns1.0r3rAs r�
test_read_1_0zurlopen_HttpTests.test_read_1_0��������rc�&�|jd�y)Ns1.1r3rAs r�
test_read_1_1zurlopen_HttpTests.test_read_1_1�r7rc��|jdd��	|jttd�|j	�y#|j	�wxYw)Ns�HTTP/1.1 401 Authentication Required
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Type: text/html; charset=iso-8859-1
TrXr�rTr��OSErrorr"r\rAs r�test_read_bogusz!urlopen_HttpTests.test_read_bogus�sJ���
�
��
�	�	�	����g�w�0D�E��O�O���D�O�O��s�A�Ac��|jdd��	d}|jtjj|�5td�ddd�|j
�y#1swY�xYw#|j
�wxYw)Ns�HTTP/1.1 302 Found
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Location: file://guidocomputer.athome.com:/python/license
Connection: close
Content-Type: text/html; charset=iso-8859-1
TrXzRedirection to url 'file:r)rTr!r�error�	HTTPErrorr"r\)r-�msgs  r�test_invalid_redirectz'urlopen_HttpTests.test_invalid_redirect�ss���
�
���
	�	�	�-�C��'�'����(>�(>��D��,�-�E�
�O�O��E�D��
�O�O��s#�,A2�A&�
A2�&A/�+A2�2Bc��tt�j�D]U}|jdd��	|j	t
jjtd�|j��Wy#|j�wxYw)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
TrX�http://something)
rr�maxtriesrTr�rr?r@r"r\)r-�is  r�test_redirect_limit_independentz1urlopen_HttpTests.test_redirect_limit_independent�su���~�'�0�0�1�A��M�M���
�
�
"��!�!�&�,�,�"8�"8�'�&�(����!�2�����!�s�/A7�7B	c��|jd�	|jttd�|j	�y#|j	�wxYw)NrrDr;rAs r�test_empty_socketz#urlopen_HttpTests.test_empty_sockets=��	
�
�
�c��	����g�w�0B�C��O�O���D�O�O��s	�?�Ac�*�|jtjj�5}t	d�ddd�|jjj�|j|jj�y#1swY�TxYw)Nz/file://localhost/a/file/which/doesnot/exists.py)	r�rr?�URLErrorr"r��	exception�filename�reason�r-�es  r�test_missing_localfilez(urlopen_HttpTests.test_missing_localfiles_��
�
�
�v�|�|�4�4�
5���E�F�6�������,�,�-�������*�*�+�6�
5���B	�	Bc���tj�\}}d|jtjj
d�z}	|j
tjj|��t|�5}|j
|�ddd�tj|�tj|�|jtjj|��|jtjj�5t|�ddd�y#1swY��xYw#tj|�tj|�wxYw#1swYyxYw)Nzfile://localhost/r)�tempfile�mkstemprr��path�sepr��existsr"r@�unlinkr�r�rr?rK)r-�fd�tmp_file�tmp_fileurl�fobjs     r�test_file_notexistsz%urlopen_HttpTests.test_file_notexistss����'�'�)���H�)�H�,<�,<�R�W�W�[�[�#�,N�N��	 ��O�O�B�G�G�N�N�8�4�5���%������%�&�
�H�H�R�L��I�I�h�����������1�2�
�
�
�v�|�|�4�4�
5��K� �6�
5�
&�%��
�H�H�R�L��I�I�h���
5�
5�s0�9D;�?D/�D;�E*�/D8�4D;�;,E'�*E3c�.�d}|jtjj�5}t	|�ddd�|jjj�|j|jj�y#1swY�TxYw)Nzftp:///path�
r�rr?rKr"r�rLrMr�rN)r-�test_ftp_urlrPs   r�test_ftp_nohostz!urlopen_HttpTests.test_ftp_nohost se��$��
�
�
�v�|�|�4�4�
5���L�!�6�������-�-�.�������*�*�+�6�
5�s�B�Bc�*�|jtjj�5}t	d�ddd�|jjj�|j|jj�y#1swY�TxYw)Nz.ftp://localhost/a/file/which/doesnot/exists.pyr`rOs  r�test_ftp_nonexistingz&urlopen_HttpTests.test_ftp_nonexisting'sa��
�
�
�v�|�|�4�4�
5���D�E�6�������-�-�.�������*�*�+�6�
5�rR�MAXFTPCACHErc��|j�	tjjddddg�tjjd<td�|j
�y#|j
�wxYw)Nrd�passr���testzftp://localhost)rtrrrr�ftpcacher"rvrAs r�test_ftp_cache_pruningz(urlopen_HttpTests.test_ftp_cache_pruning-s]������	�.4�n�n�.G�.G��PV�Xc�eg�ik�.l�F�N�N�#�#�F�+��%�&��N�N���D�N�N��s�A	A,�,A>c��|jd�	td�}|j|j�d�|j|j�d�|j|j	�d�|j|j�d�|j
�y#|j
�wxYw)N�HTTP/1.0 200 OK

Hello!zhttp://user:pass@python.org/rrrr)r-rs  r�test_userpass_inurlz%urlopen_HttpTests.test_userpass_inurl6s����
�
�6�7�	��7�8�B����R�[�[�]�I�6����R�[�[�]�C�0����R�Y�Y�[�*H�I����R�Z�Z�\�3�/��O�O���D�O�O��s�BB/�/Cc��|jd�	d}dj|�}tjj}dt|j
d��jd�z}t|�}|j||jjd��|j|j�d�|j|j�d�|j|j�|�|j|j�d	�|j!�y#|j!�wxYw)
Nrmza b:c dzhttp://{}@python.org/zAuthorization: Basic %s
�ASCIIzUTF-8rrr)rT�formatrQrRrSr
�encode�decoder"�assertInr,r�r=�assertNotEqualr�r�r\)r-�userpassr�fakehttp_wrapper�
authorizationrs      r�test_userpass_inurl_w_spacesz.urlopen_HttpTests.test_userpass_inurl_w_spacesAs����
�
�6�7�	� �H�)�0�0��:�C�#�{�{�9�9��:�&�x���w�'?�@�G�G��P�Q�M����B��M�M�-�)9�)=�)=�)D�)D�W�)M�N����R�[�[�]�I�6����R�[�[�]�C�0�����	�	��S�1����R�Z�Z�\�3�/��O�O���D�O�O��s�DD3�3Ec��tjdtf�5tjj�ddd�y#1swYyxYw�Nr�)rr$r%rr�	URLopenerrAs r�test_URLopener_deprecationz,urlopen_HttpTests.test_URLopener_deprecationTs3��
�
+�
+�R�0B�,C�
D��N�N�$�$�&�E�
D�
D�s�A�A
c�$�tj�}tjdtf�5|jt�5tjjdd|��ddd�ddd�y#1swY�xYw#1swYyxYw)Nr�zhttps://localhostz/nonexistent/path)�cafile�context)
�ssl�create_default_contextrr$r%r�r�rrr")r-r�s  r�test_cafile_and_contextz)urlopen_HttpTests.test_cafile_and_contextXsp���,�,�.��
�
+�
+�R�1C�,D�
E��"�"�:�.����&�&�'�0C�W�'��/�F�
E�.�.��F�
E�s#�B�#A:�)B�:B	�?B�BN)!rBrCrDr	rr�unittest�
skipUnlessr�r%r-r/r1r4r6r9r=rBrGrIrQr^rbrdrrqrrrkrnryr}r�r&rrrrWs5��8�	����X����3�4�"�5�"�4�X����3�4��5��2�X����3�4�"�5�"� �X����3�4��5�� �
 � ��� "��,�!�,�,��U�\�\�&�.�.�-��3��4��	��&'��X����3�4��5�rrc�D�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�urlopen_DataTestsc��|jtjj�d|_d|_d|_d|_d|_tjj|j�|_
tjj|j�|_tjj|j�|_y)Nutest data URLs :;,%=& ö Ä sU�PNG


IHDR{@��sRGB���IDAT�c```���?�
o/IEND�B`�zZdata:text/plain;charset=UTF-8,test%20data%20URLs%20%3A%3B%2C%25%3D%26%20%C3%B6%20%C3%84%20zPdata:text/plain;charset=ISO-8859-1;base64,dGVzdCBkYXRhIFVSTHMgOjssJT0mIPYgxCA%3Dz�data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7
QOjdAAAAAXNSR0IArs4c6QAAAA9JREFUCNdj%0AYGBg%2BP//PwAGAQL%2BCm8 vHgAAAABJRU5ErkJggg%3D%3D%0A%20)
�
addCleanuprr�
urlcleanupr�image�text_url�text_url_base64�	image_urlr"�
text_url_resp�text_url_base64_resp�image_url_resprAs rr�zurlopen_DataTests.setUpes���������1�1�2�;��	�
F�	
�
�
(�	
�
�
�	
��
.�	
��
$�^�^�3�3�D�M�M�B���$*�N�N�$:�$:�� � �%"��!�$�n�n�4�4�T�^�^�D��rc�d�dD]+}|jt|j|�d|z��-y)N)r:r=r�r@r�r�r�r�r�)r�r�r�r�s  rr�z urlopen_DataTests.test_interface�s6��G�D��O�O�G�D�$6�$6��=�J���
�Grc�(�|j|jj�tjj
�|j
|jj�j�ddg�|j
|jj�dtt|j���|j
tjjd�j�j�ddg�y)N)z
text/plainr�)�charsetz
ISO-8859-1zcontent-lengthzdata:,)r�zUS-ASCII)r�r�r�r�r�r�r�r��
get_paramsr��strrr�rrr"rAs rr�zurlopen_DataTests.test_info�s������d�0�0�5�5�7����9N�9N�O�����2�2�7�7�9�D�D�F�
�!:�;�	=�����,�,�1�1�3�4D�E���D�J�J�� �	"�������/�/��9�>�>�@�K�K�M�
�!8�9�	;rc�<�|j|jj�|j�|j|jj�|j
�|j|jj�|j�yr+)r�r�r�r�r�r�r�r�rAs rr�zurlopen_DataTests.test_geturl�sp������+�+�2�2�4�d�m�m�D�����2�2�9�9�;�� � �	"�����,�,�3�3�5�t�~�~�Frc���|j|jj�jt	|jj�j
��d�|j�y�Nr�)r�r�r:rs�dictr�r�rrAs r�test_read_textz urlopen_DataTests.test_read_text�sZ������+�+�0�0�2�9�9���#�#�(�(�*�5�5�7�8��C�E�FJ�i�i�	Qrc���|j|jj�jt	|jj�j
��d�|j�yr�)r�r�r:rsr�r�r�rrAs r�test_read_text_base64z'urlopen_DataTests.test_read_text_base64�sY������2�2�7�7�9�@�@���*�*�/�/�1�<�<�>�?�	�J�L��I�I�	rc�l�|j|jj�|j�yr+)r�r�r:r�rAs r�test_read_imagez!urlopen_DataTests.test_read_image�s%������,�,�1�1�3�T�Z�Z�@rc�b�|jttjjd�y)Nzdata:text/plain�r�r�rrr"rAs r�test_missing_commaz$urlopen_DataTests.test_missing_comma�s�����*�V�^�^�%;�%;�<M�Nrc�b�|jttjjd�y)Nzdata:;base64,Cg=r�rAs r�test_invalid_base64_dataz*urlopen_DataTests.test_invalid_base64_data�s�����*�V�^�^�%;�%;�<N�OrN)rBrCrDr�r�r�r�r�r�r�r�r�r&rrr�r�bs8��,�E�>�;�G�Q��
A�O�Prr�c�R�eZdZ	d�Zd�Zd�Zd
d�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)�urlretrieve_FileTestsc��|jtjj�g|_|jtj�d|_	ttjd�}|j|j�|j�|j�y#YyxYw#j�w#YwxYwxYw)Nstesting urllib.urlretriever{)r�rrr��	tempFiles�registerFileForCleanUprr�rrr�r@)r-�FILEs  rr�zurlretrieve_FileTests.setUp�s���������1�1�2����	
�#�#�I�$4�$4�5�1��	�	��	�(�(�$�/�D��J�J�t�y�y�!��J�J�L�������D��������D�s1�AB5�B.�.B2�5C�6C�C�C�	Cc�^�|jD]}tj|��y#Y�xYwr+)r�r�r�)r-�eachs  rr�zurlretrieve_FileTests.tearDown�s"���N�N�D����4��#���D�s�(�,c���tjj|�}	|jd�dtjj|�zS#t$rtjd��wxYw)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
r�rV�abspathrr�UnicodeEncodeErrorr��SkipTestrrr	)r-�filePaths  r�constructLocalFileUrlz+urlretrieve_FileTests.constructLocalFileUrl�sg���7�7�?�?�8�,��	I��O�O�G�$��V�^�^�8�8��B�B�B��"�	I��#�#�$G�H�H�	I�s�A�A3c�0�	tj�\}}	|j|�tj|d�}|j|�|j
�|j
�|S#Y|SxYw#j
�w#YwxYwxYw)Nr{)rTrUr�r��fdopenr�r@)r-r �newFd�newFilePath�newFiles     r�createNewTempFilez'urlretrieve_FileTests.createNewTempFile�s���	2�&�-�-�/���{�	��'�'��4��i�i��t�,�G��M�M�$���M�M�O��������
�D����������D�s0�AA<�"A4�4A9�<B�=B�
B�B�Bc�:�|jj|�yr+)r��append)r-�fileNames  rr�z,urlretrieve_FileTests.registerFileForCleanUp�s�������h�'rc��tjjdtjz�}|j|dtj�|j
|dtjjd�y)Nr|rr
zFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverr�r�r�r�r�r�)r-�results  r�
test_basicz urlretrieve_FileTests.test_basic�sb�����+�+�I�	�8H�8H�,H�I��������I�$4�$4�5����f�Q�i����)>�)>�9�	:rc�F�dtjz}|j|�tjj|j
tj�|�}|j||d�|jtjj|�d�t|d�}	|j�}|j�|j�|j|j|�y#Y�!xYw#|j�w#YwxYwxYw)N�%s.2rzcopy of the file was not made�rb)rr�r�rrr�r�r�r�r�rVrXrr:r@r)r-�second_tempr�r�rs     r�	test_copyzurlretrieve_FileTests.test_copy�s����y�/�/�/���#�#�K�0����+�+�D�,F�,F����-�*�,������f�Q�i�0���������{�3�69�	:��K��&��	��9�9�;�D��J�J�L�����������D�)��
�D��������D�s0�3 D�D�D�D �D�D �D�D c����dgf�fd�	}dtjz}�j|�tjj�j
tj�||�y)Nrc�����j|t��j|t��j|t��j||d�|ddz|d<y)Nrr
)r�r�r�)�block_count�block_read_size�	file_size�count_holderr-s    �r�
hooktesterz9urlretrieve_FileTests.test_reporthook.<locals>.hooktestersY����!�!�+�s�3��!�!�/�3�7��!�!�)�S�1����[�,�q�/�:�*�1�o��1�L��Orr�)rr�r�rrr�r�)r-r�r�s`  r�test_reporthookz%urlretrieve_FileTests.test_reporthooksX���NO�S�	2��y�/�/�/���#�#�K�0����"�"��&�&�y�'7�'7�8���	%rc��g}|fd�}|j�}tjj|j	|�t
j|�|jt|�d�|j|ddd�y)Nc�,�|j|||f�yr+�r��r�r�r��_reports    rr�zAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktester����N�N�K��)�D�Err
rr�	r�rrr�r�rr�r�r�r-�reportr��srcFileNames    r�test_reporthook_0_bytesz-urlretrieve_FileTests.test_reporthook_0_bytesst����HN�	F��,�,�.�����"�"�4�#=�#=�k�#J����j�	*�����V��a�(�������1��q�)rc�F�g}|fd�}|jd�}tjj|j	|�t
j|�|jt|�d�|j|ddd�|j|ddd�y)Nc�,�|j|||f�yr+r�r�s    rr�zAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktester$r�rsxxxxxrr�r
r�r�s    r�test_reporthook_5_bytesz-urlretrieve_FileTests.test_reporthook_5_bytess�����HN�	F��,�,�X�6�����"�"�4�#=�#=�k�#J����j�	*�����V��a�(�������1��q�)�������1��q�)rc��g}|fd�}|jddz�}tjj|j	|�t
j|�|jt|�d�|j|ddd�|j|ddd�|j|ddd�|j|ddd�y)	Nc�,�|j|||f�yr+r�r�s    rr�zDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktester2r�r�xi �rrr
i r�r�s    r�test_reporthook_8193_bytesz0urlretrieve_FileTests.test_reporthook_8193_bytes-s�����HN�	F��,�,�T�D�[�9�����"�"�4�#=�#=�k�#J����j�	*�����V��a�(�������1��t�,�������1��t�,�������1��t�,�������1��t�,rN)r)rBrCrDr�r�r�r�r�r�r�r�r�r�r�r&rrr�r��s=��2��0�C�� (�:�*�$%�	*�*�-rr�c��eZdZ	d�Zd�Zy)�urlretrieve_HttpTestsc��|jtjj�|j	d�d�}|jtjj�5	tjjtj|��|j�	ddd�y#|j�wxYw#1swYyxYw)N��HTTP/1.1 200 OK
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Length: 100
Content-Type: text/html; charset=iso-8859-1

FF
c��yr+r&)�par1�par2�par3s   r�_reporthookzYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthookNs��r)�
reporthook�r�rrr�rTr�r?�ContentTooShortErrorr�r�
TEST_HTTP_URLr\)r-r�s  r�.test_short_content_raises_ContentTooShortErrorzDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorAs���������1�1�2��
�
��	�	��
�
�v�|�|�@�@�
A�
"����*�*�7�+@�+@�6A�+�C����!�B�
A��
���!��B�
A�s$�'C�)/B2�C�2C�C�Cc��|jtjj�|j	d�|jtjj�5	tjjtj�|j�	ddd�y#|j�wxYw#1swYyxYw)Nr�r�rAs r�Atest_short_content_raises_ContentTooShortError_without_reporthookzWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookXs���������1�1�2��
�
��	��
�
�v�|�|�@�@�
A�
"����*�*�7�+@�+@�A����!�	B�
A�����!��	B�
A�s$�$C�&-B-�C�-B?�?C�CN)rBrCrDr�r�r&rrr�r�>s��?�"�."rr�c�D�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�QuotingTestsc�
�djgd��}tjj|�}|j	||d|�d|���tjj|�}|j	||d|�d|���y)Nr�)�ABCDEFGHIJKLMNOPQRSTUVWXYZ�abcdefghijklmnopqrstuvwxyz�
0123456789z_.-~�using quote(): � != �using quote_plus(): )�joinrr�r�r��
quote_plus)r-�do_not_quoter�s   r�test_never_quotezQuotingTests.test_never_quote�su���x�x�!)�*�����#�#�L�1������v�6B�F�K�	M����(�(��6������v�:F��O�	Qrc�r�|jtjjjdd�y)Nrr)r�rr�r��__defaults__rAs r�test_default_safezQuotingTests.test_default_safe�s'��������+�+�8�8��;�S�Arc���d}tjj||��}|j||d|�d|���tjj	||��}|j||d|�d|���tjj|d��}|j||d|�d|���tjjddd	�
�}tjjddd�
�}|j||d|�d|���tjjddd�
�}tjjddd�
�}|j||d|�d|���y)
Nz<>��safer�r�r�s<>uaüb�latin-1�ü)�encodingrr���)rr�r�r�r�)r-�quote_by_defaultr��expects    r�	test_safezQuotingTests.test_safe�s\�������#�#�$4�;K�#�L�����)�6�6F��O�	Q����(�(�)9�.>�)�@�����)�6�*�F�4�	5����#�#�$4�5�#�A�����)�6�6F��O�	Q����#�#�H�y�v�#�N�����#�#�H�y�r�#�J������� �&�*�	+����#�#�H�y�w�#�O�����#�#�H�y�r�#�J������� �&�*�	+rc���td�D�cgc]
}t|���}}|jd�|jtd��dj|�}|D]�}tj
j
|�}|jt|�|d|�dt|��d|���tj
j|�}|jt|�|d|�d	t|��d|�����~d
}d}tj
j
|�}|j||d|�d|���tj
j|�}|j||d|�d|���ycc}w)
N� z
<>#%"{}|\^[]`rr�r�z should be escaped to z, not r�z should be escapes to zab[]cdz
ab%5B%5Dcdr�)
rrr�r�rr�r�r�rr�)r-�num�should_quoterr��
partial_quote�expecteds       r�test_default_quotingz!QuotingTests.test_default_quoting�sE��-2�"�I�6�I�S��C��I��6����,�-����C��H�%��w�w�|�,�� �D��\�\�'�'��-�F����Y�t�_�f�#�I�d�O�V�=�
>��\�\�,�,�T�2�F����Y�t�_�f�#�I�d�O�V�=�
>�!�
� �
������#�#�M�2������6�6>��G�	I����(�(��7������6�;C�V�L�	N��-7s�E5c
�@�tjjd�}|j|t	d�d|�dt	d����tjjd�}|j|dd|z�d}|j
dt	d��}tjj|�}|j||d|�d|���|j
dd�}tjj|�}|j||d|�d|���y)Nr*r�r��+zusing quote_plus(): %r != +z
a b cd e fr�)rr�r�r�rr�r)r-r��givenr	s    r�test_quoting_spacezQuotingTests.test_quoting_space�s������#�#�C�(�������3��6<�i��n�M�	O����(�(��-�������6��?�	A������s�I�c�N�3�����#�#�E�*�������6<�f�E�	G����s�C�(�����(�(��/�������;A�6�J�	Lrc��|jtjjd�d�|jtjjdd�d�|jtjjd�d�|jtjjdd�d�y)Nzalpha+beta gammazalpha%2Bbeta+gammarzalpha+beta+gammasalpha+beta gamma�+)r�rr�r�rAs r�test_quoting_pluszQuotingTests.test_quoting_plus�s���������0�0�1C�D�-�	/�������0�0�1C�S�I�+�	-�	
������0�0�1D�E�-�	/�	
������0�0�1C�T�J�+�	-rc�N�d}d}tjj|�}|j||d|�d|���|j	t
tjj|d��tjj
|�}|j||d|�d|���y)N���ab��%A2%D8ab%FFr�r�r�rzusing quote_from_bytes(): )rr�r�r�r��	TypeError�quote_from_bytes�r-rr	r�s    r�test_quote_byteszQuotingTests.test_quote_bytes�s���!�������#�#�E�*�������6<�f�E�	G�	
���)�V�\�\�%7�%7��%.�	�	0����.�.�u�5�������"�F�,�	-rc�H�d}d}tjj|�}|j||d|�d|���tjj|dd��}|j||d|�d|���d}d}tjj|d��}|j||d|�d|���d	}d
}tjj|�}|j||d|�d|���d	}|j	t
tjj|d��d	}d}tjj|dd��}|j||d|�d|���d	}d
}tjj|dd��}|j||d|�d|���y)Nu¢Øabÿz%C2%A2%C3%98ab%C3%BFr�r��r�errorsrrr�漢字�%E6%BC%A2%E5%AD%97z%3F%3Frz%26%2328450%3B%26%2323383%3B�xmlcharrefreplace)rr�r�r�r�r�rs    r�test_quote_with_unicodez$QuotingTests.test_quote_with_unicode�s��� ��'�����#�#�E�*�������6<�f�E�	G����#�#�E�D��#�F�������6<�f�E�	G�!�������#�#�E�I�#�>�������6<�f�E�	G���%�����#�#�E�*�������6<�f�E�	G������,�f�l�l�.@�.@�%�-6�	�	8��������#�#�E�I�+4�$�6�������6<�f�E�	G���/�����#�#�E�I�+>�$�@�������6<�f�E�	Grc��d}d}tjj|d��}|j||d|�d|���d}d}tjj|dd	�
�}|j||d|�d|���y)Nu¢Ø ÿz
%A2%D8+%FFrrr�r�uab漢字 cdzab%3F%3F+cdrr")rr�r�r�rs    r�test_quote_plus_with_unicodez)QuotingTests.test_quote_plus_with_unicode(s����������(�(���(�C�������;A�6�J�	L�$�������(�(���09�)�;�������;A�6�J�	LrN)rBrCrDr�rr
rrrr r'r)r&rrr�r�ks;���2Q�B�+�:N�8L�&
-�-� (G�T
Lrr�c�D�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�UnquotingTestsc	��g}td�D]�}tt|��}t|�}tjj|�}|j
||d|�d|���tjj|�}|j
||d|�d|���|j|���dj|�}~tjj|�}|j
|jd�dd|z�y)	N��using unquote(): r��using unquote_plus(): r�rr
z/using unquote(): not all characters escaped: %s)rrrrr��unquoter��unquote_plusr�r��count)r-�escape_listr
rr	r��
escape_strings       r�test_unquotingzUnquotingTests.test_unquoting?s�������:�C��c�#�h�'�E���X�F��\�\�)�)�%�0�F����V�V�<B�F�K�
M��\�\�.�.�u�5�F����V�V�$�f�.�
/�
���u�%������,�
�����%�%�m�4��������c�*�A�� &�'�	(rc���|jttftjj
d�|jttftjj
d�y)Nr&)r�r�AttributeErrorrr�r0rAs r�#test_unquote_rejects_none_and_tuplez2UnquotingTests.test_unquote_rejects_none_and_tupleTsD�����9�n�5�v�|�|�7K�7K�T�R����9�n�5�v�|�|�7K�7K�R�Prc���d}|}tjj|�}|j||d|�d|���d}|}tjj|�}|j||d|�d|���d}|}tjj|�}|j||d|�d|���d}t	|d�}tjj|�}|j||d|�d|���d}t	|d�}tjj|�}|j||d|�d|���d}t	|d�}tjj|�}|j||d|�d|���|j
ttftjj
d�|j
ttftjj
d�y)	Nz%xabr.r�z%xrrz�using unquote_to_bytes(): r&)	rr�r0r�r}�unquote_to_bytesr�rr7rs    r�test_unquoting_badpercentz(UnquotingTests.test_unquoting_badpercentXs����������%�%�e�,�������"�F�*,�	-��������%�%�e�,�������"�F�*,�	-��������%�%�e�,�������"�F�*,�	-����u�g�&�����.�.�u�5�������"�F�*,�	-����u�g�&�����.�.�u�5�������"�F�*,�	-����u�g�&�����.�.�u�5�������"�F�*,�	-����9�n�5�v�|�|�7T�7T�VZ�[����9�n�5�v�|�|�7T�7T�VX�Yrc�|�d}d}tjj|�}|j||d|�d|���y)Nz%Ab%eAs��r:r��rr�r;r�rs    r�test_unquoting_mixed_casez(UnquotingTests.test_unquoting_mixed_case|s<���������.�.�u�5�������"�F�,�	-rc��dtd�z}d}tjj|�}|j	||d|�d|���tjj|�}|j	||d|�d|���y)Nzab%sd�c�abcdr�r�r/)rrr�r0r�r1rs    r�test_unquoting_partsz#UnquotingTests.test_unquoting_parts�su���)�C�.�(�������%�%�e�,�������6<�f�E�	G����*�*�5�1�������=C�V�L�	Nrc��d}|}tjj|�}|j||d|�d|���|j	dd�}tjj|�}|j||d|�d|���y)Nzare+there+spaces...r.r�rr*r/)rr�r0r�rr1rs    r�test_unquoting_plusz"UnquotingTests.test_unquoting_plus�sz��%�������%�%�e�,�������8>��G�	I����s�C�(�����*�*�5�1�������=C�V�L�	Nrc���d}d}tjj|�}|j||d|�d|���tjjd�}d}|j||d|�d|���d}d}tjj|�}|j||d|�d|���d	}d}tjj|�}|j||d|�d|���y)
N�"br%C3%BCckner_sapporo_20050930.docsbrückner_sapporo_20050930.docr:r��	漢%C3%BCs漢üs%A2%D8ab%FFrs	%A2�ab%FFr>rs    r�test_unquote_to_bytesz$UnquotingTests.test_unquote_to_bytes�s���4��8�����.�.�u�5�������"�F�,�	-����.�.�~�>��(�������"�F�,�	-���"�����.�.�u�5�������"�F�,�	-�
 ��"�����.�.�u�5�������"�F�,�	-rc�6�d}d}tjj|�}|j||d|�d|���tjj|dd��}|j||d|�d|���tjjdd��}d}|j||d|�d|���d	}d
}tjj|�}|j||d|�d|���d}d}tjj|�}|j||d|�d|���tjj|d
��}|j||d|�d|���d}d}tjj|d��}|j||d|�d|���tjjd�}d}|j||d|�d|���tjjdd��}d}|j||d|�d|���y)NrGubrückner_sapporo_20050930.docr.r�r"zbr%FCckner_sapporo_20050930.docrrr%r$z%F3%B1u�r)r#r��ignorerHu漢üu漢%FC�rr�r0r�rs    r�test_unquote_with_unicodez(UnquotingTests.test_unquote_with_unicode�s��4��5�����%�%�e�,�������8>��G�	I����%�%�e�d�4�%�H�������8>��G�	I����%�%�&G�/8�&�:��5�������8>��G�	I�%�������%�%�e�,�������8>��G�	I��������%�%�e�,�������8>��G�	I����%�%�e�I�%�>�������8>��G�	I��������%�%�e�H�%�=�������8>��G�	I����%�%�n�5���������8>��G�	I�
���%�%�k�I�%�F���������8>��G�	Irc�l�d}d}tjj|�}|j||d|�d|���d}d}tjj|�}|j||d|�d|���d}d}tjj|�}|j||d|�d|���y)	Nsblueberryjam�blueberryjamr.r�sblåbærsyltetøyublåbærsyltetøysbl%c3%a5b%c3%a6rsyltet%c3%b8jublåbærsyltetøjrLrs    r�test_unquoting_with_bytes_inputz.UnquotingTests.test_unquoting_with_bytes_input�s����������%�%�e�,�������8>��G�	I�7��0�����%�%�e�,�������8>��G�	I�1��0�����%�%�e�,�������8>��G�	IrN)rBrCrDr5r8r<r?rCrErIrMrPr&rrr+r+8s<���(�*Q�"Z�H-�
N�
N�-�>8I�tIrr+c�V�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�urlencode_Testsc��	gd�}tjj|�}|D]}|j||d|�d|�d|���� |j	|jd�dd|�d|jd����|j
d�}||dz
}||dz}|j|j�xr|j�d|�d	|���|j	t|�d
d|�dt|��dd
���y)
N)z1st=1z2nd=2z3rd=3ztesting z: z not found in �&rz: expected 2 '&'s; got r
z%: '&' not located in proper place in �z#: unexpected number of characters: r�)
rr��	urlencodertr�r2�indexr��isdigitr)	r-r�	test_type�expect_somewherer�r�amp_location�on_amp_left�on_amp_rights	         r�help_inputtypezurlencode_Tests.help_inputtypes��
	�7�����'�'��.��(�H��M�M�(�F�#�X�v�7�
8�)�	
������c�*�A�#�V�\�\�#�%6�8�	9��|�|�C�(���\�A�-�.���l�Q�.�/������+�+�-�H�,�2F�2F�2H����)�	*�	
����V��k�$�S��[�+�?�	@rc�0�|jdddd�d�y)N�1�2�3)�1st�2nd�3rdzusing dict as input type�r^rAs r�test_using_mappingz"urlencode_Tests.test_using_mapping0s�����3�c��=�6�	8rc�,�|jgd�d�y)N))rcr`)rdra)rerbz*using sequence of two-item tuples as inputrfrAs r�test_using_sequencez#urlencode_Tests.test_using_sequence5s�����F�H�	Jrc��ddi}td��dtd���}tjj|�}|j	||�ddi}d}tjj|�}|j	||�y)NrT�=zkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrr�rVr�rs    r�test_quotingzurlencode_Tests.test_quoting:su���S�	��%�c�N�I�c�N�;�����'�'��.�������(��/�0��-�����'�'��.�������(rc��dgd�i}dtjjtgd���z}tjj	|�}|j||�tjj	|d�}|dD]}d|z}|j
||��|j|jd�dd|jd�z�y)N�sequence)r`rarbzsequence=%sTrTrzExpected 2 '&'s, got %s)rr�r�r�rVr�rtr2)r-rr	r��values     r�
test_doseqzurlencode_Tests.test_doseqEs����O�,������!8�!8��_�9M�!N�N�����'�'��.�������(����'�'��t�4���:�&�E�"�U�*�F��M�M�&�&�)�'�	
������c�*�A�2�V�\�\�#�5F�F�	Hrc��|jdtjji��|jdtjjg��yr{�r�rr�rVrAs r�test_empty_sequencez#urlencode_Tests.test_empty_sequenceRs@������V�\�\�3�3�B�7�8�����V�\�\�3�3�B�7�8rc���|jdtjjddi��|jdtjjddi��y)Nza=1�ar
za=NonerrrAs r�test_nonstring_valuesz%urlencode_Tests.test_nonstring_valuesVsH��������� 6� 6��Q�x� @�A�����6�<�<�#9�#9�3��+�#F�Grc�f�|jdtjjdddgid��|jdtjjdddgid��t	j
ddg�}|jd	tjjd|id��y)
Nza=1&a=2rur
rTz
a=None&a=a)rur
)�br
za=a&a=b)r�rr�rVr�r�)r-r s  r�test_nonstring_seq_valuesz)urlencode_Tests.test_nonstring_seq_valuesZs�������F�L�L�$:�$:�C�!�Q��=�$�$O�P��������/�/��t�S�k�0B�D�I�	K��&�&��(�';�<���������/�/��d��T�B�	Drc�L�d}d}tjj|dd��}|j||�d}d}tjj|�}|j||�d}d}tjj|d�	�}|j||�y)
N�)� �Á�%3F=%3Frprr"�
%C2%A0=%C3%81�%A0=%C1rr�rr�rVr�rs    r�test_urlencode_encodingz'urlencode_Tests.test_urlencode_encodingbs���'�������'�'���	�'�R�������(�(�� �����'�'��.�������(�(�������'�'��	�'�B�������(rc��d}d}tjj|ddd��}|j||�d}d}tjj|ddd�	�}|j||�d}d
}tjj|d�}|j||�d}d}tjj|d�}|j||�d}d
}tjj|dd��}|j||�d}d}tjj|dd��}|j||�y)Nr{r~Trpr)�doseqrr#))r|)r
r}z
%3F=1&%3F=%3Fr"r))r|)�*r}z%C2%A0=42&%C2%A0=%C3%81r�rrz%A0=42&%A0=%C1r�rs    r�test_urlencode_encoding_doseqz-urlencode_Tests.test_urlencode_encoding_dosequsL��'�������'�'��T�18��(�L�������(�-�� �����'�'��t�18��(�L�������(�(�� �����'�'��t�4�������(�-��*�����'�'��t�4�������(�(�������'�'��t�i�'�H�������(�-��!�����'�'��t�i�'�H�������(rc�>�d}d}tjj|�}|j||�tjj|d�}|j||�d}d}tjj|d�}|j||�y)N�)��$��$z
%A0%24=%C1%24T))r�)r�r�z%A0%24=42&%A0%24=%C1%24r�rs    r�test_urlencode_bytesz$urlencode_Tests.test_urlencode_bytes�s���-�� �����'�'��.�������(����'�'��t�4�������(�4��*�����'�'��t�4�������(rc��d}tjj|d��}d}|j||�d}tjj|dd��}d}|j||�d}d}tjj|dd��}|j||�d}tjj|dd	�
�}d}|j||�d}d}tjj|ddd	��}d}d}tjj|ddd	�
�}|j||�y)Nr�z:$rz	%A0$=%C1$T)r�r))r�)r��
r�z%A0$=%C1$&%A0$=13&%A0$=42r)rr)r�rrr�)r-rr�r	s    r�&test_urlencode_encoding_safe_parameterz6urlencode_Tests.test_urlencode_encoding_safe_parameter�sI��
.�����'�'��D�'�9���������(�-�����'�'��T��'�E���������(�9��,�����'�'��t�$�'�?�������(�.�����'�'��D�1:�(�<���������(�-�������'�'��T��1:�(�<��9��,�����'�'��t�$�1:�(�<�������(rN)rBrCrDr^rgrirlrprsrvryr�r�r�r�r&rrrRrR
sH���@�@8�
J�
	)�H�9�H�D�)�&#)�J)�&)rrRc��eZdZ	d�Zd�Zejejdk(d�d��Z	ejejdk(d�d��Z
y)	�Pathname_Testsc�,�tjjdddd�}d}tjj|�}|j
||d|�d|���tjj|�}|j
||d|�d|���y)	N�parts�ofrurVzparts/of/a/path�pathname2url() failed; r�zurl2pathame() failed; )r�rVr�rrr	r�r)r-�
expected_path�expected_urlr�s    rr�zPathname_Tests.test_basic�s��������W�d�C��@�
�(�����,�,�]�;������v� �,�0�	1����,�,�\�:������� �-�1�	2rc��tjjddd�}dtjjd�z}tjj|�}|j||d|�d|���|}tjj|�}|j||d|�d|���tjjdd	�}d
tjjd�z}tjj|�}|j||d|�d|���d}tjjdd
�}tjj|�}|j||d|�d|���y)N�needszquot=ing�herez
needs/%s/herer�r�zurl2pathname() failed; z	make sure�using_quotez%s/using_quotezmake+sure/using_unquotez	make+sure�
using_unquote)
r�rVr�rr�r�rr	r�rrs    rrlzPathname_Tests.test_quoting�sD�������W�j�&�9�� �6�<�<�#5�#5�j�#A�A�����,�,�U�3������� �&�*�	+������,�,�V�4������� �&�*�	+������[�-�8��!�F�L�L�$6�$6�{�$C�C�����,�,�U�3������� �&�*�	+�*�������k�?�;�����,�,�U�3������� �&�*�	+r�win32z*test specific to the nturl2path functions.c���d}d}tjj|�}|j||d|�d|���d}d}tjj|�}|j||d|�d|���y)Nz
\\?\C:\dirz	///C:/dirr�r�z\\?\unc\server\share\dirz/server/share/dir)rrr	r�rs    r�
test_prefixeszPathname_Tests.test_prefixes�sz��!�������,�,�U�3������� �&�*�	+�1��$�����,�,�U�3������� �&�*�	+rz.test specific to the urllib.url2path function.c	��d}d}|D]:}tjj|�}|j||d|�d|����<d}d}tjj|�}|j||d|�d|���y)N)z/C:/z///C:/z/C|//�C:\z'urllib.request..url2pathname() failed; r�z
///C|/pathzC:\pathz&urllib.request.url2pathname() failed; )rrrr�)r-rr	rr�s     r�test_ntpathzPathname_Tests.test_ntpath
s���,�����C��^�^�0�0��5�F����V�V�$�f�.�
/��
�������,�,�U�3������� �&�*�	+rN)rBrCrDr�rlr�r��sys�platformr�r�r&rrr�r��sq��0�2�+�6�X�������0�E�G�
+�G�
+� �X�������0�I�K�
+�K�
+rr�c��eZdZ	d�Zy)�
Utility_Testsc�j�	|jtjj�t�yr+)r�rr�thishost�tuplerAs r�
test_thishostzUtility_Tests.test_thishost!s"��O����f�n�n�5�5�7��?rN)rBrCrDr�r&rrr�r�s��G�@rr�c��eZdZ	d�Zej
e��d��Zej
e��d��Zej
e��d��Z	y)�URLopener_Testsc�B�Gd�dtjj�}tjdt
f�5|j
|�jd�d�|j
|�jd�d�ddd�y#1swYyxYw)Nc��eZdZd�Zy)�8URLopener_Tests.test_quoted_open.<locals>.DummyURLopenerc��|Sr+r&�r-rs  r�	open_spamzBURLopener_Tests.test_quoted_open.<locals>.DummyURLopener.open_spam+����
rN)rBrCrDr�r&rr�DummyURLopenerr�*���
rr�z8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrr|rr$r%r�r)r-r�s  r�test_quoted_openz URLopener_Tests.test_quoted_open)s���	�V�^�^�5�5�	��
+�
+�K�"�$�%�
���^�-�2�2�#�%�%5�
7�
���^�-�2�2�>�@�9�
;�%�%�%�s�A
B�B)�categoryc���tj�5}tj|��\}}t	j
|�dtjj|�z}tjj�j|�\}}|jtjj|�tjj|��ddd�y#1swYyxYw)N)�dirzfile:)r�temp_dirrTrUr�r@rrr	r|�retriever�rV�normcase)r-�tmpdirrZ�tmpfile�fileurlrM�_s       r�test_urlopener_retrieve_filez,URLopener_Tests.test_urlopener_retrieve_file8s���
�
�
�
!�V�"�*�*�v�6�K�B���H�H�R�L����� ;� ;�G� D�D�G� �.�.�2�2�4�=�=�g�F�K�H�a����R�W�W�-�-�h�7����9I�9I�'�9R�S�
"�
!�
!�s�C
C+�+C4c�$�d}|jd�|j|j�tjj�j
|�\}}|jtjj|�dd�y)Nzhttp://www.python.org/file.txtrr
z.txt)rTr�r\rrr|r�r�r�rV�splitext)r-rrMr�s    r�test_urlopener_retrieve_remotez.URLopener_Tests.test_urlopener_retrieve_remoteBsi��.���
�
�6�7�������(��n�n�.�.�0�9�9�#�>���!�������)�)�(�3�A�6��?rc�B�Gd�dtjj�}dD]�}|jttjj
|�|jttjj�j|�|jttjj�j|�|jt|�j|�|jt|�j|���y)Nc��eZdZd�Zy)�<URLopener_Tests.test_local_file_open.<locals>.DummyURLopenerc��|Sr+r&r�s  r�open_local_filezLURLopener_Tests.test_local_file_open.<locals>.DummyURLopener.open_local_fileNr�rN)rBrCrDr�r&rrr�r�Mr�rr�)zlocal_file://examplezlocal-file://example)rrr|r�r<r"rr�)r-r�rs   r�test_local_file_openz$URLopener_Tests.test_local_file_openJs���	�V�^�^�5�5�	�D�C����g�v�~�~�'=�'=�s�C����g�v�~�~�'?�'?�'A�'F�'F��L����g�v�~�~�'?�'?�'A�'J�'J�C�P����g�~�'7�'<�'<�c�B����g�~�'7�'@�'@�#�F�DrN)
rBrCrDr�r�ignore_warningsr%r�r�r�r&rrr�r�&sy��>�
;�%�_�$�$�.@�A�T�B�T�%�_�$�$�.@�A�@�B�@�%�_�$�$�.@�A�
G�B�
Grr�c��eZdZ	d�Zd�Zy)�RequestTestsc���tjj}|d�}|j|j	�d�|di�}|j|j	�d�y)Nrr��POST)rr�Requestr��
get_method�r-r�rs   r�test_default_valuesz RequestTests.test_default_values[s[���.�.�(�(���1�2������+�+�-�u�5��1�2�6������+�+�-�v�6rc���tjj}|dd��}|j|jd�|j|j�d�|did��}|j|jd�|j|j�d�|dd��}|j|j�d�d|_|j|j�d�y)Nr�HEAD)�methodr�)rrr�r�r�r�r�s   r�test_with_method_argz!RequestTests.test_with_method_argbs����.�.�(�(���1�&�A���������0�����+�+�-�v�6��1�2�f�E���������0�����+�+�-�v�6��1�%�@������+�+�-�u�5��������+�+�-�v�6rN)rBrCrDr�r�r&rrr�r�Xs��0�7�7rr�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�URL2PathNameTestsc��|jtd�d�|jtd�d�|jtd�d�y)Nz///C|�C:�///C:z///C|/r��r�rrAs r�test_converting_drive_letterz.URL2PathNameTests.test_converting_drive_letterrsA������g�.��5�����g�.��5�����h�/��8rc�p�|jtd�d�|jtd�d�y)Nz
///C/test/z
\\\C\test\z////C/test/z	\\C\test\r�rAs r�$test_converting_when_no_drive_letterz6URL2PathNameTests.test_converting_when_no_drive_letterws.������l�3�5F�G�����m�4�6F�Grc�:�|jtd�d�y)Nz///C|/foo/bar/spam.foo�C:\foo\bar\spam.foor�rAs r�test_simple_comparez%URL2PathNameTests.test_simple_compare|s������&>�?�/�	1rc�:�|jttd�y)Nu///è|/)r��IOErrorrrAs r�test_non_ascii_drive_letterz-URL2PathNameTests.test_non_ascii_drive_letter�s�����'�<��?rc�b�gd�}|D]&}|jtt|��|��(y)N)r�z\\\C\test\\r�)r�rr	�r-�
list_of_pathsrVs   r�test_roundtrip_url2pathnamez-URL2PathNameTests.test_roundtrip_url2pathname�s/���
�"�D����\�,�t�*<�=�t�D�"rN)rBrCrDr�r�r�r�r�r&rrr�r�ps��9�
H�
1�@�Err�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�PathName2URLTestsc�p�|jtd�d�|jtd�d�y)Nr�r�r��r�r	rAs rr�z.PathName2URLTests.test_converting_drive_letter�s,������d�+�W�5�����f�-�w�7rc��|jtd�d�|jtd�d�|jtd�d�y)Nz\\\folder\test\�/////folder/test/z\\folder\test\z////folder/test/z
\folder\test\z
/folder/test/r�rAs rr�z6PathName2URLTests.test_converting_when_no_drive_letter�sM������&<�=�,�	.�����&;�<�+�	-�����&:�;�(�	*rc�:�|jtd�d�y)Nr��///C:/foo/bar/spam.foor�rAs rr�z%PathName2URLTests.test_simple_compare�s������&<�=�1�	4rc�:�|jttd�y)NzXX:\)r�r�r	rAs r�test_long_drive_letterz(PathName2URLTests.test_long_drive_letter�s�����'�<��9rc�b�gd�}|D]&}|jtt|��|��(y)N)r�r�r�)r�r	rr�s   r�test_roundtrip_pathname2urlz-PathName2URLTests.test_roundtrip_pathname2url�s/��3�
�"�D����\�,�t�*<�=�t�D�"rN)rBrCrDr�r�r�r�r�r&rrr�r��s��8�*�4�:�Err��__main__)NNr]):�urllib.parser�urllib.request�urllib.error�http.clientrQ�
email.messager�r8r��
unittest.mockrrir�test.supportrrrr�r��ImportErrorr�rT�
nturl2pathrr	�base64r
r��has_gethostnamer�rrr"rrTrqrVr_�TestCaserxr�r�rr�r�r�r�r+rRr�r�r�r�r�r�rB�mainr&rr�<module>rs$��A������	����"�&�(�	�����1����$�$�
�(�
�
�9�
:�:���
�
&� /�,�^<�F�<�;�6�;�(ZR��)�)�ZR�zD9��"�"�D9�N!C�� 1� 1�!C�HH��)�)�=�,�H�VJP��)�)�JP�ZL-�H�-�-�L-�^*"�H�-�-�}�*"�ZJL�8�$�$�JL�ZRI�X�&�&�RI�jA)�h�'�'�A)�FL+�X�&�&�L+�\@�H�%�%�@�/G�m�X�%6�%6�/G�d7�8�$�$�7�0E��)�)�E�6E��)�)�E�8�z���H�M�M�O���k4��
�C��s�H�H�H

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