HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_urlparse.cpython-310.opt-2.pyc
o

�i@
�@sLddlZddlZddlZddlZdZdZdZdZdgfdgfdgfdd	gfd
dgfdd
gfdd
gfddgfdddgfdddgfdgfdgfdgfddgfddgfddgfd dgfd!d"gfd#d$d%gfd&d'd(gfd)d*gfd+d,gfd-d.gfd/d0gfgZ	difdifdifdddgifd
ddgifdddgifdddgifddd1gifdd2gd3gd�fddd4d5gifdifdifdifdddgifdddgifdddgifd ddgifd!dd6gifd#d7gd8gd"�fd&dd9d:gifd)d;d1gifd+dd<gifd-d=d6gifd/dd>gifgZ
Gd?d@�d@ej�ZGdAdB�dBej�Z
GdCdD�dDej�ZedEk�r$e��dSdS)F�N�http://a/b/c/d;p?q#f�http://a/b/c/d;p?q�http://a/b/c/d��&z&&�=)rrz=a)r�ar)rrza=z&a=b�r�bza=a+b&b=b+c�r�a b�r
�b cza=1&a=2�r�1�r�2��&s&&�=)rrs=a)r�ar)rrsa=s&a=b�r�bsa=a+b&b=b+c�r�a b�r�b csa=1&a=2�r�1�r�2�;a=b)�;ar
�a=a+b;b=b+c)r�	a b;b=b c�;a=b)�;ar�a=a+b;b=b+c)r�	a b;b=b cr
rrrrrrrrr r"r$r&r(c@s|eZdZdd�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-dWdX�Z.dYdZ�Z/d[d\�Z0d]S)^�UrlParseTestCasecCs`tj�|�}|�||�|j|j|j|j|j|j	f}|�||�tj�
|�}|�||�|�||���tj�|���}|�|��|���|�||�|�|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j	|j	�|�|j|j�|�|j
|j
�|�|j|j�|�|j|j�tj�|�}|�||�|j|j|j|j|j	f}|�||�tj�|�}|�||�|�||���tj�|���}|�|��|���|�||�|�|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�rC�//usr/local/lib/python3.10/test/test_urlparse.py�checkRoundtripsIsV��z UrlParseTestCase.checkRoundtripscCsdtD]-\}}tjj|dd�}|�||d|�dd�|D�}tjj|dd�}|�||d|�qdS)NT��keep_blank_values�Error parsing %rcSsg|]
}t|d�r|�qS)���len��.0�vrCrCrD�
<listcomp>�sz-UrlParseTestCase.test_qsl.<locals>.<listcomp>F)�parse_qsl_test_casesr+r,�	parse_qslr.)r=�orig�expectrA�expect_without_blanksrCrCrD�test_qsl|s��zUrlParseTestCase.test_qslcshtD]/\}�tjj|dd�}|�|�d|��fdd��D�}tjj|dd�}|�||d|�qdS)NTrFrHcs&i|]}t�|d�r|�|�qS)rrJrL�rSrCrD�
<dictcomp>�s�z,UrlParseTestCase.test_qs.<locals>.<dictcomp>F)�parse_qs_test_casesr+r,�parse_qsr.)r=rRrArTrCrVrD�test_qs�s
���zUrlParseTestCase.test_qscsHgd�}dd���fdd�|D�}||D]\}}}|�|||�qdS)N))zfile:///tmp/junk.txt)�filer�
/tmp/junk.txtrrr)r[rr\rr)zimap://mail.python.org/mbox1)�imap�mail.python.org�/mbox1rrr)r]r^r_rr)z1mms://wms.sys.hinet.net/cts/Drama/09006251100.asf)�mms�wms.sys.hinet.net�/cts/Drama/09006251100.asfrrr)r`rarbrr)znfs://server/path/to/file.txt)�nfs�server�/path/to/file.txtrrr)rcrdrerr)z0svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/)�svn+ssh�svn.zope.org�/repos/main/ZConfig/trunk/rrr)rfrgrhrr)z)git+ssh://git@github.com/user/project.git)�git+ssh�git@github.com�/user/project.gitrrr)rirjrkrrcS�8|d�d�tdd�|dD��tdd�|dD��fS)Nr�asciics��|]}|�d�VqdS�rmN��encode�rM�xrCrCrD�	<genexpr>���zDUrlParseTestCase.test_roundtrips.<locals>._encode.<locals>.<genexpr>rIcsrnrorprrrCrCrDrt�ru��rq�tuple�rBrCrCrD�_encode���z1UrlParseTestCase.test_roundtrips.<locals>._encodec�g|]}�|��qSrCrCrr�rzrCrDrO��z4UrlParseTestCase.test_roundtrips.<locals>.<listcomp>�rE)r=�	str_cases�bytes_casesr>r?r@rCr}rD�test_roundtrips�s�z UrlParseTestCase.test_roundtripsc
s�gd�}dd���fdd�|D�}d}d}||f}||f}||fD]&\}}|D]}	|D]\}
}}|	|
}
|	f|}|	f|}|�|
||�q+q'q!dS)N))z://www.python.org)�www.python.orgrrrr)r�rrr)z://www.python.org#abc)r�rrr�abc)r�rrr�)z://www.python.org?q=abc)r�rr�q=abcr)r�rr�r)z://www.python.org/#abc)r��/rrr�)r�r�rr�)z://a/b/c/d;p?q#f)rz/b/c/d�p�q�f)rz/b/c/d;pr�r�cSrl)NrrmcsrnrorprrrCrCrDrt�ruzIUrlParseTestCase.test_http_roundtrips.<locals>._encode.<locals>.<genexpr>rIcsrnrorprrrCrCrDrt�rurvrwryrCrCrDrz�r{z6UrlParseTestCase.test_http_roundtrips.<locals>._encodecr|rCrCrrr}rCrDrO�r~z9UrlParseTestCase.test_http_roundtrips.<locals>.<listcomp>)�http�https)�http�httpsr)
r=r�r�Zstr_schemesZ
bytes_schemesZ	str_testsZbytes_testsZschemesZ
test_casesr/r>r?r@rCr}rD�test_http_roundtrips�s"

���z%UrlParseTestCase.test_http_roundtripsc	CsR|||f}|�tj�||�|�dd�|D�}\}}}|�tj�||�|�dS)NcS�g|]}|�d��qS�rmrprrrCrCrDrO�s
�z.UrlParseTestCase.checkJoin.<locals>.<listcomp>)r.r+r,�urljoin)	r=�baseZrelurl�expectedZstr_componentsZbytes_componentsZbasebZrelurlbZ	expectedbrCrCrD�	checkJoin�s
�zUrlParseTestCase.checkJoincCs`gd�}dd�|D�}||D]}|�tj�tj�|��|�|�tj�tj�|��|�qdS)N)�Pythonz./Python�x-newscheme://foo.com/stuffzx://yzx:/yzx:/r�cSr�r�rprrrCrCrDrO��z7UrlParseTestCase.test_unparse_parse.<locals>.<listcomp>)r.r+r,r<r;r5r-)r=r�r��urCrCrD�test_unparse_parse�s�z#UrlParseTestCase.test_unparse_parsecCs�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�td	d
�|�tdd�|�td
d�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�td d�|�td!d"�|�td#d$�|�td%d$�|�td&d�|�td'd(�|�td)d*�|�td+d,�|�td-d.�|�td/d0�|�td1d"�|�td2d�|�td3d4�|�td5d6�dS)7N�g:h�g�http://a/b/c/g�./g�g/�http://a/b/c/g/�/g�
http://a/g�//g�http://g�g?y�http://a/b/c/g?y�g?y/./x�http://a/b/c/g?y/./x�#s�http://a/b/c/d;p?q#s�g#s�http://a/b/c/g#s�g#s/./x�http://a/b/c/g#s/./x�g?y#s�http://a/b/c/g?y#s�g;x�http://a/b/c/g;x�g;x?y#s�http://a/b/c/g;x?y#s�.�
http://a/b/c/�./�..�http://a/b/�../�../g�http://a/b/g�../..�	http://a/�../../�../../grr�g.�http://a/b/c/g.�.g�http://a/b/c/.g�g..�http://a/b/c/g..�..g�http://a/b/c/..g�./../g�./g/.�g/./h�http://a/b/c/g/h�g/../h�http://a/b/c/h)r��RFC1808_BASE�r=rCrCrD�test_RFC1808�s>zUrlParseTestCase.test_RFC1808cCs|�tj�d�d�dS)Nzmailto:1337@example.org)�mailtorz1337@example.orgrrr�r.r+r,r-r�rCrCrD�test_RFC2368s�zUrlParseTestCase.test_RFC2368cCs�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�td	d
�|�tdd�|�td
d�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd �|�td!d �|�td"d�|�td#t�|�td$d%�|�td&d'�|�td(d)�|�td*d+�|�td,d�|�td-d�|�td.d/�|�td0d1�|�td2d3�|�td4d5�|�td6d7�|�td8d9�|�td:d;�|�td<d=�dS)>Nr�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�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r��	g;x=1/./y�http://a/b/c/g;x=1/y�
g;x=1/../y�http://a/b/c/yr�r��g?y/../x�http://a/b/c/g?y/../xr�r��g#s/../x�http://a/b/c/g#s/../x)r��RFC2396_BASEr�rCrCrD�test_RFC2396sFzUrlParseTestCase.test_RFC2396cCs�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�td	d
�|�tdd�|�td
d�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�td d!�|�td"d!�|�td#d$�|�td%d&�|�td'd&�|�td(d�|�td)d�|�td)d�|�td*d�|�td+d�|�td,d�|�td-d.�|�td/d0�|�td1d2�|�td3d4�|�td5d$�|�td6d
�|�td7d8�|�td9d:�|�td;d<�|�td=d>�|�td?d@�|�tdAdB�|�tdCdD�|�tdEdF�|�tdGd�|�dHdd�dS)IN�?yzhttp://a/b/c/d;p?yz;xzhttp://a/b/c/;xr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�r�r�r�r�r�r�r�r�r�r�z
../../../gz
../../../../gz/./gz/../gr�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��http:gzhttp://a/b/c/de)r��RFC3986_BASEr�rCrCrD�test_RFC3986Hs\zUrlParseTestCase.test_RFC3986cCsX|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd	�|�td
d�|�tdd
�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�tdd�|�td d	�|�td!d"�|�td#d$�|�tdd�|�tdd�|�td%d�|�td&d�|�td'd�|�d(dd(�|�d)dd�|�d)d*d*�|�d+d,d-�|�d.d,d/�|�d0dd1�|�d2dd3�|�td4d5td6�|�d7d8d9�|�d:d8d;�|�d7d<d=�|�d:d<d=�|�d7d>d?�|�dd8d=�|�d@dAdA�dS)BNr�r�r��http:rr�r�r�r�r�r�r�r�r�zhttp://a/b/c/d?yr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�zhttp:?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/gr��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_BASEr�rCrCrD�
test_urljoins�sTzUrlParseTestCase.test_urljoinscs�gd�}dd���fdd�|D�}||D]\}}}tj�|�}|�|j|jf||f�qgd�}dd�|D�}||D]}|�ttjj|�q<dS)N))z http://Test.python.org:5432/foo/�test.python.org�8)zhttp://12.34.56.78:5432/foo/�12.34.56.78r�)zhttp://[::1]:5432/foo/�::1r�)zhttp://[dead:beef::1]:5432/foo/�dead:beef::1r�)zhttp://[dead:beef::]:5432/foo/�dead:beef::r�)z:http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/�'dead:beef:cafe:5417:affe:8fa3:deaf:feedr�)z http://[::12.34.56.78]:5432/foo/�
::12.34.56.78r�)z%http://[::ffff:12.34.56.78]:5432/foo/�::ffff:12.34.56.78r�)zhttp://Test.python.org/foo/r�N)zhttp://12.34.56.78/foo/r�N)zhttp://[::1]/foo/r�N)zhttp://[dead:beef::1]/foo/r�N)zhttp://[dead:beef::]/foo/r�N)z5http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/r�N)zhttp://[::12.34.56.78]/foo/r�N)z http://[::ffff:12.34.56.78]/foo/r�N)zhttp://Test.python.org:/foo/r�N)zhttp://12.34.56.78:/foo/r�N)zhttp://[::1]:/foo/r�N)zhttp://[dead:beef::1]:/foo/r�N)zhttp://[dead:beef::]:/foo/r�N)z6http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:/foo/r�N)zhttp://[::12.34.56.78]:/foo/r�N)z!http://[::ffff:12.34.56.78]:/foo/r�NcSs"|d�d�|d�d�|dfS)NrrmrIrvrpryrCrCrDrz�s"z.UrlParseTestCase.test_RFC2732.<locals>._encodecr|rCrCrrr}rCrDrO�r~z1UrlParseTestCase.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.78cSr�r�rprrrCrCrDrO�r�)r+r,r-r.r9r:�assertRaises�
ValueError)r=r�r�r>r9r:Z	urlparsedZinvalid_urlrCr}rD�test_RFC2732�s �zUrlParseTestCase.test_RFC2732cs�ddddddddtd	d
ftd	dfg
}dd
���fdd�|D�}||D])\}}}tj�|�}|�|��|�|�|||f�|�|j|�|�|j|�q#dS)N)zhttp://python.org#frag�http://python.org�frag)r�r�r)zhttp://python.org/#frag�http://python.org/r�)r�r�r)zhttp://python.org/?q#frag�http://python.org/?qr�)r�r�r)zhttp://python.org/p#fragzhttp://python.org/pr�)�http://python.org/p?qr�rrr�rcSst|�dd�|D��S)NcsrnrorprrrCrCrDrt�ruzCUrlParseTestCase.test_urldefrag.<locals>._encode.<locals>.<genexpr>)�typeryrCrCrDrz�sz0UrlParseTestCase.test_urldefrag.<locals>._encodecr|rCrCrrr}rCrDrO�r~z3UrlParseTestCase.test_urldefrag.<locals>.<listcomp>)	r�r�r+r,�	urldefragr.r6r>r4)r=r�r�r>�defragr�rArCr}rD�test_urldefrag�s(��zUrlParseTestCase.test_urldefragcCsTtj�d�}|�|jd�|�|jd�tj�d�}|�|jd�|�|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)r+r,r;r.r9r0)r=r�rCrCrD�test_urlsplit_scoped_IPv6sz*UrlParseTestCase.test_urlsplit_scoped_IPv6cCsd}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|jd�|�|�
�dd�|dd��d	}tj�|�}|�|jd�|�|jd
�|�|jd�|�|jd�|�|jd�|�|j	d�|�|j
d
�|�|jd�|�|jd�|�|�
�|�d}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j	d�|�|j
d
�|�|jd�|�|jd�|�|�
�|�d}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|jd�|�|�
�dd�|dd��d}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|jd�|�|�
�|�d}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j	d �|�|j
d�|�|jd�|�|jd�|�|�
�|�d!}tj�|�}|�td"��|jWd�dS1�swYdS)#NzHTTP://WWW.PYTHON.ORG/doc/#fragr�zWWW.PYTHON.ORG�/doc/rr�r���7http://User:Pass@www.python.org:080/doc/?query=yes#frag�User:Pass@www.python.org:080�	query=yes�User�Pass�PzChttp://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag�(User@example.com:Pass@www.python.org:080zUser@example.comsHTTP://WWW.PYTHON.ORG/doc/#fragr�sWWW.PYTHON.ORG�/doc/r�frag�www.python.orgs7http://User:Pass@www.python.org:080/doc/?query=yes#frag�User:Pass@www.python.org:080�	query=yes�User�PasssChttp://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)r+r,r;r.r/r0r1r3r4r7r8r9r:r6�assertRaisesRegexr�)r=r>r�rCrCrD�test_urlsplit_attributes
s�  $�z)UrlParseTestCase.test_urlsplit_attributescCs�d}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|jd�|�|�
�d�d}tj�|�}|�|jd	�|�|jd
�|�|jd�|�|jd�|�|jd
�|�|j	d�|�|j
d�|�|jd
�|�|jd�|�|�
�d�d}d}td�D]}tjj||d�}|�|jd�|�|�
�d�q�dS)NzQhttp	://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentr�r�z/javascript:alert('msg')/zquery=somethingr4zGhttp://www.python.org/javascript:alert('msg')/?query=something#fragmentsQhttp	://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentr�rs/javascript:alert('msg')/squery=something�fragmentsGhttp://www.python.org/javascript:alert('msg')/?query=something#fragmentzNhttp://www.python.org/java
script:	alert('msg
')/?query
=	something#frag
mentzht
tprv�r/)r+r,r;r.r/r0r1r3r4r7r8r9r:r6�range)r=r>r�r/�_rCrCrD�!test_urlsplit_remove_unsafe_bytesgs>�z2UrlParseTestCase.test_urlsplit_remove_unsafe_bytescCsVttdd��}d}|�d�|}tj�|�}|�|jd�|�|jd�|�|j	d�|�|j
d�|�|jd	�|�|jd
�|�|j
d�|�|jd�|�|jd
�|�|��|�||�d�}tj�|�}|�|jd�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|jd�|�|j
d�|�|jd�|�|jd
�|�|��|�d��d}tj�|�d�|�}|�|jd�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|��|�tj�d�}|�tj�|�d�d}|�d�d|�d�}td�D]}tjj||d�}|�|jd�|�|��d��qdS) Nr�!r��utf-8r�r�r�rr�rrr�rr�rrr	rr
rrz)https://www.python.org:88/doc/?query=    r�zwww.python.org:88z
query=    �Xz
www.pypi.org z//www.python.org/rvrzhttps://www.python.org/)�bytesr�decoder+r,r;r.r/r0r1r3r4r7r8r9r:r6rqr<)r=ZnoiseZbase_urlr>r�Zquery_spaces_urlr/rrCrCrD�test_urlsplit_strip_url�sV�z(UrlParseTestCase.test_urlsplit_strip_urlcCs�	dD]t}tjjtjjfD]i}dD]d}|j|||d��Rd|}d|d}|rC|��r;|��r;|�d�}|�d�}n	Wd�q||�}|�|j|�|�	t
��|jWd�n1sawYWd�n1spwYqq
qdS)N)FT)	r�z1.5z-1Z0x10z-0Z1_1z 1z1 u६)rr,r:zwww.example.net:zhttp://r�rm)r+r,r;r-�subTest�isasciirqr.r0r�r�r:)r=rr,r:r0r>r�rCrCrD�test_attributes_bad_port�s0
�	�������z)UrlParseTestCase.test_attributes_bad_portcCs�d}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|�	�|�tj�
|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|�	�|�d}tj�|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|�	�|�tj�
|�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|�	�|�dS)Nz0sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15rs0sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15r)r+r,r;r.r0r7r8r9r:r6r-)r=Zurir�rCrCrD�test_attributes_without_netloc�s<z/UrlParseTestCase.test_attributes_without_netloccCs,|�tj�d�d�|�tj�d�d�dS)Nz http://example.com?blahblah=/foo)r�zexample.comrrz
blahblah=/foors http://example.com?blahblah=/foo)r�sexample.comrrs
blahblah=/foorr�r�rCrCrD�test_noslashs��zUrlParseTestCase.test_noslashcCs||�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d	�d
�|�tj�d�d�dS)
Nr1)rrr1rrrz//www.python.org:80)r�www.python.org:80rrrr�http://www.python.org:80�r�rrrrr�path)rrr!rrrs//www.python.org:80)r�www.python.org:80rrrr�http://www.python.org:80�r�r"rrrrr�r�rCrCrD�test_withoutscheme
s$������z#UrlParseTestCase.test_withoutschemecCs�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d	�d
�|�tj�d�d�|�tj�d
�d�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d�d�dS)Nzhttp:80)r�r�80rrrzhttps:80)r�rr&rrrzpath:80)r1rr&rrrr�)r�rrrrrzhttps:)r�rrrrrrr shttp:80)r�r�80rrrshttps:80)r�rr'rrrspath:80)r!rr'rrrshttp:)r�rrrrrshttps:)r�rrrrrr#r$r�r�rCrCrD�test_portseparators ��z#UrlParseTestCase.test_portseparatorcCs|�ttjjd�dS)Nr�)r��	TypeErrorr+r,�	urlencoder�rCrCrD�
test_usingsys/szUrlParseTestCase.test_usingsyscCs�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d	�d
�|�tj�d�d�|�tj�d
�d�|�tj�d�d�dS)Nzs3://foo.com/stuff)Zs3�foo.com�/stuffrrrr�)�x-newschemer,r-rrrz*x-newscheme://foo.com/stuff?query#fragment)r.r,r-rr3r4z!x-newscheme://foo.com/stuff?query)r.r,r-rr3rss3://foo.com/stuff)ss3�foo.com�/stuffrrrsx-newscheme://foo.com/stuff)�x-newschemer/r0rrrs*x-newscheme://foo.com/stuff?query#fragment)r1r/r0r�queryrs!x-newscheme://foo.com/stuff?query)r1r/r0rr2rr�r�rCrCrD�test_anyscheme3s0��������zUrlParseTestCase.test_anyschemec	Cs�tjjtjjfD]l}|j|d��\|dd�}|�|jd�|dd�}|�|jd�|�|dd�jd�|�|ddd	�jd�|�|d
dd	�jd�|�|d�jd�|�|d
�jd�|�|d
d�jd�Wd�n1sowYqdS)
N)�functionzhttp://example.net/�ftpr�shttp://example.net/sftpr�r1rr!rr)r+r,r-r;rr.r/)r=�funcrArCrCrD�test_default_schemeHs

���z$UrlParseTestCase.test_default_schemec
Csd}|D]�\}}}tjjtjjfD]v}|dkr|tjjurd}|j||d��Y||dd�}|�|jd�|�t||��	d|��|�||dd�jd�||d	d�}|�|j|�|�
t||��	|��|�||dd	�j|�|�||�j|�Wd�n1s�wYqqdS)
N)
)z
http:#fragr1r�)z//example.net#fragr1r�)zindex.html#fragr1r�)z	;a=b#fragr2r�)z	?a=b#fragr3r�)z#fragr1r�)z	abc#@fragr1�@frag)z//abc#@fragr1r8)z//abc:80#@fragr1r8)z//abc#@frag:80r1z@frag:80r2r1)r>r4F)�allow_fragmentsr�#T)r+r,r-r;rr.r4Z
assertTrue�getattr�endswithZassertFalse)r=Ztestsr>�attrZ
expected_fragr6rArCrCrD�test_parse_fragmentsWs2�������z%UrlParseTestCase.test_parse_fragmentscCsD|�td��tj�dd�Wd�n1swY|�td��tj�dd�Wd�n1s5wY|�td��tj�dd�Wd�n1sRwY|�td��tj�dd�Wd�n1sowY|�td��tj�d�Wd�n1s�wY|�td��tj�d�Wd�n1s�wY|�td��tj�d�Wd�n1s�wY|�td��tj�d	�Wd�n1s�wY|�td��tj�d
d�Wd�n1s�wY|�td��tj�dd
�Wd�dS1�swYdS)NzCannot mix strr�r�rr�)r�r�rrrr)r�rrrrr)r�r�rrr)r�rrrrr�shttp://python.org)	rr)r+r,r-r;r5r<r�r�rCrCrD�test_mixed_types_rejectedxs<���������$�z*UrlParseTestCase.test_mixed_types_rejectedc
Cs:t|j�}|j}|�|j|�d|}d|}||�}||�}d}d}	|�||�|�|��|�|�|��|�|�|�|�|�|�|�|�|�|�|�||	�|�|�|�||	�|�|�||�|�|��|�|�|��|�|�|�|�|�|�|�|�|�|�|�||	�|�|�|�||	�|�dS)N)r)rrm�strict)rK�_fields�_encoded_counterpartZassertIs�_decoded_counterpartr.rrq)
r=Zstr_typeZnum_argsZ
bytes_typeZstr_argsZ
bytes_argsZ
str_resultZbytes_result�encoding�errorsrCrCrD�_check_result_type�s.
z#UrlParseTestCase._check_result_typecCs.tjjtjjtjjg}|D]}|�|�q
dSr*)r+r,�DefragResult�SplitResult�ParseResultrF)r=Zresult_typesZresult_typerCrCrD�test_result_pairs�s��z"UrlParseTestCase.test_result_pairscCs�tjjddd�}|�|ddgi�tjjddd�}|�|ddgi�tjjddd�}|�|dd	gi�tjjd
dd�}|�|ddgi�tjjd
ddd
�}|�|ddgi�dS)N�	key=Ł%E9�latin-1�rD�key�Łé�key=Ł%C3%A9rrm�Ł���
key=Ł%E9-�Ł�-�ignore�rDrE�Ł-)r+r,rYr.�r=rArCrCrD�test_parse_qs_encoding�s
�z'UrlParseTestCase.test_parse_qs_encodingcCs�tjjddd�}|�|dg�tjjddd�}|�|dg�tjjddd�}|�|dg�tjjd	dd�}|�|d
g�tjjd	ddd�}|�|d
g�dS)NrKrLrM)rNrOrPrrm)rNrQrR)rNrSrTrU)rNrV)r+r,rQr.rWrCrCrD�test_parse_qsl_encoding�s
�z(UrlParseTestCase.test_parse_qsl_encodingcCsf|�t��tjjd�dgd�dd�Wd�n1swYtjjd�dgd�dd�dS)Nrza=a��
)�max_num_fields)r�r�r+r,rY�joinr�rCrCrD�test_parse_qsl_max_num_fields�s� z.UrlParseTestCase.test_parse_qsl_max_num_fieldsc
Cs�difdifdddgifddgdgd	�fd
dddgifd
ifdifdddgifddgdgd�fddddgifg
}|D]A\}}|�d|�d|����*tjj|dd�}|�||d|�tjj|d
d�}|�||d|�Wd�n1svwYq:dS)N�;�;;r!rr
r#rrr	�a=1;a=2rr�;�;;r%rrr'rrr�a=1;a=2rr �
Original: �, Expected: ��	separatorrH)rr+r,rYr.)r=Zparse_qs_semicolon_casesrRrSrA�result_bytesrCrCrD�test_parse_qs_separator�s(����z(UrlParseTestCase.test_parse_qs_separatorcCs�dgfdgfddgfdddgfdd	d
gfdgfdgfd
dgfdddgfdddgfg
}|D]A\}}|�d|�d|����*tjj|dd�}|�||d|�tjj|dd�}|�||d|�Wd�n1shwYq,dS)Nr_r`r!r	r#rr
rarrrbrcr%rr'rrrdrrrerfrgrH)rr+r,rQr.)r=Zparse_qsl_semicolon_casesrRrSrArirCrCrD�test_parse_qsl_separator�s(



����z)UrlParseTestCase.test_parse_qsl_separatorcCsJtj�ddgdd�d�}Gdd�d�}tj�d|�id�}|�|d	�dS)
NrIrv)�r��r	Tc@seZdZdd�ZdS)z:UrlParseTestCase.test_urlencode_sequences.<locals>.TrivialcSsdS)NZtrivialrCr�rCrCrD�__str__szBUrlParseTestCase.test_urlencode_sequences.<locals>.Trivial.__str__N)�__name__�
__module__�__qualname__rnrCrCrCrD�Trivialsrrrz	a=trivial)r+r,r*r.)r=rArrrCrCrD�test_urlencode_sequences�sz)UrlParseTestCase.test_urlencode_sequencescCsjtj�ddi�}|�|d�tjjdditjjd�}|�|d�tjjddidtjjd�}|�|d	�dS)
Nrz
some valueza=some+valuezsome value/another)�	quote_viaza=some%20value%2Fanotherr�)�safertza=some%20value/another)r+r,r*r.�quoterWrCrCrD�test_urlencode_quote_via
s��z)UrlParseTestCase.test_urlencode_quote_viacCsF|�ttjjd�tj�d�}|�|d�tj�d�}|�|d�dS)Nr�sarchaeological arcanazarchaeological%20arcanarr)r�r)r+r,�quote_from_bytesr.rWrCrCrD�test_quote_from_bytess
z&UrlParseTestCase.test_quote_from_bytescCs4tj�d�}|�|d�tj�d�}|�|d�dS)Nz	abc%20defsabc defrr)r+r,�unquote_to_bytesr.rWrCrCrD�test_unquote_to_bytessz&UrlParseTestCase.test_unquote_to_bytescCs0|jttjjddd�|jttjjddd�dS)NsfoorrMr@)rE)r�r)r+r,rvr�rCrCrD�test_quote_errors!s�z"UrlParseTestCase.test_quote_errorscCs�tj�d�}|�|jd�|�|jd�tj�d�}|�|jd�|�|jd�tj�d�}|�|jd�|�|jd�tj�d�}|�|jd�|�|jd�dS)Nztel:+31-641044153�telz
+31-641044153ztel:+31641044153z+31641044153)r+r,r;r.r/r1r-)r=�p1�p2rCrCrD�test_issue14072&sz UrlParseTestCase.test_issue14072cCs�d}tj�d�}|�t|��|jWd�n1swYtj�d�}|�t|��|jWd�dS1s<wYdS)Nz3Port could not be cast to integer value as 'oracle'z%http://Server=sde; Service=sde:oracle)r+r,r-rr�r:r;)r=�messager~rrCrCrD�!test_port_casting_failure_message5s�"�z2UrlParseTestCase.test_port_casting_failure_messagecCs�tj�d�}|�|jd�|�|jd�|�|jd�tj�d�}|�|jd�|�|jd�|�|jd�tj�d�}|�|jd�|�|jd	�|�|jd
�tj�d�}|�|jd�|�|jd�|�|jd
�dS)Nz"tel:123-4;phone-context=+1-650-516r}z123-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)r+r,r-r.r/r1r2)r=r~rCrCrD�test_telurl_params?s z#UrlParseTestCase.test_telurl_paramscCs$tj�tjj�}|�dt|��dS)N�Quoter)r+r,r��_ALWAYS_SAFE�assertIn�repr)r=�quoterrCrCrD�test_Quoter_reprTsz!UrlParseTestCase.test_Quoter_reprcCsjg}hd�}ttj�D]}|�d�s||vrqttj|�}t|dd�dkr*|�|�q|�tjj|�dS)N>�splitpasswd�
splitvalue�clear_cache�splittag�	splituser�	splittype�unwrap�
splitquery�to_bytes�	splitattr�
ResultBase�	splithost�	splitport�
splitnportr�rrpzurllib.parse)�dirr+r,�
startswithr;�appendZassertCountEqual�__all__)r=r�Zundocumented�name�objectrCrCrD�test_allXs
�zUrlParseTestCase.test_allcs0d�dd��D����fdd�tttdtj��D�}|�d|�|�d|�tj�d	�|�	t
��tj�d
�Wd�n1sBwYdD]L}dD]G}|D]B}d
�||�|��}|j|d�t
|��d��#|�	t
��tj�|�Wd�n1swYWd�n1s�wYqQqMqIdS)Nz/:#?@cSsh|]	}d�t|���qS)�{:04X})�format�ord�rM�crCrCrD�	<setcomp>msz?UrlParseTestCase.test_urlsplit_normalization.<locals>.<setcomp>cs.g|]}�tt�|����@r|�vr|�qSrC)�set�unicodedataZ
decompositionr@r��Z	hex_charsZ
illegal_charsrCrDrOns��z@UrlParseTestCase.test_urlsplit_normalization.<locals>.<listcomp>�u℀u#uhttp://プ:80uhttp://プ︓80)r�r�r5)znetloc{}false.netloczn{}user@netlocz{}://{}/pathr�)r>�char)�map�chrr�sys�
maxunicoder�r+r,r;r�r�r�rr�)r=Zdenorm_charsr/r0r�r>rCr�rD�test_urlsplit_normalizationhs2���������z,UrlParseTestCase.test_urlsplit_normalizationN)1rorprqrErUrZr�r�r�r�r�r�r�r�r�r�r�r�r
rrrrrr%r(r+r3r7r>r?rFrJrXrYr^rjrkrsrwryr{r|r�r�r�r�r�r�rCrCrCrDr)Gs^3	
#&0-972	]%;)!




r)c@sneZdZ	dd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
Utility_TestscC�\tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�dS)Nztype:opaquestring)r��opaquestringr�)Nr��
:opaquestring)Nr�ztype:)r�rztype:opaque:string)r�z
opaque:string)r+r,�
_splittyper.)r=r�rCrCrD�test_splittype�szUtility_Tests.test_splittypecCs�tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�|�|d�d�|�|d
�d�|�|d�d�|�|d�d�|�|d�d�dS)Nz%//www.example.org:80/foo/bar/baz.html)�www.example.org:80�/foo/bar/baz.htmlz//www.example.org:80)r�rr�)Nr�z//127.0.0.1#@host.com)�	127.0.0.1�/#@host.comz//127.0.0.1#@host.com:80)r�z/#@host.com:80z//127.0.0.1:80#@host.com)z127.0.0.1:80r�z///file)rz/filez//example.net/file;)�example.netz/file;z//example.net/file?)r�z/file?z//example.net/file#)r�z/file#)r+r,�
_splithostr.)r=r�rCrCrD�test_splithost�s>
�
�
�
�
�
�
�
�
�
�zUtility_Tests.test_splithostcCr�)Nr�)�	User:Pass�www.python.org:080z@www.python.org:080)rr�r�)Nr�z
User:Pass@)r�rr)zUser@example.com:Passr�)r+r,�
_splituserr.)r=r�rCrCrD�test_splituser�s 
�
�
�
�
�zUtility_Tests.test_splitusercCs�tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�|�|d�d�|�|d
�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�dS)Nzuser:ab)�user�abzuser:a
b)r�za
bzuser:a	b)r�za	bzuser:a
b)r�za
bzuser:ab)r�zabzuser:ab)r�zabzuser:a:b)r�za:bzuser:a b)r�rz	user 2:ab)zuser 2r�z
user+1:a+b)zuser+1za+bzuser:)r�rr�)r�Nz:ab)rr�)r+r,�_splitpasswdr.)r=r�rCrCrD�test_splitpasswd�szUtility_Tests.test_splitpasswdcCs�tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d	�|�|d
�d�|�|d�d
�|�|d�d�dS)N�	parrot:88)�parrot�88r��r�N�parrot:r�)r�N�
parrot:cheese)r�Nz[::1]:88)�[::1]r�r�)r�Nz:88)rr�)r+r,�
_splitportr.)r=r�rCrCrD�test_splitport�szUtility_Tests.test_splitportcCs�tjj}|�|d�d�|�|d�d�|�|dd�d�|�|d�d�|�|dd�d�|�|d�d	�|�|dd�d
�|�|d�d�|�|dd�d�|�|d
�d�dS)Nr�)r�rr�)r�����7)r�r�r�r�)r�r�)r�r�r�r�z
parrot: +1_0 )r+r,�_splitnportr.)r=r�rCrCrD�test_splitnport�szUtility_Tests.test_splitnportcCsLtjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�dS)	N�http://python.org/fake?foo=bar)�http://python.org/fake�foo=barzhttp://python.org/fake?foo=bar?)r�rr�)r�Nz?foo=bar)rr�)r+r,�_splitqueryr.)r=r�rCrCrD�test_splitquery�s
�
�
�zUtility_Tests.test_splitquerycCr�)N�http://example.com?foo=bar#baz)�http://example.com?foo=bar�bazzhttp://example.com?foo=bar#)r�rz#baz)rr�r�)r�Nz"http://example.com?foo=bar#baz#boo)r�Zboo)r+r,�	_splittagr.)r=r�rCrCrD�
test_splittag�s
�
�
�
�zUtility_Tests.test_splittagcCsftjj}|�|d�dddgf�|�|d�ddgf�|�|d�dddgf�|�|d�dgf�dS)Nz/path;attr1=value1;attr2=value2z/pathzattr1=value1zattr2=value2z/path;rz;attr1=value1;attr2=value2)r+r,�
_splitattrr.)r=r�rCrCrD�test_splitattr�s

�

�zUtility_Tests.test_splitattrcCr�)Nr�)r��barzfoo=)r�rz=bar)rr��foobar)r�Nzfoo=bar=baz)r�zbar=baz)r+r,�_splitvaluer.)r=r�rCrCrD�test_splitvalueszUtility_Tests.test_splitvaluecCs.tj�d�}|�|d�|�ttjjd�dS)Nzhttp://www.python.orguhttp://www.python.org/mediæval)r+r,�	_to_bytesr.r��UnicodeErrorrWrCrCrD�
test_to_bytess
�zUtility_Tests.test_to_bytescCs&dD]}tj�|�}|�|d�qdS)N)z<URL:scheme://host/path>z<scheme://host/path>zURL:scheme://host/path�scheme://host/pathr�)r+r,r�r.)r=Zwrapped_urlr>rCrCrD�test_unwraps�zUtility_Tests.test_unwrapN)rorprqr�r�r�r�r�r�r�r�r�r�r�r�rCrCrCrDr��s

	
r�c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�DeprecationTestcC�L|�t��}tj�d�Wd�n1swY|�t|j�d�dS)NrzUurllib.parse.splittype() is deprecated as of 3.8, use urllib.parse.urlparse() instead)�assertWarns�DeprecationWarningr+r,r�r.�str�warning�r=�cmrCrCrD�test_splittype_deprecation���z*DeprecationTest.test_splittype_deprecationcCr�)NrzUurllib.parse.splithost() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splithost_deprecation&r�z*DeprecationTest.test_splithost_deprecationcCr�)NrzUurllib.parse.splituser() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splituser_deprecation-r�z*DeprecationTest.test_splituser_deprecationcCr�)NrzWurllib.parse.splitpasswd() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splitpasswd_deprecation4r�z,DeprecationTest.test_splitpasswd_deprecationcCr�)NrzUurllib.parse.splitport() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splitport_deprecation;r�z*DeprecationTest.test_splitport_deprecationcCr�)NrzVurllib.parse.splitnport() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splitnport_deprecationBr�z+DeprecationTest.test_splitnport_deprecationcCr�)NrzVurllib.parse.splitquery() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splitquery_deprecationIr�z+DeprecationTest.test_splitquery_deprecationcCr�)NrzTurllib.parse.splittag() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splittag_deprecationPr�z)DeprecationTest.test_splittag_deprecationcCr�)NrzUurllib.parse.splitattr() is deprecated as of 3.8, use urllib.parse.urlparse() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splitattr_deprecationWr�z*DeprecationTest.test_splitattr_deprecationcCr�)NrzWurllib.parse.splitvalue() is deprecated as of 3.8, use urllib.parse.parse_qsl() instead)r�r�r+r,r�r.r�r�r�rCrCrD�test_splitvalue_deprecation^r�z+DeprecationTest.test_splitvalue_deprecationcCr�)Nrz/urllib.parse.to_bytes() is deprecated as of 3.8)r�r�r+r,r�r.r�r�r�rCrCrD�test_to_bytes_deprecationer�z)DeprecationTest.test_to_bytes_deprecationN)rorprqr�r�r�r�r�r�r�r�r�r�r�rCrCrCrDr�sr��__main__)r�r�Zunittest�urllib.parser+r�r�r�r�rPrXZTestCaser)r�r�ro�mainrCrCrCrD�<module>s�



��F
O�