403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.124
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_urlparse.cpython-36.pyc
3

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

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


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



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

z$UrlParseTestCase.test_default_schemecCsd!}�x|D]�\}}}x�tjjtjjfD]�}|dkrD|tjjkrDd}|j||d���||dd�}|j|jd�|jt||�j	d|��|j||dd�jd�||dd�}|j|j|�|j
t||�j	|��|j||dd�j|�|j||�j|�WdQRXq(WqWdS)"N�
http:#fragrr��//example.net#frag�index.html#frag�	;a=b#fragr�	?a=b#fragr�#frag�	abc#@frag�@frag�//abc#@frag�//abc:80#@frag�//abc#@frag:80�@frag:80)r*r�F)Zallow_fragmentsr�#T�rrr��rrr��rrr��rrr��rrr��rrr��rrr�r	rr�r
rr�rrr)
rrrrrrrrrr)rrrr'r�rr Z
assertTrue�getattr�endswithZassertFalse)r)Ztestsr*�attrZ
expected_fragr�r-r/r/r0�test_parse_fragments�s6z%UrlParseTestCase.test_parse_fragmentscICsx|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjd	�WdQRX|jtd��tjjd
�WdQRX|jtd��tjjd�WdQRX|jtd��tjjd�WdQRX|jtd��tjjdd�WdQRX|jtd��tjjdd�WdQRXdS)
NzCannot mix str�www.python.org�http�www.python.orgr}rzhttp://python.orgshttp://python.org)rrrrrr)r}rrrrr)rrrrr)r}rrrr)	r�r�rrrr'r!r(r�)r)r/r/r0�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)NrrrY�strict)r)r)r4�_fieldsZ_encoded_counterpartZassertIsZ_decoded_counterpartr�decoderZ)
r)Zstr_typeZnum_argsZ
bytes_typeZstr_argsZ
bytes_argsZ
str_resultZbytes_result�encoding�errorsr/r/r0�_check_result_type7s.
z#UrlParseTestCase._check_result_typecCs2tjjtjjtjjg}x|D]}|j|�qWdS)N)rrZDefragResultZSplitResultZParseResultr%)r)Zresult_typesZresult_typer/r/r0�test_result_pairsPs


z"UrlParseTestCase.test_result_pairscCs�tjjddd�}|j|ddgi�tjjddd�}|j|ddgi�tjjddd�}|j|dd	gi�tjjd
dd�}|j|ddgi�tjjd
ddd
�}|j|ddgi�dS)Nu	key=Ł%E9zlatin-1)r#�keyuŁéukey=Ł%C3%A9zutf-8rYuŁ��u
key=Ł%E9-uŁ�-�ignore)r#r$uŁ-)rrr@r)r)r-r/r/r0�test_parse_qs_encodingZs
z'UrlParseTestCase.test_parse_qs_encodingcCs�tjjddd�}|j|dg�tjjddd�}|j|dg�tjjddd�}|j|dg�tjjd
dd�}|j|dg�tjjd
ddd
�}|j|dg�dS)Nu	key=Ł%E9zlatin-1)r#r'�Łéukey=Ł%C3%A9zutf-8rY�Ł��u
key=Ł%E9-�Ł�-r()r#r$�Ł-)r'r*)r'r*)r'r+)r'r,)r'r-)rrr9r)r)r-r/r/r0�test_parse_qsl_encodinggs
z(UrlParseTestCase.test_parse_qsl_encodingcCs�|jt��"tjjdjdgd�dd�WdQRX|jt��"tjjdjdgd�dd�WdQRXtjjdjdgd�dd�dS)Nrza=a��
)Zmax_num_fieldsr)r�r�rrr@�join)r)r/r/r0�test_parse_qsl_max_num_fieldsts
&&z.UrlParseTestCase.test_parse_qsl_max_num_fieldscCsjtjjddgdd�d�}t|jd��d	d
ddd
hks8t�Gdd�d�}tjjd|�id�}|j|d�dS)Nr3r]�r��)rrTrza=1za=2zb=3zb=4zb=5c@seZdZdd�ZdS)z:UrlParseTestCase.test_urlencode_sequences.<locals>.TrivialcSsdS)NZtrivialr/)r)r/r/r0�__str__�szBUrlParseTestCase.test_urlencode_sequences.<locals>.Trivial.__str__N)�__name__�
__module__�__qualname__r5r/r/r/r0�Trivial�sr9rz	a=trivial)r3r�r4)rrr��setr,�AssertionErrorr)r)r-r9r/r/r0�test_urlencode_sequences{s
 z)UrlParseTestCase.test_urlencode_sequencescCsjtjjddi�}|j|d�tjjdditjjd�}|j|d�tjjddidtjjd�}|j|d	�dS)
Nrz
some valueza=some+valuezsome value/another)�	quote_viaza=some%20value%2Fanotherrv)Zsafer=za=some%20value/another)rrr�r�quote)r)r-r/r/r0�test_urlencode_quote_via�sz)UrlParseTestCase.test_urlencode_quote_viacCsF|jttjjd�tjjd�}|j|d�tjjd�}|j|d�dS)Nr�sarchaeological arcanazarchaeological%20arcanarr)r�r�rrZquote_from_bytesr)r)r-r/r/r0�test_quote_from_bytes�s
z&UrlParseTestCase.test_quote_from_bytescCs4tjjd�}|j|d�tjjd�}|j|d�dS)Nz	abc%20defsabc defrr)rrZunquote_to_bytesr)r)r-r/r/r0�test_unquote_to_bytes�sz&UrlParseTestCase.test_unquote_to_bytescCs0|jttjjddd�|jttjjddd�dS)Nsfoozutf-8)r#r )r$)r�r�rrr>)r)r/r/r0�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/r0�test_issue14072�sz UrlParseTestCase.test_issue14072cCs�tjjd�}|j|jd�|j|jd�|j|jd�tjjd�}|j|jd�|j|jd�|j|jd�tjjd�}|j|jd�|j|jd	�|j|jd
�tjjd�}|j|jd�|j|jd�|j|jd
�dS)Nz"tel:123-4;phone-context=+1-650-516rCz123-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)rDr/r/r0�test_telurl_params�s z#UrlParseTestCase.test_telurl_paramscCs$tjjtjj�}|jdt|��dS)N�Quoter)rrrGZ_ALWAYS_SAFE�assertIn�repr)r)Zquoterr/r/r0�test_Quoter_repr�sz!UrlParseTestCase.test_Quoter_reprcCs�g}ddddddddd	d
ddd
ddh}xLttj�D]>}|jd�s2||krJq2ttj|�}t|dd�dkr2|j|�q2W|jtjj|�dS)N�	splitattr�	splithost�
splitnport�splitpasswd�	splitport�
splitquery�splittag�	splittype�	splituser�
splitvaluerGZ
ResultBaseZclear_cache�to_bytes�unwrap�_r7zurllib.parse)�dirrr�
startswithr�appendZassertCountEqual�__all__)r)r�Zundocumented�name�objectr/r/r0�test_all�s
zUrlParseTestCase.test_allcsd�dd��D����fdd�tttdtj��D�}|jd|�|jd|�tjjd	�|j	t
��tjjd
�WdQRXx�dD]x}xrdD]j}xd|D]\}dj||j|��}|j|djt
|��d��(|j	t
��tjj|�WdQRXWdQRXq�Wq�Wq�WdS)Nz/:#?@cSsh|]}djt|���qS)z{:04X})�format�ord)r5�cr/r/r0�	<setcomp>�sz?UrlParseTestCase.test_urlsplit_normalization.<locals>.<setcomp>cs.g|]&}�ttj|�j��@r|�kr|�qSr/)r:�unicodedata�
decompositionr,)r5ra)�	hex_chars�
illegal_charsr/r0r7�sz@UrlParseTestCase.test_urlsplit_normalization.<locals>.<listcomp>�u℀u#uhttp://プ:80uhttp://プ︓80r}r~r��netloc{}false.netloc�n{}user@netlocz{}://{}/pathz{:04X})r*�char)r}r~r�)rhri)�map�chr�range�sys�
maxunicoderHrrr'r�r�r_r�r`)r)Zdenorm_charsrrrar*r/)rerfr0�test_urlsplit_normalization�s"


z,UrlParseTestCase.test_urlsplit_normalizationN),r6r7r8r1r=rArnr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr%r&r)r.r2r<r?r@rArBrErFrJr^rpr/r/r/r0rSsR3	
#&0-972	])!



rc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
Utility_Testsz=Testcase to test the various utility functions in the urllib.cCs\tjj}|j|d�d	�|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�dS)Nztype:opaquestringr��opaquestring�
:opaquestringztype:rztype:opaque:string�
opaque:string)r�rr)Nrr)Nrs)r�r)r�rt)rrrRr)r)rRr/r/r0�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#)rvrw)rvr)Nrw)rxry)rxrz)r{ry)rr|)r}r~)r}r)r}r�)rrrLr)r)rLr/r/r0�test_splithosts*









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�)rrrSr)r)rSr/r/r0�test_splituser#s




zUtility_Tests.test_splitusercCs�tjj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d
�d�|j|d�d�|j|d�d �|j|d�d!�|j|d�d"�|j|d�d#�|j|d�d$�|j|d�d%�|j|d�d&�dS)'Nzuser:ab�user�abzuser:a
b�a
bzuser:a	b�a	bzuser:a
b�a
bzuser:ab�abzuser:ab�abzuser:a:b�a:bzuser:a b�a bz	user 2:ab�user 2z
user+1:a+b�user+1�a+bzuser:rz:ab)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r)r�N)rr�)rrrNr)r)rNr/r/r0�test_splitpasswd0szUtility_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�)rrrOr)r)rOr/r/r0�test_splitportBszUtility_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��Xr3�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)rrrMr)r)rMr/r/r0�test_splitnportMszUtility_Tests.test_splitnportcCsLtjj}|j|d�d�|j|d�d�|j|d�d	�|j|d�d
�dS)N�http://python.org/fake?foo=bar�http://python.org/fake�foo=barzhttp://python.org/fake?foo=bar?rz?foo=bar)r�r�)r�r)r�N)rr�)rrrPr)r)rPr/r/r0�test_splitqueryYs


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�)rrrQr)r)rQr/r/r0�
test_splittages



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

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�)rrrTr)r)rTr/r/r0�test_splitvaluezszUtility_Tests.test_splitvaluecCs.tjjd�}|j|d�|jttjjd�dS)Nzhttp://www.python.orguhttp://www.python.org/mediæval)rrrUrr��UnicodeError)r)r-r/r/r0�
test_to_bytes�szUtility_Tests.test_to_bytescCstjjd�}|j|d�dS)Nz<URL:type://host/path>ztype://host/path)rrrVr)r)r*r/r/r0�test_unwrap�szUtility_Tests.test_unwrapN)r6r7r8�__doc__rur�r�r�r�r�r�r�r�r�r�r�r/r/r/r0rq�s
	
rq�__main__)rr)rr)rr)rr)rr)rr)rr)rr	)rr
)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr)rr	)rr
)rr)rr)rr)rr)rr)rnrcZunittestZurllib.parserr�r�r�r�r8r?ZTestCaserrqr6�mainr/r/r/r0�<module>s�






.


Youez - 2016 - github.com/yon3zu
LinuXploit