Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_urlparse.cpython-35.pyc



��Yf���!@s�ddlZddlZddlZddlZdZdZdZdZdgfdgfdgfdddfgfd	dd
fgfd
d
dfgfdd
dfgfdd
d
fgfdd
dfd
dfgfdd
dfd
dfgfdgfdgfdgfdddfgfdddfgfdddfgfdddfgfdddfgfdddfddfgfd dd!fdd"fgfd#gfd$gfd%d
d
fgfd&d
dfd
dfgfd'd
dfd
dfgfd(gfd)gfd*ddfgfd+ddfddfgfd,dd!fdd"fgfgZ	difdifdifdddgifd	dd
gifd
d
dgifdd
dgifdd
d
gifdd
dgd
dgifdd
ddgifdifdifdifdddgifdddgifdddgifdddgifdddgifdddgddgifd dd!d"gifd#ifd$ifd%d
d
gifd&d
dgd
dgifd'd
ddgifd(ifd)ifd*ddgifd+ddgddgifd,dd!d"gifgZ
Gd-d.�d.ej�ZGd/d0�d0ej�Z
ed1kr�ej�dS)2�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�2�;z;;z;a=bza=a+b;b=b+cza=1;a=2�;s;;s;a=bsa=a+b;b=b+csa=1;a=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&dIdJ�Z'dKdL�Z(dMdN�Z)dOS)P�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/python35/lib64/python3.5/test/test_urlparse.py�checkRoundtripsUsRz UrlParseTestCase.checkRoundtripscCs�x�tD]}\}}tjj|dd�}|j||d|�dd�|D�}tjj|dd�}|j||d|�qWdS)N�keep_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%�orig�expectr)�expect_without_blanksr+r+r,�test_qsl�szUrlParseTestCase.test_qslcs�x�tD]�\}�tjj|dd�}|j|�d|��fdd��D�}tjj|dd�}|j||d|�qWdS)Nr.TzError parsing %rcs1i|]'}t�|d�r�||�qS)r)r0)r1r2)r7r+r,�
<dictcomp>�s	z,UrlParseTestCase.test_qs.<locals>.<dictcomp>F)�parse_qs_test_casesrr�parse_qsr)r%r6r)r8r+)r7r,�test_qs�s
zUrlParseTestCase.test_qsc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)rUN)�encode)r1�xr+r+r,�	<genexpr>�szDUrlParseTestCase.test_roundtrips.<locals>._encode.<locals>.<genexpr>r/css|]}|jd�VqdS)rUN)rV)r1rWr+r+r,rX�s�)rV�tuple)r*r+r+r,�_encode�sz1UrlParseTestCase.test_roundtrips.<locals>._encodecsg|]}�|��qSr+r+)r1rW)r[r+r,r3�s	z4UrlParseTestCase.test_roundtrips.<locals>.<listcomp>�r?rr@rrr�r?rr@rr)r>r\r]�rBrCrDrrr�rBrCrDrr)rAr^r_�rFrGrHrrr�rFrGrHrr)rEr`ra�rJrKrLrrr�rJrKrLrr)rIrbrc�rNrOrPrrr�rNrOrPrr)rMrdre�rRrSrTrrr�rRrSrTrr)rQrfrg)r-)r%�	str_cases�bytes_casesr&r'r(r+)r[r,�test_roundtrips�s8	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)NrrUcss|]}|jd�VqdS)rUN)rV)r1rWr+r+r,rX�szIUrlParseTestCase.test_http_roundtrips.<locals>._encode.<locals>.<genexpr>r/css|]}|jd�VqdS)rUN)rV)r1rWr+r+r,rX�srY)rVrZ)r*r+r+r,r[�sz6UrlParseTestCase.test_http_roundtrips.<locals>._encodecsg|]}�|��qSr+r+)r1rW)r[r+r,r3�s	z9UrlParseTestCase.test_http_roundtrips.<locals>.<listcomp>�http�https�http�https�rlrrrr�rlrrr)rkr}r~�rlrrrrn�rlrrrn)rmrr��rlrrrpr�rlrrpr)ror�r��rlrrrrrn�rlrrrrn)rqr�r��rrtrurvrw�rrxrvrw)rsr�r�)ryrz)r{r|)r-)
r%rhriZstr_schemesZ
bytes_schemesZ	str_testsZbytes_testsZschemesZ
test_casesrr&r'r(r+)r[r,�test_http_roundtrips�s8	



z%UrlParseTestCase.test_http_roundtripsc	Csq|||f}|jtjj||�|�dd�|D�}\}}}|jtjj||�|�dS)NcSsg|]}|jd��qS)rU)rV)r1rWr+r+r,r3�s	z.UrlParseTestCase.checkJoin.<locals>.<listcomp>)rrr�urljoin)	r%�baseZrelurl�expectedZstr_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:/rrcSsg|]}|jd��qS)rU)rV)r1rWr+r+r,r3�s	z7UrlParseTestCase.test_unparse_parse.<locals>.<listcomp>)rrrr$r#rr)r%rhri�ur+r+r,�test_unparse_parse�s
(z#UrlParseTestCase.test_unparse_parsecCsQ|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+r,�test_RFC1808�s>zUrlParseTestCase.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.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+r,�test_RFC2396'sFzUrlParseTestCase.test_RFC2396cCsn|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+r,�test_RFC3986Ts\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$�|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/grr�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+r,�
test_urljoins�sTzUrlParseTestCase.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)NrrUr/rY)rV)r*r+r+r,r[�sz.UrlParseTestCase.test_RFC2732.<locals>._encodecsg|]}�|��qSr+r+)r1rW)r[r+r,r3�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)rU)rV)r1rWr+r+r,r3�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%rhrir&r!r"Z	urlparsedZinvalid_urlr+)r[r,�test_RFC2732�sV	&	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?qrwcSst|�dd�|D��S)Ncss|]}|jd�VqdS)rUN)rV)r1rWr+r+r,rXszCUrlParseTestCase.test_urldefrag.<locals>._encode.<locals>.<genexpr>)�type)r*r+r+r,r[sz0UrlParseTestCase.test_urldefrag.<locals>._encodecsg|]}�|��qSr+r+)r1rW)r[r+r,r3s	z3UrlParseTestCase.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	urldefragrrr&r)r%rhrir&Zdefragr�r)r+)r[r,�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/#fragryzWWW.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#rrrrrrrr r!r"r)r%r&rur+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+)rur+r,�<lambda>msz;UrlParseTestCase.test_attributes_bad_port.<locals>.<lambda>cs�jS)N)r"r+)rur+r,r�qsshttp://www.example.net:fooswww.example.net:foocs�jS)N)r"r+)rur+r,r�vscs�jS)N)r"r+)rur+r,r�zsN)rrr#rrr�r�r)r%r+)rur,�test_attributes_bad_portisz)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#rrrr r!r"rr)r%Zurirur+r+r,�test_attributes_without_netloc|s<z/UrlParseTestCase.test_attributes_without_netloccCs<|jtjjd�d�|jtjjd�d�dS)
Nz http://example.com?blahblah=/foory�example.comr�
blahblah=/foos http://example.com?blahblah=/foo�http�example.comr	�
blahblah=/foo)ryr�rrr�r)r�r�r	r	r�r	)rrrr)r%r+r+r,�test_noslash�szUrlParseTestCase.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:80ry�pathr	s//www.python.org:80�www.python.org:80shttp://www.python.org:80�http)rrrrrr)rr�rrrr)ryr�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:ryzhttps:rzzhttp://www.python.org:80�www.python.org:80�path:80r	shttp:�httpshttps:�httpsshttp://www.python.org:80�www.python.org:80)rrr�rrr)ryrrrrr)rzrrrrr)ryr�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_portseparator�sz#UrlParseTestCase.test_portseparatorcCs|jttjjd�dS)Nr�)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�rrr)r�r�r�rrr)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�WdQRXqWdS)
N�functionzhttp://example.net/�ftpryshttp://example.net/sftpshttprrspathrr	)rrrr#�subTestrr)r%�funcr)r+r+r,�test_default_scheme�sz$UrlParseTestCase.test_default_schemecCsnd"}xa|D]Y\}}}xGtjjtjjfD]-}|dkr_|tjjkr_d}|jd|d|���||dd�}|j|jd�|jt||�j	d|��|j||dd�jd�||dd�}|j|j|�|j
t||�j	|��|j||dd�j|�|j||�j|�WdQRXq5Wq
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�rr��r�rr��r�rr��r�rr��r�rr��r�rr��r�rr��rrr��rrr��rrr)
rrrrr	r
rrr
r)rrrr#r�rrZ
assertTrue�getattr�endswithZassertFalse)r%Ztestsr&�attrZ
expected_fragr�r)r+r+r,�test_parse_fragments�s6z%UrlParseTestCase.test_parse_fragmentscICs�|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.orgryrzhttp://python.orgshttp://python.org)rrrrrr)ryrrrrr)rrrrr)ryrrrr)	ZassertRaisesRegexr�rrrr#rr$r�)r%r+r+r,�test_mixed_types_rejecteds(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	rU�strict)r)r	)r0�_fieldsZ_encoded_counterpartZassertIsZ_decoded_counterpartr�decoderV)
r%Zstr_typeZnum_argsZ
bytes_typeZstr_argsZ
bytes_argsZ
str_resultZbytes_result�encoding�errorsr+r+r,�_check_result_type0s.	

z#UrlParseTestCase._check_result_typecCsCtjjtjjtjjg}x|D]}|j|�q(WdS)N)rrZDefragResultZSplitResultZParseResultr)r%Zresult_typesZresult_typer+r+r,�test_result_pairsIs
		
z"UrlParseTestCase.test_result_pairscCs�tjjddd�}|j|ddgi�tjjddd�}|j|ddgi�tjjddd�}|j|dd	gi�tjjd
dd�}|j|ddgi�tjjd
dddd
�}|j|ddgi�dS)Nu	key=Ł%E9rzlatin-1�keyuŁéukey=Ł%C3%A9zutf-8rUuŁ��u
key=Ł%E9-uŁ�-r�ignoreuŁ-)rrr<r)r%r)r+r+r,�test_parse_qs_encodingSs	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-8rU�Ł��u
key=Ł%E9-�Ł�-rr�Ł-)rr!)rr!)rr")rr#)rr$)rrr5r)r%r)r+r+r,�test_parse_qsl_encoding`s	z(UrlParseTestCase.test_parse_qsl_encodingcCs�tjjdddgddid�}t|jd	��d
ddd
dhksWt�Gdd�d�}tjjd|�id�}|j|d�dS)Nrr/rYr�r��Trza=1za=2zb=3zb=4zb=5c@seZdZdd�ZdS)z:UrlParseTestCase.test_urlencode_sequences.<locals>.TrivialcSsdS)NZtrivialr+)r%r+r+r,�__str__uszBUrlParseTestCase.test_urlencode_sequences.<locals>.Trivial.__str__N)�__name__�
__module__�__qualname__r(r+r+r+r,�Trivialtsr,z	a=trivial)r&r�r')rrr��setr(�AssertionErrorr)r%r)r,r+r+r,�test_urlencode_sequencesms
'0z)UrlParseTestCase.test_urlencode_sequencescCs�tjjddi�}|j|d�tjjddidtjj�}|j|d�tjjddidddtjj�}|j|d	�dS)
Nrz
some valueza=some+valuezsome value/anotherZ	quote_viaza=some%20value%2FanotherZsaferrza=some%20value/another)rrr�r�quote)r%r)r+r+r,�test_urlencode_quote_via{sz)UrlParseTestCase.test_urlencode_quote_viacCsa|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_bytes�sz&UrlParseTestCase.test_unquote_to_bytescCsB|jttjjddd�|jttjjddd�dS)Nsfoorzutf-8rr)r�r�rrr0)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_issue14072�sz 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-516r5z123-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%r6r+r+r,�test_telurl_params�s z#UrlParseTestCase.test_telurl_paramscCs2tjjtjj�}|jdt|��dS)N�Quoter)rrr9Z_ALWAYS_SAFE�assertIn�repr)r%Zquoterr+r+r,�test_Quoter_repr�sz!UrlParseTestCase.test_Quoter_reprcCs�g}ddddddddd	d
ddd
ddh}xlttj�D][}|jd�sI||krmqIttj|�}t|dd�dkrI|j|�qIW|jtjj|�dS)N�	splitattr�	splithost�
splitnport�splitpasswd�	splitport�
splitquery�splittag�	splittype�	splituser�
splitvaluer9Z
ResultBaseZclear_cache�to_bytes�unwrap�_r*zurllib.parse)�dirrr�
startswithr�appendZassertCountEqual�__all__)r%r�Zundocumented�name�objectr+r+r,�test_all�szUrlParseTestCase.test_allcsXd�dd��D����fdd�tttdtj��D�}|jd|�|jd|�tjjd	�|j	t
��tjjd
�WdQRXx�ddd
gD]�}x�ddgD]�}x|D]w}dj||j|��}|jd|ddjt
|����,|j	t
��tjj|�WdQRXWdQRXq�Wq�Wq�WdS)Nz/:#?@cSs%h|]}djt|���qS)z{:04X})�format�ord)r1�cr+r+r,�	<setcomp>�s	z?UrlParseTestCase.test_urlsplit_normalization.<locals>.<setcomp>csAg|]7}�ttj|�j��@r|�kr|�qSr+)r-�unicodedata�
decompositionr()r1rS)�	hex_chars�
illegal_charsr+r,r3�s	z@UrlParseTestCase.test_urlsplit_normalization.<locals>.<listcomp>�u℀u#uhttp://プ:80uhttp://プ︓80ryrzr�znetloc{}false.netloczn{}user@netlocz{}://{}/pathr&�charz{:04X})�map�chr�range�sys�
maxunicoder:rrr#r�r�rQr�rR)r%Zdenorm_charsrrrSr&r+)rWrXr,�test_urlsplit_normalization�s1
(z,UrlParseTestCase.test_urlsplit_normalizationN)*r)r*r+r-r9r=rjr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr r%r/r1r2r3r4r7r8r<rPr`r+r+r+r,rSsN3	
#&0-97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)r�rb)Nrb)Nrc)r�r)r�rd)rrrDr)r%rDr+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#)rfrg)rfr)Nrg)rhri)rhrj)rkri)rrl)rmrn)rmro)rmrp)rrr>r)r%r>r+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)rrrs)rrs)Nrs)rrr)rtrs)rrrEr)r%rEr+r+r,�test_splitusers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)rvrw)rvrx)rvry)rvrz)rvr{)rvr|)rvr})rvr~)rrw)r�r�)rvr)rvN)rrw)rrr@r)r%r@r+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)r�r�)r�N)r�N)r�N)r�N)r�r�)r�N)rr�)rrrAr)r%rAr+r+r,�test_splitport4s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:88r��Xr/�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)rrr?r)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)r�r�)r�r)r�N)rr�)rrrBr)r%rBr+r+r,�test_splitqueryKs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�)rrrCr)r%rCr+r+r,�
test_splittagWs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)rrr=r)r%r=r+r+r,�test_splitattrcs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�)rrrFr)r%rFr+r+r,�test_splitvaluelszUtility_Tests.test_splitvaluecCs?tjjd�}|j|d�|jttjjd�dS)Nzhttp://www.python.orguhttp://www.python.org/mediæval)rrrGrr��UnicodeError)r%r)r+r+r,�
test_to_bytesvszUtility_Tests.test_to_bytescCs&tjjd�}|j|d�dS)Nz<URL:type://host/path>ztype://host/path)rrrHr)r%r&r+r+r,�test_unwrap|szUtility_Tests.test_unwrapN)r)r*r+�__doc__rerqrur�r�r�r�r�r�r�r�r�r+r+r+r,ra�s
	
ra�__main__)r^rUZunittestZurllib.parserr�r�r�r�r4r;ZTestCaserrar)�mainr+r+r+r,�<module>s�										!										�����