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.7/test/__pycache__/test_urlparse.cpython-37.pyc
B

��g��@s6ddlZddlZddlZddlZdZdZdZdZdgfdgfdgfdd	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
edCk�r2e��dS)D�Nzhttp://a/b/c/d;p?q#fzhttp://a/b/c/d;p?qzhttp://a/b/c/d��&z&&�=)rrz=a)r�ar)rrza=z&a=b)r�bza=a+b&b=b+c)rza b)rzb cza=1&a=2)r�1)r�2��&s&&�=)r	r	s=a)r	�ar)rr	sa=s&a=b)r�bsa=a+b&b=b+c)rsa b)r
sb csa=1&a=2)r�1)r�2z;a=b)z;arza=a+b;b=b+c)rz	a b;b=b cs;a=b)s;ar
sa=a+b;b=b+c)rs	a b;b=b crza bzb crrr
sa bsb crrz;az	a b;b=b cs;as	a b;b=b cc@sleZdZdd�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.dYS)Z�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�r)�./usr/local/lib/python3.7/test/test_urlparse.py�checkRoundtripsIsRz UrlParseTestCase.checkRoundtripscCshxbtD]Z\}}tjj|dd�}|�||d|�dd�|D�}tjj|dd�}|�||d|�qWdS)NT)�keep_blank_valueszError parsing %rcSsg|]}t|d�r|�qS)�)�len)�.0�vr)r)r*�
<listcomp>�sz-UrlParseTestCase.test_qsl.<locals>.<listcomp>F)�parse_qsl_test_casesrr�	parse_qslr)r#�orig�expectr'�expect_without_blanksr)r)r*�test_qsl|szUrlParseTestCase.test_qslcslxftD]^\}�tjj|dd�}|�|�d|��fdd��D�}tjj|dd�}|�||d|�qWdS)NT)r,zError parsing %rcs&i|]}t�|d�r�||�qS)r)r.)r/r0)r5r)r*�
<dictcomp>�sz,UrlParseTestCase.test_qs.<locals>.<dictcomp>F)�parse_qs_test_casesrr�parse_qsr)r#r4r'r6r))r5r*�test_qs�s
zUrlParseTestCase.test_qscsTddddddg}dd���fd	d
�|D�}x$||D]\}}}|�|||�q4WdS)N)zfile:///tmp/junk.txt)�filerz
/tmp/junk.txtrrr)r<rz
/tmp/junk.txtrr)zimap://mail.python.org/mbox1)�imapzmail.python.orgz/mbox1rrr)r=zmail.python.orgz/mbox1rr)z1mms://wms.sys.hinet.net/cts/Drama/09006251100.asf)�mmszwms.sys.hinet.netz/cts/Drama/09006251100.asfrrr)r>zwms.sys.hinet.netz/cts/Drama/09006251100.asfrr)znfs://server/path/to/file.txt)�nfs�serverz/path/to/file.txtrrr)r?r@z/path/to/file.txtrr)z0svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/)zsvn+sshzsvn.zope.orgz/repos/main/ZConfig/trunk/rrr)zsvn+sshzsvn.zope.orgz/repos/main/ZConfig/trunk/rr)z)git+ssh://git@github.com/user/project.git)zgit+sshzgit@github.comz/user/project.gitrrr)zgit+sshzgit@github.comz/user/project.gitrrcSs8|d�d�tdd�|dD��tdd�|dD��fS)Nr�asciicss|]}|�d�VqdS)rAN)�encode)r/�xr)r)r*�	<genexpr>�szDUrlParseTestCase.test_roundtrips.<locals>._encode.<locals>.<genexpr>r-css|]}|�d�VqdS)rAN)rB)r/rCr)r)r*rD�s�)rB�tuple)r(r)r)r*�_encode�sz1UrlParseTestCase.test_roundtrips.<locals>._encodecsg|]}�|��qSr)r))r/rC)rGr)r*r1�sz4UrlParseTestCase.test_roundtrips.<locals>.<listcomp>)r+)r#�	str_cases�bytes_casesr$r%r&r))rGr*�test_roundtrips�sz UrlParseTestCase.test_roundtripsc
s�dddddg}dd���fdd	�|D�}d
}d}||f}||f}x`||fD]T\}}xJ|D]B}	x<|D]4\}
}}|	|
}
|	f|}|	f|}|�|
||�qbWqXWqJWdS)N)z://www.python.org)zwww.python.orgrrrr)zwww.python.orgrrr)z://www.python.org#abc)zwww.python.orgrrr�abc)zwww.python.orgrrrK)z://www.python.org?q=abc)zwww.python.orgrrzq=abcr)zwww.python.orgrzq=abcr)z://www.python.org/#abc)zwww.python.org�/rrrK)zwww.python.orgrLrrK)z://a/b/c/d;p?q#f)rz/b/c/d�p�q�f)rz/b/c/d;prNrOcSs8|d�d�tdd�|dD��tdd�|dD��fS)NrrAcss|]}|�d�VqdS)rAN)rB)r/rCr)r)r*rD�szIUrlParseTestCase.test_http_roundtrips.<locals>._encode.<locals>.<genexpr>r-css|]}|�d�VqdS)rAN)rB)r/rCr)r)r*rD�srE)rBrF)r(r)r)r*rG�sz6UrlParseTestCase.test_http_roundtrips.<locals>._encodecsg|]}�|��qSr)r))r/rC)rGr)r*r1�sz9UrlParseTestCase.test_http_roundtrips.<locals>.<listcomp>)�http�https)shttpshttps)r+)
r#rHrIZstr_schemesZ
bytes_schemesZ	str_testsZbytes_testsZschemesZ
test_casesrr$r%r&r))rGr*�test_http_roundtrips�s$


z%UrlParseTestCase.test_http_roundtripsc	CsR|||f}|�tj�||�|�dd�|D�}\}}}|�tj�||�|�dS)NcSsg|]}|�d��qS)rA)rB)r/rCr)r)r*r1�sz.UrlParseTestCase.checkJoin.<locals>.<listcomp>)rrr�urljoin)	r#�baseZrelurl�expectedZstr_componentsZbytes_componentsZbasebZrelurlbZ	expectedbr)r)r*�	checkJoin�s
zUrlParseTestCase.checkJoincCsndddddddg}dd	�|D�}xH||D]<}|�tj�tj�|��|�|�tj�tj�|��|�q*WdS)
N�Pythonz./Pythonzx-newscheme://foo.com/stuffzx://yzx:/yzx:/rLcSsg|]}|�d��qS)rA)rB)r/rCr)r)r*r1�sz7UrlParseTestCase.test_unparse_parse.<locals>.<listcomp>)rrrr"r!rr)r#rHrI�ur)r)r*�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)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)rV�RFC1808_BASE)r#r)r)r*�test_RFC1808�s>zUrlParseTestCase.test_RFC1808cCs|�tj�d�d�dS)Nzmailto:1337@example.org)Zmailtorz1337@example.orgrrr)rrrr)r#r)r)r*�test_RFC2368szUrlParseTestCase.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)>Nzg:hrZzhttp://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)rV�RFC2396_BASE)r#r)r)r*�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)INz?yzhttp://a/b/c/d;p?yz;xzhttp://a/b/c/;xzg:hrZzhttp://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)rV�RFC3986_BASE)r#r)r)r*�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)BNzg:hzhttp:gzhttp://a/b/c/gzhttp:zhttp://a/b/c/drZz./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/grL�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)rV�SIMPLE_BASE)r#r)r)r*�
test_urljoins�sTzUrlParseTestCase.test_urljoinscs�ddddddddd	d
ddd
dddddddddddg}dd���fdd�|D�}x:||D].\}}}tj�|�}|�|j|jf||f�qXWdddd d!g}d"d�|D�}x"||D]}|�ttjj|�q�WdS)#N)z http://Test.python.org:5432/foo/ztest.python.orgi8)zhttp://12.34.56.78:5432/foo/z12.34.56.78i8)zhttp://[::1]:5432/foo/z::1i8)zhttp://[dead:beef::1]:5432/foo/zdead:beef::1i8)zhttp://[dead:beef::]:5432/foo/zdead:beef::i8)z:http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/z'dead:beef:cafe:5417:affe:8fa3:deaf:feedi8)z http://[::12.34.56.78]:5432/foo/z
::12.34.56.78i8)z%http://[::ffff:12.34.56.78]:5432/foo/z::ffff:12.34.56.78i8)zhttp://Test.python.org/foo/ztest.python.orgN)zhttp://12.34.56.78/foo/z12.34.56.78N)zhttp://[::1]/foo/z::1N)zhttp://[dead:beef::1]/foo/zdead:beef::1N)zhttp://[dead:beef::]/foo/zdead:beef::N)z5http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/z'dead:beef:cafe:5417:affe:8fa3:deaf:feedN)zhttp://[::12.34.56.78]/foo/z
::12.34.56.78N)z http://[::ffff:12.34.56.78]/foo/z::ffff:12.34.56.78N)zhttp://Test.python.org:/foo/ztest.python.orgN)zhttp://12.34.56.78:/foo/z12.34.56.78N)zhttp://[::1]:/foo/z::1N)zhttp://[dead:beef::1]:/foo/zdead:beef::1N)zhttp://[dead:beef::]:/foo/zdead:beef::N)z6http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:/foo/z'dead:beef:cafe:5417:affe:8fa3:deaf:feedN)zhttp://[::12.34.56.78]:/foo/z
::12.34.56.78N)z!http://[::ffff:12.34.56.78]:/foo/z::ffff:12.34.56.78NcSs"|d�d�|d�d�|dfS)NrrAr-rE)rB)r(r)r)r*rG�sz.UrlParseTestCase.test_RFC2732.<locals>._encodecsg|]}�|��qSr)r))r/rC)rGr)r*r1�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|]}|�d��qS)rA)rB)r/rCr)r)r*r1�s)rrrrrr �assertRaises�
ValueError)r#rHrIr$rr Z	urlparsedZinvalid_urlr))rGr*�test_RFC2732�sJzUrlParseTestCase.test_RFC2732cs�ddddddddtd	d
ftd	dfg
}dd
���fdd�|D�}x^||D]R\}}}tj�|�}|�|��|�|�|||f�|�|j|�|�|j|�qHWdS)N)zhttp://python.org#fragzhttp://python.org�frag)zhttp://python.orgzhttp://python.orgr)zhttp://python.org/#fragzhttp://python.org/ri)zhttp://python.org/zhttp://python.org/r)zhttp://python.org/?q#fragzhttp://python.org/?qri)zhttp://python.org/?qzhttp://python.org/?qr)zhttp://python.org/p#fragzhttp://python.org/pri)zhttp://python.org/p?qzhttp://python.org/p?qrzhttp://a/b/c/d;p?qrOrcSst|�dd�|D��S)Ncss|]}|�d�VqdS)rAN)rB)r/rCr)r)r*rD�szCUrlParseTestCase.test_urldefrag.<locals>._encode.<locals>.<genexpr>)�type)r(r)r)r*rG�sz0UrlParseTestCase.test_urldefrag.<locals>._encodecsg|]}�|��qSr)r))r/rC)rGr)r*r1�sz3UrlParseTestCase.test_urldefrag.<locals>.<listcomp>)	r\r_rrZ	urldefragrrr$r)r#rHrIr$Zdefragrir'r))rGr*�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)rrr!rrr)r#rMr)r)r*�test_urlsplit_scoped_IPv6sz*UrlParseTestCase.test_urlsplit_scoped_IPv6c	Csd}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WdQRXdS)#NzHTTP://WWW.PYTHON.ORG/doc/#fragrPzWWW.PYTHON.ORGz/doc/rrizwww.python.org�z7http://User:Pass@www.python.org:080/doc/?query=yes#fragzUser:Pass@www.python.org:080z	query=yesZUserZPass�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/r	sfragswww.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!rrrrrrrrrr r�assertRaisesRegexrg)r#r$rMr)r)r*�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}tj�|�}|�|�
�d�d}tj�|�}|�|�
�d�d}d}x@td�D]4}tjj||d�}|�|jd�|�|�
�d��q�WdS)NzQh
ttp://www.python
.org	/java
script:	alert('msg
')/?query
=	something#frag
mentrPzwww.python.orgz/javascript:alert('msg')/zquery=somethingrzGhttp://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
psrE)rrQzHhttps://www.python.org/javascript:alert('msg')/?query=something#fragment)rrr!rrrrrrrrrr r�range)r#r$rMr�_r)r)r*�!test_urlsplit_remove_unsafe_bytesgsHz2UrlParseTestCase.test_urlsplit_remove_unsafe_bytesc
Cs�x�dD]�}x�tjjtjjfD]�}x�dD]z}|j|||d��`d|}d|}|rd|�d�}|�d�}||�}|�|j|�|�t	��|j
WdQRXWdQRXq&WqWqWdS)z Check handling of invalid ports.)FT)rcz1.5z-1Z0x10)�bytesrr zwww.example.net:zhttp://rAN)rrr!r�subTestrBrrrfrgr )r#rtrr rr$rMr)r)r*�test_attributes_bad_port�s



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	)rrr!rrrrrr rr)r#ZurirMr)r)r*�test_attributes_without_netloc�s<z/UrlParseTestCase.test_attributes_without_netloccCs,|�tj�d�d�|�tj�d�d�dS)Nz http://example.com?blahblah=/foo)rPzexample.comrrz
blahblah=/foors http://example.com?blahblah=/foo)shttpsexample.comr	r	s
blahblah=/foor	)rrrr)r#r)r)r*�test_noslash�szUrlParseTestCase.test_noslashcCs||�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d�d�|�tj�d	�d
�|�tj�d�d�dS)
Nr)rrrrrrz//www.python.org:80)rzwww.python.org:80rrrrzhttp://www.python.org:80)rPzwww.python.org:80rrrrspath)r	r	spathr	r	r	s//www.python.org:80)r	swww.python.org:80r	r	r	r	shttp://www.python.org:80)shttpswww.python.org:80r	r	r	r	)rrrr)r#r)r)r*�test_withoutscheme�sz#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�dS)Nzpath:80)rrzpath:80rrrzhttp:)rPrrrrrzhttps:)rQrrrrrzhttp://www.python.org:80)rPzwww.python.org:80rrrrspath:80)r	r	spath:80r	r	r	shttp:)shttpr	r	r	r	r	shttps:)shttpsr	r	r	r	r	shttp://www.python.org:80)shttpswww.python.org:80r	r	r	r	)rrrr)r#r)r)r*�test_portseparator�sz#UrlParseTestCase.test_portseparatorcCs|�ttjjd�dS)Nrc)rf�	TypeErrorrr�	urlencode)r#r)r)r*�
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)Zs3zfoo.comz/stuffrrrzx-newscheme://foo.com/stuff)zx-newschemezfoo.comz/stuffrrrz*x-newscheme://foo.com/stuff?query#fragment)zx-newschemezfoo.comz/stuffrrrz!x-newscheme://foo.com/stuff?query)zx-newschemezfoo.comz/stuffrrrss3://foo.com/stuff)ss3sfoo.coms/stuffr	r	r	sx-newscheme://foo.com/stuff)sx-newschemesfoo.coms/stuffr	r	r	s*x-newscheme://foo.com/stuff?query#fragment)sx-newschemesfoo.coms/stuffr	squerysfragments!x-newscheme://foo.com/stuff?query)sx-newschemesfoo.coms/stuffr	squeryr	)rrrr)r#r)r)r*�test_anyscheme�s zUrlParseTestCase.test_anyschemec
Cs�x�tjjtjjfD]�}|j|d���|dd�}|�|jd�|dd�}|�|jd�|�|dd�jd�|�|ddd	�jd�|�|d
dd	�jd�|�|d�jd�|�|d
�jd�|�|d
d�jd�WdQRXqWdS)
N)�functionzhttp://example.net/�ftprPshttp://example.net/sftpshttpr)rspathrr	)rrrr!rurr)r#�funcr'r)r)r*�test_default_schemes

z$UrlParseTestCase.test_default_schemecCsd}�x|D]�\}}}x�tjjtjjfD]�}|dkrD|tjjkrDd}|j||d���||dd�}|�|jd�|�t||��	d|��|�||dd�jd�||d	d�}|�|j|�|�
t||��	|��|�||dd	�j|�|�||�j|�WdQRXq(WqWdS)
N)
)z
http:#fragrri)z//example.net#fragrri)zindex.html#fragrri)z	;a=b#fragrri)z	?a=b#fragrri)z#fragrri)z	abc#@fragrz@frag)z//abc#@fragrz@frag)z//abc:80#@fragrz@frag)z//abc#@frag:80rz@frag:80rr)r$rF)Zallow_fragmentsr�#T)rrrr!rurrZ
assertTrue�getattr�endswithZassertFalse)r#Ztestsr$�attrZ
expected_fragr�r'r)r)r*�test_parse_fragments"s$z%UrlParseTestCase.test_parse_fragmentsc	Csx|�td��tj�dd�WdQRX|�td��tj�dd�WdQRX|�td��tj�dd�WdQRX|�td��tj�dd�WdQRX|�td��tj�d�WdQRX|�td��tj�d�WdQRX|�td��tj�d�WdQRX|�td��tj�d	�WdQRX|�td��tj�d
d�WdQRX|�td��tj�dd
�WdQRXdS)NzCannot mix strzwww.python.orgshttpswww.python.orgrP)shttpzwww.python.orgrrrr)rPswww.python.orgrrrr)shttpzwww.python.orgrrr)rPswww.python.orgrrrzhttp://python.orgshttp://python.org)	ror{rrrr!rr"rS)r#r)r)r*�test_mixed_types_rejectedCs(z*UrlParseTestCase.test_mixed_types_rejectedc
Cs:t|j�}|j}|�|j|�d|}d|}||�}||�}d}d}	|�||�|�|��|�|�|��|�|�|�|�|�|�|�|�|�|�|�||	�|�|�|�||	�|�|�||�|�|��|�|�|��|�|�|�|�|�|�|�|�|�|�|�||	�|�|�|�||	�|�dS)N)r)r	rA�strict)r.�_fieldsZ_encoded_counterpartZassertIsZ_decoded_counterpartr�decoderB)
r#Zstr_typeZnum_argsZ
bytes_typeZstr_argsZ
bytes_argsZ
str_resultZbytes_result�encoding�errorsr)r)r*�_check_result_type[s.
z#UrlParseTestCase._check_result_typecCs2tjjtjjtjjg}x|D]}|�|�qWdS)N)rrZDefragResultZSplitResultZParseResultr�)r#Zresult_typesZresult_typer)r)r*�test_result_pairsts


z"UrlParseTestCase.test_result_pairscCs�tjjddd�}|�|ddgi�tjjddd�}|�|ddgi�tjjddd�}|�|dd	gi�tjjd
dd�}|�|ddgi�tjjd
ddd
�}|�|ddgi�dS)Nu	key=Ł%E9zlatin-1)r��keyuŁéukey=Ł%C3%A9zutf-8rAuŁ��u
key=Ł%E9-uŁ�-�ignore)r�r�uŁ-)rrr:r)r#r'r)r)r*�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)Nu	key=Ł%E9zlatin-1)r�)r�uŁéukey=Ł%C3%A9zutf-8rA)r�uŁ��u
key=Ł%E9-)r�uŁ�-r�)r�r�)r�uŁ-)rrr3r)r#r'r)r)r*�test_parse_qsl_encoding�s
z(UrlParseTestCase.test_parse_qsl_encodingc	CsR|�t��"tjjd�dgd�dd�WdQRXtjjd�dgd�dd�dS)Nrza=a��
)Zmax_num_fields)rfrgrrr:�join)r#r)r)r*�test_parse_qsl_max_num_fields�s&z.UrlParseTestCase.test_parse_qsl_max_num_fieldsc
Cs�difdifdddgifddgdgd	�fd
dddgifd
ifdifdddgifddgdgd�fddddgifg
}xT|D]L\}}|�d|�d|����(tjj|dd�}|�||d|�WdQRXqvWdS)N�;z;;z;a=brrza=a+b;b=b+cza bzb c)rrza=1;a=2rr�;s;;s;a=brr
sa=a+b;b=b+csa bsb c)rr
sa=1;a=2rrz
Original: z, Expected: )�	separatorzError parsing %r)rurrr:r)r#Zparse_qs_semicolon_casesr4r5r'r)r)r*�test_parse_qs_separator�sz(UrlParseTestCase.test_parse_qs_separatorcCs�dgfdgfddgfdddgfdd	d
gfdgfdgfd
dgfdddgfdddgfg
}xT|D]L\}}|�d|�d|����(tjj|dd�}|�||d|�WdQRXqZWdS)Nr�z;;z;a=b)rrza=a+b;b=b+c)rza b)rzb cza=1;a=2)rr)rrr�s;;s;a=b)rr
sa=a+b;b=b+c)rsa b)r
sb csa=1;a=2)rr)rrz
Original: z, Expected: )r�zError parsing %r)rurrr3r)r#Zparse_qsl_semicolon_casesr4r5r'r)r)r*�test_parse_qsl_separator�s


z)UrlParseTestCase.test_parse_qsl_separatorcCsjtj�ddgdd�d�}t|�d��ddd	d
dhks8t�Gdd
�d
�}tj�d|�id�}|�|d�dS)Nr-rE)�rm�)rrTrza=1za=2zb=3zb=4zb=5c@seZdZdd�ZdS)z:UrlParseTestCase.test_urlencode_sequences.<locals>.TrivialcSsdS)NZtrivialr))r#r)r)r*�__str__�szBUrlParseTestCase.test_urlencode_sequences.<locals>.Trivial.__str__N)�__name__�
__module__�__qualname__r�r)r)r)r*�Trivial�sr�rz	a=trivial)rrr|�setr&�AssertionErrorr)r#r'r�r)r)r*�test_urlencode_sequences�s
 z)UrlParseTestCase.test_urlencode_sequencescCsjtj�ddi�}|�|d�tjjdditjjd�}|�|d�tjjddidtjjd�}|�|d	�dS)
Nrz
some valueza=some+valuezsome value/another)�	quote_viaza=some%20value%2FanotherrL)Zsafer�za=some%20value/another)rrr|r�quote)r#r'r)r)r*�test_urlencode_quote_via�sz)UrlParseTestCase.test_urlencode_quote_viacCsF|�ttjjd�tj�d�}|�|d�tj�d�}|�|d�dS)Nrcsarchaeological arcanazarchaeological%20arcanar	r)rfr{rrZquote_from_bytesr)r#r'r)r)r*�test_quote_from_bytes�s
z&UrlParseTestCase.test_quote_from_bytescCs4tj�d�}|�|d�tj�d�}|�|d�dS)Nz	abc%20defsabc defrr	)rrZunquote_to_bytesr)r#r'r)r)r*�test_unquote_to_bytes�sz&UrlParseTestCase.test_unquote_to_bytescCs0|jttjjddd�|jttjjddd�dS)Nsfoozutf-8)r�r�)r�)rfr{rrr�)r#r)r)r*�test_quote_errors�sz"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)rrr!rrrr)r#�p1Zp2r)r)r*�test_issue14072�sz UrlParseTestCase.test_issue14072cCs�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)rrrrrrr)r#r�r)r)r*�test_telurl_params�s z#UrlParseTestCase.test_telurl_paramscCs$tj�tjj�}|�dt|��dS)N�Quoter)rrr�Z_ALWAYS_SAFE�assertIn�repr)r#Zquoterr)r)r*�test_Quoter_reprsz!UrlParseTestCase.test_Quoter_reprcCs�g}ddddddddd	d
ddd
ddh}xLttj�D]>}|�d�s2||krJq2ttj|�}t|dd�dkr2|�|�q2W|�tjj|�dS)N�	splitattr�	splithost�
splitnport�splitpasswd�	splitport�
splitquery�splittag�	splittype�	splituser�
splitvaluer�Z
ResultBaseZclear_cache�to_bytes�unwraprrr�zurllib.parse)�dirrr�
startswithr��appendZassertCountEqual�__all__)r#rUZundocumented�name�objectr)r)r*�test_alls
zUrlParseTestCase.test_allc
sd�dd��D����fdd�tttdtj��D�}|�d|�|�d|�tj�d	�|�	t
��tj�d
�WdQRXx�dD]x}xrdD]j}xd|D]\}d
�||�|��}|j|d�t
|��d��(|�	t
��tj�|�WdQRXWdQRXq�Wq�Wq�WdS)Nz/:#?@cSsh|]}d�t|���qS)z{:04X})�format�ord)r/�cr)r)r*�	<setcomp>*sz?UrlParseTestCase.test_urlsplit_normalization.<locals>.<setcomp>cs.g|]&}�tt�|����@r|�kr|�qSr))r��unicodedata�
decompositionr&)r/r�)�	hex_chars�
illegal_charsr)r*r1,sz@UrlParseTestCase.test_urlsplit_normalization.<locals>.<listcomp>�u℀u#uhttp://プ:80uhttp://プ︓80)rPrQr�)znetloc{}false.netloczn{}user@netlocz{}://{}/pathz{:04X})r$�char)�map�chrrq�sys�
maxunicoder�rrr!rfrgr�rur�)r#Zdenorm_charsrrr�r$r))r�r�r*�test_urlsplit_normalization%s"


z,UrlParseTestCase.test_urlsplit_normalizationN)/r�r�r�r+r7r;rJrRrVrYr]r^r`rbrerhrkrlrprsrvrwrxryrzr}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*rGsX3	
#&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}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�dS)Nztype:opaquestring)rj�opaquestringr�)Nr�z
:opaquestring)Nz
:opaquestringztype:)rjrztype:opaque:string)rjz
opaque:string)rrr�r)r#r�r)r)r*�test_splittypeFs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)zwww.example.org:80z/foo/bar/baz.htmlz//www.example.org:80)zwww.example.org:80rz/foo/bar/baz.html)Nz/foo/bar/baz.htmlz//127.0.0.1#@host.com)z	127.0.0.1z/#@host.comz//127.0.0.1#@host.com:80)z	127.0.0.1z/#@host.com:80z//127.0.0.1:80#@host.com)z127.0.0.1:80z/#@host.comz///file)rz/filez//example.net/file;)zexample.netz/file;z//example.net/file?)zexample.netz/file?z//example.net/file#)zexample.netz/file#)rrr�r)r#r�r)r)r*�test_splithostNs*









zUtility_Tests.test_splithostcCs\tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�dS)NzUser:Pass@www.python.org:080)z	User:Passzwww.python.org:080z@www.python.org:080)rzwww.python.org:080zwww.python.org:080)Nzwww.python.org:080z
User:Pass@)z	User:Passrz(User@example.com:Pass@www.python.org:080)zUser@example.com:Passzwww.python.org:080)rrr�r)r#r�r)r)r*�test_splituserks




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�za bz	user 2:ab)zuser 2r�z
user+1:a+b)zuser+1za+bzuser:)r�rr�)r�Nz:ab)rr�)rrr�r)r#r�r)r)r*�test_splitpasswdxszUtility_Tests.test_splitpasswdcCs�tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d	�|�|d
�d�|�|d�d
�|�|d�d�dS)Nz	parrot:88)�parrot�88r�)r�Nzparrot:z	127.0.0.1)z	127.0.0.1Nz
parrot:cheese)z
parrot:cheeseNz[::1]:88)z[::1]r�z[::1])z[::1]Nz:88)rr�)rrr�r)r#r�r)r)r*�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�dS)
Nz	parrot:88)r��Xr�)r�����7)r�r�zparrot:z	127.0.0.1)z	127.0.0.1r�)z	127.0.0.1r�z
parrot:cheese)r�N)rrr�r)r#r�r)r)r*�test_splitnport�szUtility_Tests.test_splitnportcCsLtjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�dS)	Nzhttp://python.org/fake?foo=bar)zhttp://python.org/fakezfoo=barzhttp://python.org/fake?foo=bar?)zhttp://python.org/fake?foo=barrzhttp://python.org/fake)zhttp://python.org/fakeNz?foo=bar)rzfoo=bar)rrr�r)r#r�r)r)r*�test_splitquery�s


zUtility_Tests.test_splitquerycCs\tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�dS)Nzhttp://example.com?foo=bar#baz)zhttp://example.com?foo=bar�bazzhttp://example.com?foo=bar#)zhttp://example.com?foo=barrz#baz)rr�zhttp://example.com?foo=bar)zhttp://example.com?foo=barNz"http://example.com?foo=bar#baz#boo)zhttp://example.com?foo=bar#bazZboo)rrr�r)r#r�r)r)r*�
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)rrr�r)r#r�r)r)r*�test_splitattr�s

zUtility_Tests.test_splitattrcCs\tjj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�dS)Nzfoo=bar)rc�barzfoo=)rcrz=bar)rr��foobar)r�Nzfoo=bar=baz)rczbar=baz)rrr�r)r#r�r)r)r*�test_splitvalue�szUtility_Tests.test_splitvaluecCs.tj�d�}|�|d�|�ttjjd�dS)Nzhttp://www.python.orguhttp://www.python.org/mediæval)rrr�rrf�UnicodeError)r#r'r)r)r*�
test_to_bytes�szUtility_Tests.test_to_bytescCstj�d�}|�|d�dS)Nz<URL:type://host/path>ztype://host/path)rrr�r)r#r$r)r)r*�test_unwrap�szUtility_Tests.test_unwrapN)r�r�r��__doc__r�r�r�r�r�r�r�r�r�r�r�r�r)r)r)r*r�Bs
	
r��__main__)r�r�ZunittestZurllib.parserr\r_rardr2r9ZTestCaserr�r��mainr)r)r)r*�<module>s�