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_urlparse.cpython-36.pyc
3

ai���!@s�ddlZddlZddlZddlZdZdZdZdZdgfdgfdgfdd4gfd	d5gfd
d6gfdd7gfdd8gfdd9d:gfdd;d<gfdgfdgfdgfdd=gfdd>gfdd?gfdd@gfddAgfddBdCgfd dDdEgfd#gfd$gfd%dFgfd&dGdHgfd'dIdJgfd(gfd)gfd*dKgfd+dLdMgfd,dNdOgfgZ	difdifdifdddgifd	dd
gifd
d
dgifdd
dgifdd
d
gifddgdgd-�fdd
ddgifdifdifdifdddgifdddgifdddgifdddgifdddgifddgdgd.�fd dd!d"gifd#ifd$ifd%d
d
gifd&dgdgd-�fd'd
ddgifd(ifd)ifd*ddgifd+dgdgd.�fd,dd!d"gifgZ
Gd/d0�d0ej�ZGd1d2�d2ej�Z
ed3k�r�ej�dS)P�Nzhttp://a/b/c/d;p?q#fzhttp://a/b/c/d;p?qzhttp://a/b/c/d��&z&&�=z=a�aza=z&a=b�bza=a+b&b=b+c�a b�b cza=1&a=2�1�2��&s&&�=s=a�asa=s&a=b�bsa=a+b&b=b+c�a b�b csa=1&a=2�1�2�;z;;z;a=bza=a+b;b=b+cza=1;a=2�;s;;s;a=bsa=a+b;b=b+csa=1;a=2)rr)rrc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWS)X�UrlParseTestCasecCs`tjj|�}|j||�|j|j|j|j|j|j	f}|j||�tjj
|�}|j||�|j||j��tjj|j��}|j|j�|j��|j||�|j|j|j�|j|j|j�|j|j|j�|j|j|j�|j|j|j�|j|j	|j	�|j|j|j�|j|j
|j
�|j|j|j�|j|j|j�tjj|�}|j||�|j|j|j|j|j	f}|j||�tjj|�}|j||�|j||j��tjj|j��}|j|j�|j��|j||�|j|j|j�|j|j|j�|j|j|j�|j|j|j�|j|j	|j	�|j|j|j�|j|j
|j
�|j|j|j�|j|j|j�dS)N)�urllib�parse�urlparse�assertEqual�scheme�netloc�path�params�query�fragment�
urlunparse�geturl�username�password�hostname�port�urlsplit�
urlunsplit)�self�url�parsed�split�result�tZresult2Zresult3�r/�%/usr/lib64/python3.6/test_urlparse.py�checkRoundtripsUsRz UrlParseTestCase.checkRoundtripscCshxbtD]Z\}}tjj|dd�}|j||d|�dd�|D�}tjj|dd�}|j||d|�qWdS)NT)�keep_blank_valueszError parsing %rcSsg|]}t|d�r|�qS)�)�len)�.0�vr/r/r0�
<listcomp>�sz-UrlParseTestCase.test_qsl.<locals>.<listcomp>F)�parse_qsl_test_casesrr�	parse_qslr)r)�orig�expectr-�expect_without_blanksr/r/r0�test_qsl�szUrlParseTestCase.test_qslcslxftD]^\}�tjj|dd�}|j|�d|��fdd��D�}tjj|dd�}|j||d|�qWdS)NT)r2zError parsing %rcs&i|]}t�|d�r�||�qS)r)r4)r5r6)r;r/r0�
<dictcomp>�sz,UrlParseTestCase.test_qs.<locals>.<dictcomp>F)�parse_qs_test_casesrr�parse_qsr)r)r:r-r<r/)r;r0�test_qs�s
zUrlParseTestCase.test_qscsTdd"d%d(d+d.g}dd���fdd�|D�}x$||D]\}}}|j|||�q4WdS)/N�file:///tmp/junk.txt�filer�
/tmp/junk.txt�imap://mail.python.org/mbox1�imap�mail.python.org�/mbox1�1mms://wms.sys.hinet.net/cts/Drama/09006251100.asf�mms�wms.sys.hinet.net�/cts/Drama/09006251100.asf�nfs://server/path/to/file.txt�nfs�server�/path/to/file.txt�0svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/�svn+ssh�svn.zope.org�/repos/main/ZConfig/trunk/�)git+ssh://git@github.com/user/project.git�git+ssh�git@github.com�/user/project.gitcSs8|djd�tdd�|dD��tdd�|dD��fS)Nr�asciicss|]}|jd�VqdS)rYN)�encode)r5�xr/r/r0�	<genexpr>�szDUrlParseTestCase.test_roundtrips.<locals>._encode.<locals>.<genexpr>r3css|]}|jd�VqdS)rYN)rZ)r5r[r/r/r0r\�s�)rZ�tuple)r.r/r/r0�_encode�sz1UrlParseTestCase.test_roundtrips.<locals>._encodecsg|]}�|��qSr/r/)r5r[)r_r/r0r7�sz4UrlParseTestCase.test_roundtrips.<locals>.<listcomp>�rCrrDrrr�rCrrDrr)rBr`ra�rFrGrHrrr�rFrGrHrr)rErbrc�rJrKrLrrr�rJrKrLrr)rIrdre�rNrOrPrrr�rNrOrPrr)rMrfrg�rRrSrTrrr�rRrSrTrr)rQrhri�rVrWrXrrr�rVrWrXrr)rUrjrk)r1)r)�	str_cases�bytes_casesr*r+r,r/)r_r0�test_roundtrips�s8z UrlParseTestCase.test_roundtripsc

s�ddd!d$d'g}dd���fdd�|D�}d(}d)}||f}||f}x`||fD]T\}}xJ|D]B}	x<|D]4\}
}}|	|
}
|	f|}|	f|}|j|
||�qbWqXWqJWdS)*N�://www.python.org�www.python.orgr�://www.python.org#abc�abc�://www.python.org?q=abc�q=abc�://www.python.org/#abc�/�://a/b/c/d;p?q#fr�/b/c/d�p�q�f�/b/c/d;pcSs8|djd�tdd�|dD��tdd�|dD��fS)NrrYcss|]}|jd�VqdS)rYN)rZ)r5r[r/r/r0r\�szIUrlParseTestCase.test_http_roundtrips.<locals>._encode.<locals>.<genexpr>r3css|]}|jd�VqdS)rYN)rZ)r5r[r/r/r0r\�sr])rZr^)r.r/r/r0r_�sz6UrlParseTestCase.test_http_roundtrips.<locals>._encodecsg|]}�|��qSr/r/)r5r[)r_r/r0r7�sz9UrlParseTestCase.test_http_roundtrips.<locals>.<listcomp>�http�https�http�https�rprrrr�rprrr)ror�r��rprrrrr�rprrrr)rqr�r��rprrrtr�rprrtr)rsr�r��rprvrrrr�rprvrrr)rur�r��rrxryrzr{�rr|rzr{)rwr�r�)r}r~)rr�)r1)
r)rlrmZstr_schemesZ
bytes_schemesZ	str_testsZbytes_testsZschemesZ
test_casesrr*r+r,r/)r_r0�test_http_roundtrips�s8


z%UrlParseTestCase.test_http_roundtripsc	CsR|||f}|jtjj||�|�dd�|D�}\}}}|jtjj||�|�dS)NcSsg|]}|jd��qS)rY)rZ)r5r[r/r/r0r7�sz.UrlParseTestCase.checkJoin.<locals>.<listcomp>)rrr�urljoin)	r)�baseZrelurl�expectedZstr_componentsZbytes_componentsZbasebZrelurlbZ	expectedbr/r/r0�	checkJoin�s
zUrlParseTestCase.checkJoincCsndddddddg}dd	�|D�}xH||D]<}|jtjjtjj|��|�|jtjjtjj|��|�q*WdS)
N�Pythonz./Pythonzx-newscheme://foo.com/stuffzx://yzx:/yzx:/rvcSsg|]}|jd��qS)rY)rZ)r5r[r/r/r0r7�sz7UrlParseTestCase.test_unparse_parse.<locals>.<listcomp>)rrrr(r'r!r)r)rlrm�ur/r/r0�test_unparse_parse�s
z#UrlParseTestCase.test_unparse_parsecCs�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtd	d
�|jtdd�|jtd
d�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtd d�|jtd!d"�|jtd#d$�|jtd%d$�|jtd&d�|jtd'd(�|jtd)d*�|jtd+d,�|jtd-d.�|jtd/d0�|jtd1d"�|jtd2d�|jtd3d4�|jtd5d6�dS)7Nzg:h�gzhttp://a/b/c/gz./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gzg?yzhttp://a/b/c/g?yzg?y/./xzhttp://a/b/c/g?y/./xz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg#s/./xzhttp://a/b/c/g#s/./xzg?y#szhttp://a/b/c/g?y#szg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#s�.z
http://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../z../../grzhttp://a/b/c/d;p?q#fzg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/h)r��RFC1808_BASE)r)r/r/r0�test_RFC1808�s>zUrlParseTestCase.test_RFC1808cCs|jtjjd�d�dS)Nzmailto:1337@example.org�mailtor�1337@example.org)r�rr�rrr)rrrr)r)r/r/r0�test_RFC2368"szUrlParseTestCase.test_RFC2368cCs�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtd	d
�|jtdd�|jtd
d�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd �|jtd!d �|jtd"d�|jtd#t�|jtd$d%�|jtd&d'�|jtd(d)�|jtd*d+�|jtd,d�|jtd-d�|jtd.d/�|jtd0d1�|jtd2d3�|jtd4d5�|jtd6d7�|jtd8d9�|jtd:d;�|jtd<d=�dS)>Nzg:hr�zhttp://a/b/c/gz./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gzg?yzhttp://a/b/c/g?yz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg?y#szhttp://a/b/c/g?y#szg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#sr�z
http://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../z../../grzg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hz	g;x=1/./yzhttp://a/b/c/g;x=1/yz
g;x=1/../yzhttp://a/b/c/yzg?y/./xzhttp://a/b/c/g?y/./xzg?y/../xzhttp://a/b/c/g?y/../xzg#s/./xzhttp://a/b/c/g#s/./xzg#s/../xzhttp://a/b/c/g#s/../x)r��RFC2396_BASE)r)r/r/r0�test_RFC2396'sFzUrlParseTestCase.test_RFC2396cCs�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtd	d
�|jtdd�|jtd
d�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtd d!�|jtd"d!�|jtd#d$�|jtd%d&�|jtd'd&�|jtd(d�|jtd)d�|jtd)d�|jtd*d�|jtd+d�|jtd,d�|jtd-d.�|jtd/d0�|jtd1d2�|jtd3d4�|jtd5d$�|jtd6d
�|jtd7d8�|jtd9d:�|jtd;d<�|jtd=d>�|jtd?d@�|jtdAdB�|jtdCdD�|jtdEdF�|jtdGd�|jdHdd�dS)INz?yzhttp://a/b/c/d;p?yz;xzhttp://a/b/c/;xzg:hr�zhttp://a/b/c/gz./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gzg?yzhttp://a/b/c/g?yz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg?y#szhttp://a/b/c/g?y#szg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#srzhttp://a/b/c/d;p?qr�z
http://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../z../../gz
../../../gz
../../../../gz/./gz/../gzg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hz	g;x=1/./yzhttp://a/b/c/g;x=1/yz
g;x=1/../yzhttp://a/b/c/yzg?y/./xzhttp://a/b/c/g?y/./xzg?y/../xzhttp://a/b/c/g?y/../xzg#s/./xzhttp://a/b/c/g#s/./xzg#s/../xzhttp://a/b/c/g#s/../xzhttp:gzhttp://a/b/c/de)r��RFC3986_BASE)r)r/r/r0�test_RFC3986Ts\zUrlParseTestCase.test_RFC3986cCsX|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd	�|jtd
d�|jtdd
�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtdd�|jtd d	�|jtd!d"�|jtd#d$�|jtdd�|jtdd�|jtd%d�|jtd&d�|jtd'd�|jd(dd(�|jd)dd�|jd)d*d*�|jd+d,d-�|jd.d,d/�|jd0dd1�|jd2dd3�|jtd4d5td6�|jd7d8d9�|jd:d8d;�|jd7d<d=�|jd:d<d=�|jd7d>d?�|jdd8d=�|jd@dAdA�dS)BNzg:hzhttp:gzhttp://a/b/c/gzhttp:zhttp://a/b/c/dr�z./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gz?yzhttp://a/b/c/d?yzg?yzhttp://a/b/c/g?yzg?y/./xzhttp://a/b/c/g?y/./xr�z
http://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hzhttp:?yzhttp:g?yzhttp:g?y/./xzhttp:///rzhttp://a/./gzsvn://pathtorepo/dir1Zdir2zsvn://pathtorepo/dir2zsvn+ssh://pathtorepo/dir1zsvn+ssh://pathtorepo/dir2zws://a/bzws://a/gz	wss://a/bz	wss://a/grv�fooz/foozhttp://a/b/c/d/e/z
../../f/g/zhttp://a/b/c/f/g/zhttp://a/b/c/d/ezhttp://a/b/f/g/z/../../f/g/z
http://a/f/g/z	../../f/gzhttp://a/b/c/f/grr)r��SIMPLE_BASE)r)r/r/r0�
test_urljoins�sTzUrlParseTestCase.test_urljoinscs�d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCg}d"d#���fd$d%�|D�}x:||D].\}}}tjj|�}|j|j|jf||f�qXWd&d'd(d)d*g}d+d%�|D�}x$||D]}|jttjj|��q�WdS)DN� http://Test.python.org:5432/foo/�test.python.org�8�http://12.34.56.78:5432/foo/�12.34.56.78�http://[::1]:5432/foo/�::1�http://[dead:beef::1]:5432/foo/�dead:beef::1�http://[dead:beef::]:5432/foo/�dead:beef::�:http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/�'dead:beef:cafe:5417:affe:8fa3:deaf:feed� http://[::12.34.56.78]:5432/foo/�
::12.34.56.78�%http://[::ffff:12.34.56.78]:5432/foo/�::ffff:12.34.56.78�http://Test.python.org/foo/�http://12.34.56.78/foo/�http://[::1]/foo/�http://[dead:beef::1]/foo/�http://[dead:beef::]/foo/�5http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/�http://[::12.34.56.78]/foo/� http://[::ffff:12.34.56.78]/foo/�http://Test.python.org:/foo/�http://12.34.56.78:/foo/�http://[::1]:/foo/�http://[dead:beef::1]:/foo/�http://[dead:beef::]:/foo/�6http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:/foo/�http://[::12.34.56.78]:/foo/�!http://[::ffff:12.34.56.78]:/foo/cSs"|djd�|djd�|dfS)NrrYr3r])rZ)r.r/r/r0r_�sz.UrlParseTestCase.test_RFC2732.<locals>._encodecsg|]}�|��qSr/r/)r5r[)r_r/r0r7�sz1UrlParseTestCase.test_RFC2732.<locals>.<listcomp>zhttp://::12.34.56.78]/zhttp://[::1/foo/zftp://[::1/foo/bad]/badzhttp://[::1/foo/bad]/badzhttp://[::ffff:12.34.56.78cSsg|]}|jd��qS)rY)rZ)r5r[r/r/r0r7�s)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)r�r�N)rrrrr%r&�assertRaises�
ValueError)r)rlrmr*r%r&Z	urlparsedZinvalid_urlr/)r_r0�test_RFC2732�sVzUrlParseTestCase.test_RFC2732cs�ddddddddtdd
ftddfg
}dd���fdd�|D�}x^||D]R\}}}tjj|�}|j|j�|�|j|||f�|j|j|�|j|j|�qHWdS)N�http://python.org#frag�http://python.org�fragr�http://python.org/#frag�http://python.org/�http://python.org/?q#frag�http://python.org/?q�http://python.org/p#frag�http://python.org/p�http://python.org/p?qzhttp://a/b/c/d;p?qr{cSst|�dd�|D��S)Ncss|]}|jd�VqdS)rYN)rZ)r5r[r/r/r0r\szCUrlParseTestCase.test_urldefrag.<locals>._encode.<locals>.<genexpr>)�type)r.r/r/r0r_sz0UrlParseTestCase.test_urldefrag.<locals>._encodecsg|]}�|��qSr/r/)r5r[)r_r/r0r7sz3UrlParseTestCase.test_urldefrag.<locals>.<listcomp>)r�r�r�)r�r�r)r�r�r�)r�r�r)r�r�r�)r�r�r)r�r�r�)r�r�r)	r�r�rrZ	urldefragrr"r*r )r)rlrmr*Zdefragr�r-r/)r_r0�test_urldefrag�s$zUrlParseTestCase.test_urldefragcCsTtjjd�}|j|jd�|j|jd�tjjd�}|j|jd�|j|jd�dS)Nz,http://[FE80::822a:a8ff:fe49:470c%tESt]:1234zfe80::822a:a8ff:fe49:470c%tEStz%[FE80::822a:a8ff:fe49:470c%tESt]:1234s,http://[FE80::822a:a8ff:fe49:470c%tESt]:1234sfe80::822a:a8ff:fe49:470c%tESts%[FE80::822a:a8ff:fe49:470c%tESt]:1234)rrr'rr%r)r)ryr/r/r0�test_urlsplit_scoped_IPv6
sz*UrlParseTestCase.test_urlsplit_scoped_IPv6c	Csd}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d�|j|jd�|j|jd�|j|j
�dd�|dd��d	}tjj|�}|j|jd�|j|jd
�|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d
�|j|jd�|j|jd�|j|j
�|�d}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d
�|j|jd�|j|jd�|j|j
�|�d}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d�|j|jd�|j|jd�|j|j
�dd�|dd��d}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d�|j|jd�|j|jd�|j|j
�|�d}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	d �|j|j
d�|j|jd�|j|jd�|j|j
�|�d!}tjj|�}|jtd"��|jWdQRXdS)#NzHTTP://WWW.PYTHON.ORG/doc/#fragr}zWWW.PYTHON.ORGz/doc/rr�zwww.python.org�z7http://User:Pass@www.python.org:080/doc/?query=yes#fragzUser:Pass@www.python.org:080z	query=yes�User�Pass�PzChttp://User@example.com:Pass@www.python.org:080/doc/?query=yes#fragz(User@example.com:Pass@www.python.org:080zUser@example.comsHTTP://WWW.PYTHON.ORG/doc/#fragshttpsWWW.PYTHON.ORGs/doc/rsfragswww.python.orgs7http://User:Pass@www.python.org:080/doc/?query=yes#fragsUser:Pass@www.python.org:080s	query=yessUsersPasssChttp://User@example.com:Pass@www.python.org:080/doc/?query=yes#frags(User@example.com:Pass@www.python.org:080sUser@example.coms%HTTP://WWW.PYTHON.ORG:65536/doc/#fragzout of range)rrr'rrrrrr r#r$r%r&r"�assertRaisesRegexr�)r)r*ryr/r/r0�test_urlsplit_attributess�  z)UrlParseTestCase.test_urlsplit_attributescCsZttdd!��}d}|jd�|}tjj|�}|j|jd�|j|jd�|j|j	d�|j|j
d	�|j|jd
�|j|jd�|j|j
d�|j|jd
�|j|jd�|j|j�|�||jd�}tjj|�}|j|jd�|j|jd�|j|j	d�|j|j
d�|j|jd�|j|jd�|j|j
d�|j|jd�|j|jd�|j|j�|jd��d}tjj|jd�|�}|j|jd�|j|jd�|j|j	d�|j|j
d�|j|jd�|j|j�|�tjjd�}|jtjj|�d�d}|jd�d|jd�}x@td�D]4}tjj||d�}|j|jd�|j|j�d ��qWdS)"Nr� r3z7http://User:Pass@www.python.org:080/doc/?query=yes#fragzutf-8r}zUser:Pass@www.python.org:080z/doc/z	query=yesr�r�r�zwww.python.orgr�shttpsUser:Pass@www.python.org:080s/doc/s	query=yessfragsUsersPassswww.python.orgz)https://www.python.org:88/doc/?query=    r~zwww.python.org:88z
query=    �Xz
www.pypi.org z//www.python.org/r])rzhttps://www.python.org/�!)�bytes�range�decoderrr'rrrrrr r#r$r%r&r"rZr()r)ZnoiseZbase_urlr*ryZquery_spaces_urlr�_r/r/r0�test_urlsplit_strip_urlssTz(UrlParseTestCase.test_urlsplit_strip_urlcCs�d}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d�|j|jd�|j|jd�|j|j
�d�d}tjj|�}|j|jd	�|j|jd
�|j|jd�|j|jd�|j|jd
�|j|j	d�|j|j
d�|j|jd
�|j|jd�|j|j
�d�d}tjj|�}|j|j
�d�d}tjj|�}|j|j
�d�d}d}x@td�D]4}tjj||d�}|j|jd�|j|j
�d��q�WdS)NzQh
ttp://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentr}zwww.python.orgz/javascript:alert('msg')/zquery=somethingr zGhttp://www.python.org/javascript:alert('msg')/?query=something#fragmentsQh
ttp://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentshttpswww.python.orgs/javascript:alert('msg')/squery=somethingsfragmentsGhttp://www.python.org/javascript:alert('msg')/?query=something#fragmentzYx-new-scheme	://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentzOx-new-scheme://www.python.org/javascript:alert('msg')/?query=something#fragmentsYx-new-scheme	://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentsOx-new-scheme://www.python.org/javascript:alert('msg')/?query=something#fragmentzQhttps://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentzhtt
psr])rr~zHhttps://www.python.org/javascript:alert('msg')/?query=something#fragment)rrr'rrrrrr r#r$r%r&r"r�)r)r*ryrr�r/r/r0�!test_urlsplit_remove_unsafe_bytes�sHz2UrlParseTestCase.test_urlsplit_remove_unsafe_bytescCs�x�d
D]�}x�tjjtjjfD]�}x�dD]~}|j|||d��dd|}d	|d
}|rh|jd�}|jd�}||�}|j|j|�|jt	��|j
WdQRXWdQRXq&WqWqWdS)z Check handling of invalid ports.FTr��1.5�-1�0x10)r�rr&zwww.example.net:zhttp://rvrYN)FT)r�r�r�r�)rrr'r�subTestrZrrr�r�r&)r)r�rr&rr*ryr/r/r0�test_attributes_bad_port�s



z)UrlParseTestCase.test_attributes_bad_portcCs�d}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	�|�tjj
|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	�|�d}tjj|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	�|�tjj
|�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|j	�|�dS)Nz0sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15rs0sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15r)rrr'rrr#r$r%r&r"r)r)Zuriryr/r/r0�test_attributes_without_netloc�s<z/UrlParseTestCase.test_attributes_without_netloccCs,|jtjjd�d�|jtjjd�d�dS)
Nz http://example.com?blahblah=/foor}�example.comr�
blahblah=/foos http://example.com?blahblah=/foo�http�example.comr�
blahblah=/foo)r}r�rrr�r)r�r�rrr�r)rrrr)r)r/r/r0�test_noslashszUrlParseTestCase.test_noslashcCs||jtjjd�d
�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd	�d�|jtjjd�d�dS)Nrrz//www.python.org:80�www.python.org:80zhttp://www.python.org:80r}�pathrs//www.python.org:80�www.python.org:80shttp://www.python.org:80�http)rrrrrr)rr�rrrr)r}r�rrrr)rrr�rrr)rr�rrrr)r�r�rrrr)rrrr)r)r/r/r0�test_withoutschemesz#UrlParseTestCase.test_withoutschemecCs�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd	�d�|jtjjd�d�|jtjjd
�d�|jtjjd�d�dS)N�path:80rzhttp:r}zhttps:r~zhttp://www.python.org:80�www.python.org:80�path:80rshttp:�httpshttps:�httpsshttp://www.python.org:80�www.python.org:80)rrr�rrr)r}rrrrr)r~rrrrr)r}r�rrrr)rrr�rrr)r�rrrrr)r�rrrrr)r�r�rrrr)rrrr)r)r/r/r0�test_portseparator1sz#UrlParseTestCase.test_portseparatorcCs|jttjjd�dS)Nr�)r��	TypeErrorrr�	urlencode)r)r/r/r0�
test_usingsysAszUrlParseTestCase.test_usingsyscCs�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd�d�dS)Nzs3://foo.com/stuff�s3�foo.com�/stuffrzx-newscheme://foo.com/stuff�x-newschemez*x-newscheme://foo.com/stuff?query#fragmentrr z!x-newscheme://foo.com/stuff?queryss3://foo.com/stuff�s3�foo.com�/stuffrsx-newscheme://foo.com/stuff�x-newschemes*x-newscheme://foo.com/stuff?query#fragment�query�fragments!x-newscheme://foo.com/stuff?query)r�r�r�rrr)r�r�r�rrr)r�r�r�rrr )r�r�r�rrr)rrrrrr)rrrrrr)rrrrrr)rrrrrr)rrrr)r)r/r/r0�test_anyschemeEs zUrlParseTestCase.test_anyschemec
Cs�x�tjjtjjfD]�}|j|d���|dd�}|j|jd�|dd�}|j|jd�|j|dd�jd�|j|ddd	�jd�|j|d
dd	�jd�|j|d�jd�|j|d
�jd�|j|d
d�jd�WdQRXqWdS)
N)�functionzhttp://example.net/�ftpr}shttp://example.net/sftpshttpr)rspathrr)rrrr'r�rr)r)�funcr-r/r/r0�test_default_schemeZs

z$UrlParseTestCase.test_default_schemecCsd!}�x|D]�\}}}x�tjjtjjfD]�}|dkrD|tjjkrDd}|j||d���||dd�}|j|jd�|jt||�j	d|��|j||dd�jd�||dd�}|j|j|�|j
t||�j	|��|j||dd�j|�|j||�j|�WdQRXq(WqWdS)"N�
http:#fragrr��//example.net#frag�index.html#frag�	;a=b#fragr�	?a=b#fragr�#frag�	abc#@frag�@frag�//abc#@frag�//abc:80#@frag�//abc#@frag:80�@frag:80)r*rF)Zallow_fragmentsr�#T�rrr��rrr��r
rr��rrr��rrr��rrr��rrr�rrr�rrr�rrr)
rrrrrrrrr r!)rrrr'r�rr Z
assertTrue�getattr�endswithZassertFalse)r)Ztestsr*�attrZ
expected_fragr	r-r/r/r0�test_parse_fragmentsis6z%UrlParseTestCase.test_parse_fragmentscICsx|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjd	�WdQRX|jtd��tjjd
�WdQRX|jtd��tjjd�WdQRX|jtd��tjjd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRXdS)
NzCannot mix str�www.python.org�http�www.python.orgr}rzhttp://python.orgshttp://python.org)r'r&rrrr)r}r(rrrr)r'r&rrr)r}r(rrr)	r�r�rrrr'r!r(r�)r)r/r/r0�test_mixed_types_rejected�s(z*UrlParseTestCase.test_mixed_types_rejectedc
Cs:t|j�}|j}|j|j|�d|}d|}||�}||�}d}d}	|j||�|j|j�|�|j|j�|�|j|j|�|�|j|j|�|�|j|j||	�|�|j|j||	�|�|j||�|j|j�|�|j|j�|�|j|j|�|�|j|j|�|�|j|j||	�|�|j|j||	�|�dS)NrrrY�strict)r)r)r4�_fieldsZ_encoded_counterpartZassertIsZ_decoded_counterpartrr�rZ)
r)Zstr_typeZnum_argsZ
bytes_typeZstr_argsZ
bytes_argsZ
str_resultZbytes_result�encoding�errorsr/r/r0�_check_result_type�s.
z#UrlParseTestCase._check_result_typecCs2tjjtjjtjjg}x|D]}|j|�qWdS)N)rrZDefragResultZSplitResultZParseResultr.)r)Zresult_typesZresult_typer/r/r0�test_result_pairs�s


z"UrlParseTestCase.test_result_pairscCs�tjjddd�}|j|ddgi�tjjddd�}|j|ddgi�tjjddd�}|j|dd	gi�tjjd
dd�}|j|ddgi�tjjd
ddd
�}|j|ddgi�dS)Nu	key=Ł%E9zlatin-1)r,�keyuŁéukey=Ł%C3%A9zutf-8rYuŁ��u
key=Ł%E9-uŁ�-�ignore)r,r-uŁ-)rrr@r)r)r-r/r/r0�test_parse_qs_encoding�s
z'UrlParseTestCase.test_parse_qs_encodingcCs�tjjddd�}|j|dg�tjjddd�}|j|dg�tjjddd�}|j|dg�tjjd
dd�}|j|dg�tjjd
ddd
�}|j|dg�dS)Nu	key=Ł%E9zlatin-1)r,r0�Łéukey=Ł%C3%A9zutf-8rY�Ł��u
key=Ł%E9-�Ł�-r1)r,r-�Ł-)r0r3)r0r3)r0r4)r0r5)r0r6)rrr9r)r)r-r/r/r0�test_parse_qsl_encoding�s
z(UrlParseTestCase.test_parse_qsl_encodingcCs�|jt��"tjjdjdgd�dd�WdQRX|jt��"tjjdjdgd�dd�WdQRXtjjdjdgd�dd�dS)Nrza=a��
)Zmax_num_fieldsr)r�r�rrr@�join)r)r/r/r0�test_parse_qsl_max_num_fields�s
&&z.UrlParseTestCase.test_parse_qsl_max_num_fieldscCsjtjjddgdd�d�}t|jd��d	d
ddd
hks8t�Gdd�d�}tjjd|�id�}|j|d�dS)Nr3r]�r��)rrTrza=1za=2zb=3zb=4zb=5c@seZdZdd�ZdS)z:UrlParseTestCase.test_urlencode_sequences.<locals>.TrivialcSsdS)NZtrivialr/)r)r/r/r0�__str__�szBUrlParseTestCase.test_urlencode_sequences.<locals>.Trivial.__str__N)�__name__�
__module__�__qualname__r>r/r/r/r0�Trivial�srBrz	a=trivial)r<r�r=)rrr��setr,�AssertionErrorr)r)r-rBr/r/r0�test_urlencode_sequences�s
 z)UrlParseTestCase.test_urlencode_sequencescCsjtjjddi�}|j|d�tjjdditjjd�}|j|d�tjjddidtjjd�}|j|d	�dS)
Nrz
some valueza=some+valuezsome value/another)�	quote_viaza=some%20value%2Fanotherrv)ZsaferFza=some%20value/another)rrr�r�quote)r)r-r/r/r0�test_urlencode_quote_via�sz)UrlParseTestCase.test_urlencode_quote_viacCsF|jttjjd�tjjd�}|j|d�tjjd�}|j|d�dS)Nr�sarchaeological arcanazarchaeological%20arcanarr)r�r�rrZquote_from_bytesr)r)r-r/r/r0�test_quote_from_bytes�s
z&UrlParseTestCase.test_quote_from_bytescCs4tjjd�}|j|d�tjjd�}|j|d�dS)Nz	abc%20defsabc defrr)rrZunquote_to_bytesr)r)r-r/r/r0�test_unquote_to_bytessz&UrlParseTestCase.test_unquote_to_bytescCs0|jttjjddd�|jttjjddd�dS)Nsfoozutf-8)r,r*)r-)r�r�rrrG)r)r/r/r0�test_quote_errorssz"UrlParseTestCase.test_quote_errorscCs�tjjd�}|j|jd�|j|jd�tjjd�}|j|jd�|j|jd�tjjd�}|j|jd�|j|jd�tjjd�}|j|jd�|j|jd�dS)Nztel:+31-641044153�telz
+31-641044153ztel:+31641044153z+31641044153)rrr'rrrr)r)�p1Zp2r/r/r0�test_issue14072sz UrlParseTestCase.test_issue14072cCs�tjjd�}|j|jd�|j|jd�|j|jd�tjjd�}|j|jd�|j|jd�|j|jd�tjjd�}|j|jd�|j|jd	�|j|jd
�tjjd�}|j|jd�|j|jd�|j|jd
�dS)Nz"tel:123-4;phone-context=+1-650-516rLz123-4zphone-context=+1-650-516ztel:+1-201-555-0123z+1-201-555-0123rz"tel:7042;phone-context=example.comZ7042zphone-context=example.comz%tel:863-1234;phone-context=+1-914-555z863-1234zphone-context=+1-914-555)rrrrrrr)r)rMr/r/r0�test_telurl_paramss z#UrlParseTestCase.test_telurl_paramscCs$tjjtjj�}|jdt|��dS)N�Quoter)rrrPZ_ALWAYS_SAFE�assertIn�repr)r)Zquoterr/r/r0�test_Quoter_repr4sz!UrlParseTestCase.test_Quoter_reprcCs�g}ddddddddd	d
ddd
ddh}xLttj�D]>}|jd�s2||krJq2ttj|�}t|dd�dkr2|j|�q2W|jtjj|�dS)N�	splitattr�	splithost�
splitnport�splitpasswd�	splitport�
splitquery�splittag�	splittype�	splituser�
splitvaluerPZ
ResultBaseZclear_cache�to_bytes�unwrapr�r@zurllib.parse)�dirrr�
startswithr"�appendZassertCountEqual�__all__)r)r�Zundocumented�name�objectr/r/r0�test_all8s
zUrlParseTestCase.test_allcsd�dd��D����fdd�tttdtj��D�}|jd|�|jd|�tjjd	�|j	t
��tjjd
�WdQRXx�dD]x}xrdD]j}xd|D]\}dj||j|��}|j|djt
|��d��(|j	t
��tjj|�WdQRXWdQRXq�Wq�Wq�WdS)Nz/:#?@cSsh|]}djt|���qS)z{:04X})�format�ord)r5�cr/r/r0�	<setcomp>Msz?UrlParseTestCase.test_urlsplit_normalization.<locals>.<setcomp>cs.g|]&}�ttj|�j��@r|�kr|�qSr/)rC�unicodedata�
decompositionr,)r5ri)�	hex_chars�
illegal_charsr/r0r7Osz@UrlParseTestCase.test_urlsplit_normalization.<locals>.<listcomp>�u℀u#uhttp://プ:80uhttp://プ︓80r}r~r�netloc{}false.netloc�n{}user@netlocz{}://{}/pathz{:04X})r*�char)r}r~r)rprq)�map�chrr��sys�
maxunicoderQrrr'r�r�rgr�rh)r)Zdenorm_charsrrrir*r/)rmrnr0�test_urlsplit_normalizationHs"


z,UrlParseTestCase.test_urlsplit_normalizationN).r?r@rAr1r=rArnr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr
r%r)r.r/r2r7r;rErHrIrJrKrNrOrSrfrwr/r/r/r0rSsV3	
#&0-972	];0)!



rc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
Utility_Testsz=Testcase to test the various utility functions in the urllib.cCs\tjj}|j|d�d	�|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�dS)Nztype:opaquestringr��opaquestring�
:opaquestringztype:rztype:opaque:string�
opaque:string)r�ry)Nry)Nrz)r�r)r�r{)rrr[r)r)r[r/r/r0�test_splittypeiszUtility_Tests.test_splittypecCs�tjj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d	�d�|j|d�d�|j|d
�d�|j|d�d�|j|d�d�|j|d�d�dS) Nz%//www.example.org:80/foo/bar/baz.html�www.example.org:80�/foo/bar/baz.htmlz//www.example.org:80rz//127.0.0.1#@host.com�	127.0.0.1�/#@host.comz//127.0.0.1#@host.com:80�/#@host.com:80z//127.0.0.1:80#@host.com�127.0.0.1:80z///file�/filez//example.net/file;�example.net�/file;z//example.net/file?�/file?z//example.net/file#�/file#)r}r~)r}r)Nr~)rr�)rr�)r�r�)rr�)r�r�)r�r�)r�r�)rrrUr)r)rUr/r/r0�test_splithostqs*









zUtility_Tests.test_splithostcCs\tjj}|j|d�d	�|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�dS)NzUser:Pass@www.python.org:080�	User:Pass�www.python.org:080z@www.python.org:080rz
User:Pass@z(User@example.com:Pass@www.python.org:080�User@example.com:Pass)r�r�)rr�)Nr�)r�r)r�r�)rrr\r)r)r\r/r/r0�test_splituser�s




zUtility_Tests.test_splitusercCs�tjj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d
�d�|j|d�d�|j|d�d �|j|d�d!�|j|d�d"�|j|d�d#�|j|d�d$�|j|d�d%�|j|d�d&�dS)'Nzuser:ab�user�abzuser:a
b�a
bzuser:a	b�a	bzuser:a
b�a
bzuser:ab�abzuser:ab�abzuser:a:b�a:bzuser:a b�a bz	user 2:ab�user 2z
user+1:a+b�user+1�a+bzuser:rz:ab)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r)r�N)rr�)rrrWr)r)rWr/r/r0�test_splitpasswd�szUtility_Tests.test_splitpasswdcCs�tjj}|j|d�d�|j|d�d�|j|d�d
�|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d	�d�dS)Nz	parrot:88�parrot�88zparrot:�	127.0.0.1�
parrot:cheesez[::1]:88�[::1]z:88r)r�r�)r�N)r�N)r�N)r�N)r�r�)r�N)rr�)rrrXr)r)rXr/r/r0�test_splitport�szUtility_Tests.test_splitportcCs�tjj}|j|d�d	�|j|d�d�|j|dd�d�|j|d�d�|j|dd�d�|j|d�d�|j|dd�d�|j|d�d�|j|dd�d�dS)Nz	parrot:88r�r�r3�7zparrot:�	127.0.0.1z
parrot:cheese)r�r����)r�r�)r�r�r�)r�r�)r�r�r�)r�r�)r�r�)r�N)r�N)rrrVr)r)rVr/r/r0�test_splitnport�szUtility_Tests.test_splitnportcCsLtjj}|j|d�d�|j|d�d�|j|d�d	�|j|d�d
�dS)N�http://python.org/fake?foo=bar�http://python.org/fake�foo=barzhttp://python.org/fake?foo=bar?rz?foo=bar)r�r�)r�r)r�N)rr�)rrrYr)r)rYr/r/r0�test_splitquery�s


zUtility_Tests.test_splitquerycCs\tjj}|j|d�d	�|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�dS)N�http://example.com?foo=bar#baz�http://example.com?foo=bar�bazzhttp://example.com?foo=bar#rz#bazz"http://example.com?foo=bar#baz#boo�boo)r�r�)r�r)rr�)r�N)r�r�)rrrZr)r)rZr/r/r0�
test_splittag�s



zUtility_Tests.test_splittagcCsftjj}|j|d�dddgf�|j|d�ddgf�|j|d�dddgf�|j|d�dgf�dS)Nz/path;attr1=value1;attr2=value2z/pathzattr1=value1zattr2=value2z/path;rz;attr1=value1;attr2=value2)rrrTr)r)rTr/r/r0�test_splitattr�s

zUtility_Tests.test_splitattrcCs\tjj}|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�|j|d�d�dS)Nzfoo=barr��barzfoo=rz=bar�foobarzfoo=bar=baz�bar=baz)r�r�)r�r)rr�)r�N)r�r�)rrr]r)r)r]r/r/r0�test_splitvalue�szUtility_Tests.test_splitvaluecCs.tjjd�}|j|d�|jttjjd�dS)Nzhttp://www.python.orguhttp://www.python.org/mediæval)rrr^rr��UnicodeError)r)r-r/r/r0�
test_to_bytes�szUtility_Tests.test_to_bytescCstjjd�}|j|d�dS)Nz<URL:type://host/path>ztype://host/path)rrr_r)r)r*r/r/r0�test_unwrap�szUtility_Tests.test_unwrapN)r?r@rA�__doc__r|r�r�r�r�r�r�r�r�r�r�r�r/r/r/r0rxes
	
rx�__main__)rr)rr)rr)rr)rr)rr)rr)rr	)rr
)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr	)rr
)rr)rr)rr)rr)rr)rurkZunittestZurllib.parserr�r�r�r�r8r?ZTestCaserrxr?�mainr/r/r/r0�<module>s�