Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_urlparse.cpython-34.pyo

�
f f��@sddlZddlZddlZddlZdZdZdZdZdgfdgfdgfdddfgfd	dd
fgfd
d
dfgfdd
dfgfdd
dfgfdd
d
fgfdd
dfd
dfgfdd
dfd
dfgfdgfdgfdgfdddfgfdddfgfdddfgfdddfgfdddfgfdddfgfdddfddfgfd dd!fdd"fgfgZ	Gd#d$�d$ej
�ZGd%d&�d&ej
�Ze
d'krej�ndS)(�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+cza bzb cza=1&a=2�1�2��&s&&�=s=a�asa=s&a=b�bsa=a+b&b=b+csa bsb csa=1&a=2�1�2c@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&dIS)J�UrlParseTestCasecCsPtjj|�}|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)�7/opt/alt/python34/lib64/python3.4/test/test_urlparse.py�checkRoundtrips)sRz UrlParseTestCase.checkRoundtripscCs�x�tD]}\}}tjj|dd�}|j||d|�dd�|D�}tjj|dd�}|j||d|�qWdS)NZkeep_blank_valuesTzError parsing %rcSs&g|]}t|d�r|�qS)�)�len)�.0�vr)r)r*�
<listcomp>`s	z-UrlParseTestCase.test_qsl.<locals>.<listcomp>F)�parse_qsl_test_casesrr�	parse_qslr)r#ZorigZexpectr'Zexpect_without_blanksr)r)r*�test_qsl\szUrlParseTestCase.test_qslcsrdd"d%d(d+d.g}dd���fdd�|D�}x.||D]"\}}}|j|||�qHWdS)/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.gitcSsH|djd�tdd�|dD��tdd�|dD��fS)Nr�asciicss|]}|jd�VqdS)rKN)�encode)r.�xr)r)r*�	<genexpr>�szDUrlParseTestCase.test_roundtrips.<locals>._encode.<locals>.<genexpr>r,css|]}|jd�VqdS)rKN)rL)r.rMr)r)r*rN�s�)rL�tuple)r(r)r)r*�_encode�sz1UrlParseTestCase.test_roundtrips.<locals>._encodecsg|]}�|��qSr)r))r.rM)rQr)r*r0�s	z4UrlParseTestCase.test_roundtrips.<locals>.<listcomp>��filerr6rrr�rSrr6rr)r4rRrT�r8r9r:rrr�r8r9r:rr)r7rUrV�r<r=r>rrr�r<r=r>rr)r;rWrX�r@rArBrrr�r@rArBrr)r?rYrZ�rDrErFrrr�rDrErFrr)rCr[r\�rHrIrJrrr�rHrIrJrr)rGr]r^)r+)r#�	str_cases�bytes_casesr$r%r&r))rQr*�test_roundtripses8	z UrlParseTestCase.test_roundtripsc

s�ddd!d$d'g}dd���fdd�|D�}d(}d)}||f}||f}x|||fD]n\}}x_|D]W}	xN|D]F\}
}}|	|
}
|	f|}|	f|}|j|
||�q�Wq~WqkWdS)*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;pcSsH|djd�tdd�|dD��tdd�|dD��fS)NrrKcss|]}|jd�VqdS)rKN)rL)r.rMr)r)r*rN�szIUrlParseTestCase.test_http_roundtrips.<locals>._encode.<locals>.<genexpr>r,css|]}|jd�VqdS)rKN)rL)r.rMr)r)r*rN�srO)rLrP)r(r)r)r*rQ�sz6UrlParseTestCase.test_http_roundtrips.<locals>._encodecsg|]}�|��qSr)r))r.rM)rQr)r*r0�s	z9UrlParseTestCase.test_http_roundtrips.<locals>.<listcomp>�http�https�http�https�rcrrrr�rcrrr)rbrtru�rcrrr�abc�rcrrrw)rdrvrx�rcrrrgr�rcrrgr)rfryrz�rcrirrrw�rcrirrw)rhr{r|�rrkrlrmrn�rrormrn)rjr}r~)rprq)rrrs)r+)
r#r_r`Zstr_schemesZ
bytes_schemesZ	str_testsZbytes_testsZschemesZ
test_casesrr$r%r&r))rQr*�test_http_roundtrips�s8	



z%UrlParseTestCase.test_http_roundtripsc	Csq|||f}|jtjj||�|�dd�|D�}\}}}|jtjj||�|�dS)NcSsg|]}|jd��qS)rK)rL)r.rMr)r)r*r0�s	z.UrlParseTestCase.checkJoin.<locals>.<listcomp>)rrr�urljoin)	r#�baseZrelurlZexpectedZstr_componentsZbytes_componentsZbasebZrelurlbZ	expectedbr)r)r*�	checkJoin�s zUrlParseTestCase.checkJoincCs�dddddddg}dd	�|D�}xb||D]V}|jtjjtjj|��|�|jtjjtjj|��|�q9WdS)
N�Pythonz./Pythonzx-newscheme://foo.com/stuffzx://yzx:/yzx:/ricSsg|]}|jd��qS)rK)rL)r.rMr)r)r*r0�s	z7UrlParseTestCase.test_unparse_parse.<locals>.<listcomp>)rrrr"r!rr)r#r_r`�ur)r)r*�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/d*�|jtd0d1�|jtd2d3�|jtd4d5�|jtd6d7�|jtd8d"�|jtd9d�|jtd:d;�|jtd<d=�dS)>Nzg: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#fz
../../../gz
http://a/../gz
../../../../gzhttp://a/../../gz/./gzhttp://a/./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/h)r��RFC1808_BASE)r#r)r)r*�test_RFC1808�sFzUrlParseTestCase.test_RFC1808cCs |jtjjd�d�dS)Nzmailto:1337@example.org�mailtor�1337@example.org)r�rr�rrr)rrrr)r#r)r)r*�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/d0�|jtd1d2�|jtd3d�|jtd4d�|jtd5d6�|jtd7d8�|jtd9d:�|jtd;d<�|jtd=d>�|jtd?d@�|jtdAdB�|jtdCdD�dS)ENzg: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../../grz
../../../gz
http://a/../gz
../../../../gzhttp://a/../../gz/./gzhttp://a/./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/../x)r��RFC2396_BASE)r#r)r)r*�test_RFC2396�sNzUrlParseTestCase.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/d0�|jtd1d$�|jtd2d
�|jtd3d4�|jtd5d6�|jtd7d8�|jtd9d:�|jtd;d<�|jtd=d>�|jtd?d@�|jtdAdB�|jtdCd�|jdDdd�dS)ENz?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../../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_BASEr�)r#r)r)r*�test_RFC3986sRzUrlParseTestCase.test_RFC3986cCs�|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$�|jtd%d&�|jtd'd(�|jtdd�|jtdd�|jtd)d�|jtd*d�|jtd+d�|jd,dd,�|jd-dd�|jd-d$d$�|jd.d/d0�|jd1d/d2�dS)3Nzg: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
http://a/../gz./../gz./g/.z/./gzhttp://a/./gzg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hzhttp:?yzhttp:g?yzhttp:g?y/./xzhttp:///rzsvn://pathtorepo/dir1Zdir2zsvn://pathtorepo/dir2zsvn+ssh://pathtorepo/dir1zsvn+ssh://pathtorepo/dir2)r��SIMPLE_BASE)r#r)r)r*�
test_urljoinsTsDzUrlParseTestCase.test_urljoinscsd,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCg}d"d#���fd$d%�|D�}xO||D]C\}}}tjj|�}|j|j|jf||f�q~Wd&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)NrrKr,rO)rL)r(r)r)r*rQ�sz.UrlParseTestCase.test_RFC2732.<locals>._encodecsg|]}�|��qSr)r))r.rM)rQr)r*r0�s	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.78cSsg|]}|jd��qS)rK)rL)r.rMr)r)r*r0�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)rrrrrr �assertRaises�
ValueError)r#r_r`r$rr Z	urlparsedZinvalid_urlr))rQr*�test_RFC2732xsV	&	zUrlParseTestCase.test_RFC2732cs�ddddddddtdd
ftddfg
}dd���fdd�|D�}x||D]s\}}}tjj|�}|j|j�|�|j|||f�|j|j|�|j|j|�qfWdS)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?qrncSst|�dd�|D��S)Ncss|]}|jd�VqdS)rKN)rL)r.rMr)r)r*rN�szCUrlParseTestCase.test_urldefrag.<locals>._encode.<locals>.<genexpr>)�type)r(r)r)r*rQ�sz0UrlParseTestCase.test_urldefrag.<locals>._encodecsg|]}�|��qSr)r))r.rM)rQr)r*r0�s	z3UrlParseTestCase.test_urldefrag.<locals>.<listcomp>)r�r��frag)r�r�r)r�r�r�)r�r�r)r�r�r�)r�r�r)r�r�r�)r�r�r)	r�r�rrZ	urldefragrrr$r)r#r_r`r$Zdefragr�r'r))rQr*�test_urldefrag�s$zUrlParseTestCase.test_urldefragcCsmd}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|�}|j|jd�dS)"NzHTTP://WWW.PYTHON.ORG/doc/#fragrpzWWW.PYTHON.ORGz/doc/rr�zwww.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/#frag)rrr!rrrrrrrrrr r)r#r$rlr)r)r*�test_urlsplit_attributes�s�**z)UrlParseTestCase.test_urlsplit_attributescstjjd��|j�jd�|jt�fdd��tjjd��|j�jd�|jt�fdd��tjjd��|j�jd�|jt�fdd��tjjd��|j�jd�|jt�fd	d��d
S)z$Check handling of non-integer ports.zhttp://www.example.net:foozwww.example.net:foocs�jS)N)r r))rlr)r*�<lambda>!sz;UrlParseTestCase.test_attributes_bad_port.<locals>.<lambda>cs�jS)N)r r))rlr)r*r�%sshttp://www.example.net:fooswww.example.net:foocs�jS)N)r r))rlr)r*r�*scs�jS)N)r r))rlr)r*r�.sN)rrr!rrr�r�r)r#r))rlr*�test_attributes_bad_portsz)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!rrrrrr rr)r#Zurirlr)r)r*�test_attributes_without_netloc0s<z/UrlParseTestCase.test_attributes_without_netloccCs<|jtjjd�d�|jtjjd�d�dS)
Nz http://example.com?blahblah=/foorp�example.comr�
blahblah=/foos http://example.com?blahblah=/foo�http�example.comr	�
blahblah=/foo)zhttpr�rrr�r)r�r�r	r	r�r	)rrrr)r#r)r)r*�test_noslashYszUrlParseTestCase.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:80rp�pathr	s//www.python.org:80�www.python.org:80shttp://www.python.org:80�http)rrzpathrrr)rr�rrrr)zhttpr�rrrr)r	r	r�r	r	r	)r	r�r	r	r	r	)r�r�r	r	r	r	)rrrr)r#r)r)r*�test_withoutscheme`sz#UrlParseTestCase.test_withoutschemecCs�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd�d�|jtjjd	�d�|jtjjd�d�|jtjjd
�d�|jtjjd�d�dS)N�path:80rzhttp:rpzhttps:rqzhttp://www.python.org:80�www.python.org:80�path:80r	shttp:�httpshttps:�httpsshttp://www.python.org:80�www.python.org:80)rrr�rrr)�httprrrrr)zhttpsrrrrr)r�r�rrrr)r	r	r�r	r	r	)r�r	r	r	r	r	)r�r	r	r	r	r	)r�r�r	r	r	r	)rrrr)r#r)r)r*�test_portseparatorssz#UrlParseTestCase.test_portseparatorcCs|jttjjd�dS)N�foo)r��	TypeErrorrr�	urlencode)r#r)r)r*�
test_usingsys�szUrlParseTestCase.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#fragmentrrz!x-newscheme://foo.com/stuff?queryss3://foo.com/stuff�s3�foo.com�/stuffr	sx-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�r�queryzfragment)r�r�r�rr�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	)rrrr)r#r)r)r*�test_anyscheme�s zUrlParseTestCase.test_anyschemec
Cs,x%tjjtjjfD]}|jd|���|dd�}|j|jd�|dd�}|j|jd�|j|dd�jd�|j|dd	d�jd�|j|d
d	d�jd�|j|d�jd�|j|d
�jd�|j|d
d�jd�WdQXqWdS)
N�functionzhttp://example.net/�ftprpshttp://example.net/sftpshttprrspathrr	)rrrr!�subTestrr)r#�funcr'r)r)r*�test_default_scheme�sz$UrlParseTestCase.test_default_schemecCspd"}xc|D][\}}}xItjjtjjfD]/}|dkrb|tjjkrbd}n|jd|d|���||dd�}|j|jd�|jt||�j	d|��|j||dd�jd�||dd�}|j|j|�|j
t||�j	|��|j||dd�j|�|j||�j|�WdQXq5Wq
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:80r$r�Zallow_fragmentsFr�#T�r��path�frag�r�rr�r�rr�r�zparamsr�r�zqueryr�r�rr�r�rr��r�rr��r�rr��r�rr�)
r�rrrrrrrr	r
)rrrr!r�rrZ
assertTrue�getattr�endswithZassertFalse)r#Ztestsr$�attrZ
expected_fragr�r'r)r)r*�test_parse_fragments�s6	z%UrlParseTestCase.test_parse_fragmentsc@Cs�|jtd��tjjdd�WdQX|jtd��tjjdd�WdQX|jtd��tjjdd�WdQX|jtd��tjjdd�WdQX|jtd��tjjd	�WdQX|jtd��tjjd
�WdQX|jtd��tjjd�WdQX|jtd��tjjd�WdQX|jtd��tjjdd�WdQX|jtd��tjjdd�WdQXdS)
NzCannot mix str�www.python.org�http�www.python.orgrprzhttp://python.orgshttp://python.org)rrrrrr)�httprrrrr)rrrrr)rrrrr)	ZassertRaisesRegexr�rrrr!rr"r�)r#r)r)r*�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)Nrr	rK�strict)r)r	)r-�_fieldsZ_encoded_counterpartZassertIsZ_decoded_counterpartr�decoderL)
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_typecCsCtjjtjjtjjg}x|D]}|j|�q(WdS)N)rrZDefragResultZSplitResultZParseResultr)r#Zresult_typesZresult_typer)r)r*�test_result_pairs�s
		
z"UrlParseTestCase.test_result_pairscCstjjddd�}|j|idgd6�tjjddd�}|j|idgd6�tjjddd�}|j|id	gd6�tjjd
dd�}|j|idgd6�tjjd
dddd
�}|j|idgd6�dS)Nu	key=Ł%E9rzlatin-1uŁé�keyukey=Ł%C3%A9zutf-8rKuŁ��u
key=Ł%E9-uŁ�-r�ignoreuŁ-)rrZparse_qsr)r#r'r)r)r*�test_parse_qs_encodings	z'UrlParseTestCase.test_parse_qs_encodingcCs�tjjddd�}|j|dg�tjjddd�}|j|dg�tjjddd�}|j|dg�tjjd
dd�}|j|dg�tjjd
dddd
�}|j|dg�dS)Nu	key=Ł%E9rzlatin-1r�Łéukey=Ł%C3%A9zutf-8rK�Ł��u
key=Ł%E9-�Ł�-rr�Ł-)�keyr)r"r)r"r)r"r )r"r!)rrr2r)r#r'r)r)r*�test_parse_qsl_encodings	z(UrlParseTestCase.test_parse_qsl_encodingcCsotjjiddgd6dd6d�}Gd	d
�d
�}tjji|�d6d�}|j|d�dS)
Nr,rOr�r��rTc@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(sr*z	a=trivial)r$r�r%)rrr�r)r#r'r*r)r)r*�test_urlencode_sequences!s)z)UrlParseTestCase.test_urlencode_sequencescCsa|jttjjd�tjjd�}|j|d�tjjd�}|j|d�dS)Nr�sarchaeological arcanazarchaeological%20arcanar	r)r�r�rrZquote_from_bytesr)r#r'r)r)r*�test_quote_from_bytes/s
z&UrlParseTestCase.test_quote_from_bytescCsHtjjd�}|j|d�tjjd�}|j|d�dS)Nz	abc%20defsabc defrr	)rrZunquote_to_bytesr)r#r'r)r)r*�test_unquote_to_bytes6sz&UrlParseTestCase.test_unquote_to_bytescCsB|jttjjddd�|jttjjddd�dS)Nsfoorzutf-8rr)r�r�rrZquote)r#r)r)r*�test_quote_errors<sz"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)r*�test_issue14072Asz UrlParseTestCase.test_issue14072cCs0tjjd�}|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-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#r0r)r)r*�test_telurl_paramsPs z#UrlParseTestCase.test_telurl_paramscCs2tjjtjj�}|jdt|��dS)N�Quoter)rrr3Z_ALWAYS_SAFE�assertIn�repr)r#Zquoterr)r)r*�test_Quoter_represz!UrlParseTestCase.test_Quoter_reprcs�d�dd��D����fdd�tttdtj��D�}|jd|�|jd|�x�d	d
dgD]}}xt|D]l}dj||�}|jd
|ddjt|����+|j	t
��tjj
|�WdQXWdQXq�WqzWdS)Nz/:#?@cSs%h|]}djt|���qS)z{:04X})�format�ord)r.�cr)r)r*�	<setcomp>ns	z?UrlParseTestCase.test_urlsplit_normalization.<locals>.<setcomp>csAg|]7}�ttj|�j��@r|�kr|�qSr))�set�unicodedata�
decompositionr&)r.r9)�	hex_chars�
illegal_charsr)r*r0ps	z@UrlParseTestCase.test_urlsplit_normalization.<locals>.<listcomp>�u℀u#rprqr�z{}://netloc{}false.netloc/pathr$�charz{:04X})�map�chr�range�sys�
maxunicoder4r7r�r8r�r�rrr!)r#Zdenorm_charsrr9r$r))r>r?r*�test_urlsplit_normalizationis1
(z,UrlParseTestCase.test_urlsplit_normalizationN)'r'r(r)r+r3rarr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr#r+r,r-r.r1r2r6rGr)r)r)r*r'sH3	#&-,:$2\)!


rc@s�eZdZdZdd�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)�typerI)NrI)NrJ)rLr)rLrK)rr�	splittyper)r#rMr)r)r*�test_splittype�s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#)rOrP)rOr)NrP)rQrR)rQrS)rTrR)rrU)rVrW)rVrX)rVrY)rr�	splithostr)r#rZr)r)r*�test_splithost�s*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])rr�	splituserr)r#r_r)r)r*�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)�userrb)rmrc)rmrd)rmre)rmrf)rmrg)rmrh)rmri)rjrb)rkrl)rmr)rmN)rrb)rr�splitpasswdr)r#rnr)r)r*�test_splitpasswd�szUtility_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)rprq)rpN)rpN)rrN)rsN)rtrq)rtN)rrq)rr�	splitportr)r#rur)r)r*�test_splitport�szUtility_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:88rp�Xr,�7zparrot:�	127.0.0.1z
parrot:cheese)�parrotrw���)rzr{)rzrxr{)rzr{)rzrxr{)ryr{)ryrx)rzN)rzN)rr�
splitnportr)r#r|r)r)r*�test_splitnport�szUtility_Tests.test_splitnportcCshtjj}|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)rr�)r~r)rN)rr�)rr�
splitqueryr)r#r�r)r)r*�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�)rr�splittagr)r#r�r)r)r*�
test_splittag�szUtility_Tests.test_splittagcCs�tjj}|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)rr�	splitattrr)r#r�r)r)r*�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)�foor�)r�r)rr�)r�N)r�r�)rr�
splitvaluer)r#r�r)r)r*�test_splitvalue�szUtility_Tests.test_splitvaluecCs?tjjd�}|j|d�|jttjjd�dS)Nzhttp://www.python.orguhttp://www.python.org/mediæval)rr�to_bytesrr��UnicodeError)r#r'r)r)r*�
test_to_bytes	szUtility_Tests.test_to_bytescCs&tjjd�}|j|d�dS)Nz<URL:type://host/path>ztype://host/path)rrZunwrapr)r#r$r)r)r*�test_unwrapszUtility_Tests.test_unwrapN)r'r(r)�__doc__rNr[r`rorvr}r�r�r�r�r�r�r)r)r)r*rHs
	
rH�__main__)rEr<ZunittestZurllib.parserr�r�r�r�r1ZTestCaserrHr'�mainr)r)r)r*�<module>sH						!���[�