B
    u9aËâ  ã            !   @   s¢  d dl Z d dlZd dlZd dlZdZdZdZdZdg fdg fdg fdd	gfd
dgfddgfddgfddgfdddgfdddgfdg fdg fdg fddgfddgfddgfd dgfd!d"gfd#d$d%gfd&d'd(gfd)g fd*g fd+dgfd,ddgfd-ddgfd.g fd/g fd0d"gfd1d$d%gfd2d'd(gfgZ	di fdi fdi fdddgifd
ddgifdddgifdddgifddd3gifdd4gd5gdœfddd6d7gifdi fdi fdi fdddgifdddgifdddgifd ddgifd!dd8gifd#d9gd:gd"œfd&dd;d<gifd)i fd*i fd+dd3gifd,d4gd5gdœfd-dd6d7gifd.i fd/i fd0dd8gifd1d9gd:gd"œfd2dd;d<gifgZ
G d=d>„ d>ejƒZG d?d@„ d@ejƒZedAkrže ¡  dS )Bé    Nzhttp://a/b/c/d;p?q#fzhttp://a/b/c/d;p?qzhttp://a/b/c/dÚ ú&z&&ú=)r   r   z=a)r   Úar   )r   r   za=z&a=b)r   Úbza=a+b&b=b+c)r   za b)r   zb cza=1&a=2)r   Ú1)r   Ú2ó    ó   &s   &&ó   =)r	   r	   s   =a)r	   ó   ar   )r   r	   s   a=s   &a=b)r   ó   bs   a=a+b&b=b+c)r   s   a b)r   s   b cs   a=1&a=2)r   ó   1)r   ó   2ú;z;;z;a=bza=a+b;b=b+cza=1;a=2ó   ;s   ;;s   ;a=bs   a=a+b;b=b+cs   a=1;a=2r   za bzb cr   r   r   s   a bs   b cr   r   c               @   sT  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;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ÚUrlParseTestCasec             C   s`  t j |¡}|  ||¡ |j|j|j|j|j|j	f}|  ||¡ t j 
|¡}|  ||¡ |  || ¡ ¡ t j | ¡ ¡}|  | ¡ | ¡ ¡ |  ||¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  |j	|j	¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ t j |¡}|  ||¡ |j|j|j|j|j	f}|  ||¡ t j |¡}|  ||¡ |  || ¡ ¡ t j | ¡ ¡}|  | ¡ | ¡ ¡ |  ||¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  |j	|j	¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ d S )N)ÚurllibÚparseÚurlparseÚassertEqualÚschemeÚnetlocÚpathÚparamsÚqueryÚfragmentÚ
urlunparseÚgeturlÚusernameÚpasswordÚhostnameÚportÚurlsplitÚ
urlunsplit)ÚselfÚurlÚparsedÚsplitÚresultÚtZresult2Zresult3© r+   ú#/usr/lib/python3.7/test_urlparse.pyÚcheckRoundtripsU   sR    z UrlParseTestCase.checkRoundtripsc             C   sh   xbt D ]Z\}}tjj|dd}|  ||d| ¡ dd„ |D ƒ}tjj|dd}|  ||d| ¡ qW d S )NT)Úkeep_blank_valueszError parsing %rc             S   s   g | ]}t |d  ƒr|‘qS )é   )Úlen)Ú.0Úvr+   r+   r,   ú
<listcomp>Œ   s    z-UrlParseTestCase.test_qsl.<locals>.<listcomp>F)Úparse_qsl_test_casesr   r   Ú	parse_qslr   )r%   ÚorigÚexpectr)   Úexpect_without_blanksr+   r+   r,   Útest_qslˆ   s    zUrlParseTestCase.test_qslc                sl   xft D ]^\}‰ tjj|dd}|  |ˆ d| ¡ ‡ fdd„ˆ D ƒ}tjj|dd}|  ||d| ¡ qW d S )NT)r.   zError parsing %rc                s&   i | ]}t ˆ | d  ƒrˆ | |“qS )r   )r0   )r1   r2   )r7   r+   r,   ú
<dictcomp>•   s   z,UrlParseTestCase.test_qs.<locals>.<dictcomp>F)Úparse_qs_test_casesr   r   Úparse_qsr   )r%   r6   r)   r8   r+   )r7   r,   Útest_qs‘   s    
zUrlParseTestCase.test_qsc                sT   ddddddg}dd„ ‰ ‡ fd	d
„|D ƒ}x$|| D ]\}}}|   |||¡ q4W d S )N)zfile:///tmp/junk.txt)Úfiler   z/tmp/junk.txtr   r   r   )r>   r   z/tmp/junk.txtr   r   )zimap://mail.python.org/mbox1)Úimapzmail.python.orgz/mbox1r   r   r   )r?   zmail.python.orgz/mbox1r   r   )z1mms://wms.sys.hinet.net/cts/Drama/09006251100.asf)Úmmszwms.sys.hinet.netz/cts/Drama/09006251100.asfr   r   r   )r@   zwms.sys.hinet.netz/cts/Drama/09006251100.asfr   r   )znfs://server/path/to/file.txt)ÚnfsÚserverz/path/to/file.txtr   r   r   )rA   rB   z/path/to/file.txtr   r   )z0svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/)zsvn+sshzsvn.zope.orgz/repos/main/ZConfig/trunk/r   r   r   )zsvn+sshzsvn.zope.orgz/repos/main/ZConfig/trunk/r   r   )z)git+ssh://git@github.com/user/project.git)zgit+sshzgit@github.comz/user/project.gitr   r   r   )zgit+sshzgit@github.comz/user/project.gitr   r   c             S   s8   | d   d¡tdd„ | d D ƒƒtdd„ | d D ƒƒfS )Nr   Úasciic             s   s   | ]}|  d ¡V  qdS )rC   N)Úencode)r1   Úxr+   r+   r,   ú	<genexpr>¸   s    zDUrlParseTestCase.test_roundtrips.<locals>._encode.<locals>.<genexpr>r/   c             s   s   | ]}|  d ¡V  qdS )rC   N)rD   )r1   rE   r+   r+   r,   rF   ¹   s    é   )rD   Útuple)r*   r+   r+   r,   Ú_encode¶   s    z1UrlParseTestCase.test_roundtrips.<locals>._encodec                s   g | ]}ˆ |ƒ‘qS r+   r+   )r1   rE   )rI   r+   r,   r3   º   s    z4UrlParseTestCase.test_roundtrips.<locals>.<listcomp>)r-   )r%   Ú	str_casesÚbytes_casesr&   r'   r(   r+   )rI   r,   Útest_roundtrips›   s    z UrlParseTestCase.test_roundtripsc                s¦   dddddg}dd„ ‰ ‡ fdd	„|D ƒ}d
}d}||f}||f}x`||fD ]T\}}xJ|D ]B}	x<|D ]4\}
}}|	|
 }
|	f| }|	f| }|   |
||¡ qbW qXW qJW d S )N)z://www.python.org)zwww.python.orgr   r   r   r   )zwww.python.orgr   r   r   )z://www.python.org#abc)zwww.python.orgr   r   r   Úabc)zwww.python.orgr   r   rM   )z://www.python.org?q=abc)zwww.python.orgr   r   zq=abcr   )zwww.python.orgr   zq=abcr   )z://www.python.org/#abc)zwww.python.orgú/r   r   rM   )zwww.python.orgrN   r   rM   )z://a/b/c/d;p?q#f)r   z/b/c/dÚpÚqÚf)r   z/b/c/d;prP   rQ   c             S   s8   | d   d¡tdd„ | d D ƒƒtdd„ | d D ƒƒfS )Nr   rC   c             s   s   | ]}|  d ¡V  qdS )rC   N)rD   )r1   rE   r+   r+   r,   rF   Õ   s    zIUrlParseTestCase.test_http_roundtrips.<locals>._encode.<locals>.<genexpr>r/   c             s   s   | ]}|  d ¡V  qdS )rC   N)rD   )r1   rE   r+   r+   r,   rF   Ö   s    rG   )rD   rH   )r*   r+   r+   r,   rI   Ó   s    z6UrlParseTestCase.test_http_roundtrips.<locals>._encodec                s   g | ]}ˆ |ƒ‘qS r+   r+   )r1   rE   )rI   r+   r,   r3   ×   s    z9UrlParseTestCase.test_http_roundtrips.<locals>.<listcomp>)ÚhttpÚhttps)s   https   https)r-   )r%   rJ   rK   Zstr_schemesZbytes_schemesZ	str_testsZbytes_testsZschemesZ
test_casesr   r&   r'   r(   r+   )rI   r,   Útest_http_roundtrips¾   s$    


z%UrlParseTestCase.test_http_roundtripsc       	      C   sR   |||f}|   tj ||¡|¡ dd„ |D ƒ }\}}}|   tj ||¡|¡ d S )Nc             S   s   g | ]}|  d ¡‘qS )rC   )rD   )r1   rE   r+   r+   r,   r3   è   s    z.UrlParseTestCase.checkJoin.<locals>.<listcomp>)r   r   r   Úurljoin)	r%   ÚbaseZrelurlÚexpectedZstr_componentsZbytes_componentsZbasebZrelurlbZ	expectedbr+   r+   r,   Ú	checkJoinä   s    
zUrlParseTestCase.checkJoinc             C   sn   dddddddg}dd	„ |D ƒ}xH|| D ]<}|   tj tj |¡¡|¡ |   tj tj |¡¡|¡ q*W d S )
NÚPythonz./Pythonzx-newscheme://foo.com/stuffzx://yzx:/yzx:/rN   c             S   s   g | ]}|  d ¡‘qS )rC   )rD   )r1   rE   r+   r+   r,   r3   í   s    z7UrlParseTestCase.test_unparse_parse.<locals>.<listcomp>)r   r   r   r$   r#   r   r   )r%   rJ   rK   Úur+   r+   r,   Útest_unparse_parseë   s
    z#UrlParseTestCase.test_unparse_parsec             C   s¶  |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   td	d
¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   td d¡ |   td!d"¡ |   td#d$¡ |   td%d$¡ |   td&d¡ |   td'd(¡ |   td)d*¡ |   td+d,¡ |   td-d.¡ |   td/d0¡ |   td1d"¡ |   td2d¡ |   td3d4¡ |   td5d6¡ d S )7Nzg:hÚgzhttp://a/b/c/gz./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gzg?yzhttp://a/b/c/g?yzg?y/./xzhttp://a/b/c/g?y/./xz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg#s/./xzhttp://a/b/c/g#s/./xzg?y#szhttp://a/b/c/g?y#szg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#sÚ.zhttp://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../z../../gr   zhttp://a/b/c/d;p?q#fzg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/h)rX   ÚRFC1808_BASE)r%   r+   r+   r,   Útest_RFC1808ò   s>    zUrlParseTestCase.test_RFC1808c             C   s   |   tj d¡d¡ d S )Nzmailto:1337@example.org)Zmailtor   z1337@example.orgr   r   r   )r   r   r   r   )r%   r+   r+   r,   Útest_RFC2368"  s    zUrlParseTestCase.test_RFC2368c             C   sî  |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   td	d
¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd ¡ |   td!d ¡ |   td"d¡ |   td#t¡ |   td$d%¡ |   td&d'¡ |   td(d)¡ |   td*d+¡ |   td,d¡ |   td-d¡ |   td.d/¡ |   td0d1¡ |   td2d3¡ |   td4d5¡ |   td6d7¡ |   td8d9¡ |   td:d;¡ |   td<d=¡ d S )>Nzg:hr\   zhttp://a/b/c/gz./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gzg?yzhttp://a/b/c/g?yz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg?y#szhttp://a/b/c/g?y#szg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#sr]   zhttp://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../z../../gr   zg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hz	g;x=1/./yzhttp://a/b/c/g;x=1/yz
g;x=1/../yzhttp://a/b/c/yzg?y/./xzhttp://a/b/c/g?y/./xzg?y/../xzhttp://a/b/c/g?y/../xzg#s/./xzhttp://a/b/c/g#s/./xzg#s/../xzhttp://a/b/c/g#s/../x)rX   ÚRFC2396_BASE)r%   r+   r+   r,   Útest_RFC2396'  sF    zUrlParseTestCase.test_RFC2396c             C   sˆ  |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   td	d
¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   td d!¡ |   td"d!¡ |   td#d$¡ |   td%d&¡ |   td'd&¡ |   td(d¡ |   td)d¡ |   td)d¡ |   td*d¡ |   td+d¡ |   td,d¡ |   td-d.¡ |   td/d0¡ |   td1d2¡ |   td3d4¡ |   td5d$¡ |   td6d
¡ |   td7d8¡ |   td9d:¡ |   td;d<¡ |   td=d>¡ |   td?d@¡ |   tdAdB¡ |   tdCdD¡ |   tdEdF¡ |   tdGd¡ |   dHdd¡ d S )INz?yzhttp://a/b/c/d;p?yz;xzhttp://a/b/c/;xzg:hr\   zhttp://a/b/c/gz./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gzg?yzhttp://a/b/c/g?yz#szhttp://a/b/c/d;p?q#szg#szhttp://a/b/c/g#szg?y#szhttp://a/b/c/g?y#szg;xzhttp://a/b/c/g;xzg;x?y#szhttp://a/b/c/g;x?y#sr   zhttp://a/b/c/d;p?qr]   zhttp://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../z../../gz
../../../gz../../../../gz/./gz/../gzg.zhttp://a/b/c/g.z.gzhttp://a/b/c/.gzg..zhttp://a/b/c/g..z..gzhttp://a/b/c/..gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hz	g;x=1/./yzhttp://a/b/c/g;x=1/yz
g;x=1/../yzhttp://a/b/c/yzg?y/./xzhttp://a/b/c/g?y/./xzg?y/../xzhttp://a/b/c/g?y/../xzg#s/./xzhttp://a/b/c/g#s/./xzg#s/../xzhttp://a/b/c/g#s/../xzhttp:gzhttp://a/b/c/de)rX   ÚRFC3986_BASE)r%   r+   r+   r,   Útest_RFC3986T  s\    zUrlParseTestCase.test_RFC3986c             C   sX  |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd	¡ |   td
d¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   tdd¡ |   td d	¡ |   td!d"¡ |   td#d$¡ |   tdd¡ |   tdd¡ |   td%d¡ |   td&d¡ |   td'd¡ |   d(dd(¡ |   d)dd¡ |   d)d*d*¡ |   d+d,d-¡ |   d.d,d/¡ |   d0dd1¡ |   d2dd3¡ |   td4 d5td6 ¡ |   d7d8d9¡ |   d:d8d;¡ |   d7d<d=¡ |   d:d<d=¡ |   d7d>d?¡ |   dd8d=¡ |   d@dAdA¡ d S )BNzg:hzhttp:gzhttp://a/b/c/gzhttp:zhttp://a/b/c/dr\   z./gzg/zhttp://a/b/c/g/z/gz
http://a/gz//gzhttp://gz?yzhttp://a/b/c/d?yzg?yzhttp://a/b/c/g?yzg?y/./xzhttp://a/b/c/g?y/./xr]   zhttp://a/b/c/z./z..zhttp://a/b/z../z../gzhttp://a/b/gz../..z	http://a/z../../gz./../gz./g/.zg/./hzhttp://a/b/c/g/hzg/../hzhttp://a/b/c/hzhttp:?yzhttp:g?yzhttp:g?y/./xzhttp:///r   zhttp://a/./gzsvn://pathtorepo/dir1Zdir2zsvn://pathtorepo/dir2zsvn+ssh://pathtorepo/dir1zsvn+ssh://pathtorepo/dir2zws://a/bzws://a/gz	wss://a/bz	wss://a/grN   Úfooz/foozhttp://a/b/c/d/e/z
../../f/g/zhttp://a/b/c/f/g/zhttp://a/b/c/d/ezhttp://a/b/f/g/z/../../f/g/zhttp://a/f/g/z	../../f/gzhttp://a/b/c/f/gr   r   )rX   ÚSIMPLE_BASE)r%   r+   r+   r,   Útest_urljoins  sT    zUrlParseTestCase.test_urljoinsc                sÎ   ddddddddd	d
ddddddddddddddg}dd„ ‰ ‡ fdd„|D ƒ}x:|| D ].\}}}t j |¡}|  |j|jf||f¡ qXW dddd d!g}d"d„ |D ƒ}x"|| D ]}|  tt jj|¡ q°W d S )#N)z http://Test.python.org:5432/foo/ztest.python.orgi8  )zhttp://12.34.56.78:5432/foo/z12.34.56.78i8  )zhttp://[::1]:5432/foo/z::1i8  )zhttp://[dead:beef::1]:5432/foo/zdead:beef::1i8  )zhttp://[dead:beef::]:5432/foo/zdead: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  )zhttp://Test.python.org/foo/ztest.python.orgN)zhttp://12.34.56.78/foo/z12.34.56.78N)zhttp://[::1]/foo/z::1N)zhttp://[dead:beef::1]/foo/zdead:beef::1N)zhttp://[dead:beef::]/foo/zdead:beef::N)z5http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/z'dead:beef:cafe:5417:affe:8fa3:deaf:feedN)zhttp://[::12.34.56.78]/foo/z::12.34.56.78N)z http://[::ffff:12.34.56.78]/foo/z::ffff:12.34.56.78N)zhttp://Test.python.org:/foo/ztest.python.orgN)zhttp://12.34.56.78:/foo/z12.34.56.78N)zhttp://[::1]:/foo/z::1N)zhttp://[dead:beef::1]:/foo/zdead:beef::1N)zhttp://[dead:beef::]:/foo/zdead:beef::N)z6http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:/foo/z'dead:beef:cafe:5417:affe:8fa3:deaf:feedN)zhttp://[::12.34.56.78]:/foo/z::12.34.56.78N)z!http://[::ffff:12.34.56.78]:/foo/z::ffff:12.34.56.78Nc             S   s"   | d   d¡| d   d¡| d fS )Nr   rC   r/   rG   )rD   )r*   r+   r+   r,   rI   å  s    z.UrlParseTestCase.test_RFC2732.<locals>._encodec                s   g | ]}ˆ |ƒ‘qS r+   r+   )r1   rE   )rI   r+   r,   r3   ç  s    z1UrlParseTestCase.test_RFC2732.<locals>.<listcomp>zhttp://::12.34.56.78]/zhttp://[::1/foo/zftp://[::1/foo/bad]/badzhttp://[::1/foo/bad]/badzhttp://[::ffff:12.34.56.78c             S   s   g | ]}|  d ¡‘qS )rC   )rD   )r1   rE   r+   r+   r,   r3   ò  s    )r   r   r   r   r!   r"   ÚassertRaisesÚ
ValueError)r%   rJ   rK   r&   r!   r"   Z	urlparsedZinvalid_urlr+   )rI   r,   Útest_RFC2732Ä  sJ    zUrlParseTestCase.test_RFC2732c                s¢   ddddddddt d	d
ftd	dfg
}dd„ ‰ ‡ fdd„|D ƒ}x^|| D ]R\}}}tj |¡}|  | ¡ |¡ |  |||f¡ |  |j|¡ |  |j|¡ qHW d S )N)zhttp://python.org#fragzhttp://python.orgÚfrag)zhttp://python.orgzhttp://python.orgr   )zhttp://python.org/#fragzhttp://python.org/rk   )zhttp://python.org/zhttp://python.org/r   )zhttp://python.org/?q#fragzhttp://python.org/?qrk   )zhttp://python.org/?qzhttp://python.org/?qr   )zhttp://python.org/p#fragzhttp://python.org/prk   )zhttp://python.org/p?qzhttp://python.org/p?qr   zhttp://a/b/c/d;p?qrQ   r   c             S   s   t | ƒdd„ | D ƒƒS )Nc             s   s   | ]}|  d ¡V  qdS )rC   N)rD   )r1   rE   r+   r+   r,   rF     s    zCUrlParseTestCase.test_urldefrag.<locals>._encode.<locals>.<genexpr>)Útype)r*   r+   r+   r,   rI     s    z0UrlParseTestCase.test_urldefrag.<locals>._encodec                s   g | ]}ˆ |ƒ‘qS r+   r+   )r1   rE   )rI   r+   r,   r3     s    z3UrlParseTestCase.test_urldefrag.<locals>.<listcomp>)	r^   ra   r   r   Z	urldefragr   r   r&   r   )r%   rJ   rK   r&   Zdefragrk   r)   r+   )rI   r,   Útest_urldefragö  s$    zUrlParseTestCase.test_urldefragc             C   sT   t j d¡}|  |jd¡ |  |jd¡ t j d¡}|  |jd¡ |  |jd¡ d S )Nz,http://[FE80::822a:a8ff:fe49:470c%tESt]:1234zfe80::822a:a8ff:fe49:470c%tEStz%[FE80::822a:a8ff:fe49:470c%tESt]:1234s,   http://[FE80::822a:a8ff:fe49:470c%tESt]:1234s   fe80::822a:a8ff:fe49:470c%tESts%   [FE80::822a:a8ff:fe49:470c%tESt]:1234)r   r   r#   r   r!   r   )r%   rO   r+   r+   r,   Útest_urlsplit_scoped_IPv6  s    z*UrlParseTestCase.test_urlsplit_scoped_IPv6c          	   C   s  d}t j |¡}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |j	d ¡ |  |j
d ¡ |  |jd¡ |  |jd ¡ |  | ¡ dd … |dd … ¡ d	}t j |¡}|  |jd¡ |  |jd
¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |j	d¡ |  |j
d¡ |  |jd¡ |  |jd¡ |  | ¡ |¡ d}t j |¡}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |j	d¡ |  |j
d¡ |  |jd¡ |  |jd¡ |  | ¡ |¡ d}t j |¡}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |j	d ¡ |  |j
d ¡ |  |jd¡ |  |jd ¡ |  | ¡ dd … |dd … ¡ d}t j |¡}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |j	d¡ |  |j
d¡ |  |jd¡ |  |jd¡ |  | ¡ |¡ d}t j |¡}|  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |jd¡ |  |j	d ¡ |  |j
d¡ |  |jd¡ |  |jd¡ |  | ¡ |¡ d!}t j |¡}|  td"¡ |j W d Q R X d S )#NzHTTP://WWW.PYTHON.ORG/doc/#fragrR   zWWW.PYTHON.ORGz/doc/r   rk   zwww.python.orgé   z7http://User:Pass@www.python.org:080/doc/?query=yes#fragzUser:Pass@www.python.org:080z	query=yesZUserZPasséP   zChttp://User@example.com:Pass@www.python.org:080/doc/?query=yes#fragz(User@example.com:Pass@www.python.org:080zUser@example.coms   HTTP://WWW.PYTHON.ORG/doc/#frags   https   WWW.PYTHON.ORGs   /doc/r	   s   frags   www.python.orgs7   http://User:Pass@www.python.org:080/doc/?query=yes#frags   User:Pass@www.python.org:080s	   query=yess   Users   PasssC   http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frags(   User@example.com:Pass@www.python.org:080s   User@example.coms%   HTTP://WWW.PYTHON.ORG:65536/doc/#fragzout of range)r   r   r#   r   r   r   r   r   r   r   r    r!   r"   r   ÚassertRaisesRegexri   )r%   r&   rO   r+   r+   r,   Útest_urlsplit_attributes  s˜      z)UrlParseTestCase.test_urlsplit_attributesc             C   s°   xªdD ]¢}xœt jjt jjfD ]ˆ}x‚dD ]z}| j|||d` d| }d| }|rd| d¡}| d¡}||ƒ}|  |j|¡ |  t	¡ |j
 W d Q R X W d Q R X q&W qW qW d S )N)FT)re   z1.5z-1Z0x10)Úbytesr   r"   zwww.example.net:zhttp://rC   )r   r   r#   r   ÚsubTestrD   r   r   rh   ri   r"   )r%   rs   r   r"   r   r&   rO   r+   r+   r,   Útest_attributes_bad_ports  s    



z)UrlParseTestCase.test_attributes_bad_portc             C   s”  d}t j |¡}|  |jd¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  | 	¡ |¡ t j 
|¡}|  |jd¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  | 	¡ |¡ d}t j |¡}|  |jd¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  | 	¡ |¡ t j 
|¡}|  |jd¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  |jd ¡ |  | 	¡ |¡ d S )Nz0sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15r   s0   sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15r	   )r   r   r#   r   r   r   r    r!   r"   r   r   )r%   ZurirO   r+   r+   r,   Útest_attributes_without_netlocƒ  s<    z/UrlParseTestCase.test_attributes_without_netlocc             C   s,   |   tj d¡d¡ |   tj d¡d¡ d S )Nz http://example.com?blahblah=/foo)rR   zexample.comr   r   zblahblah=/foor   s    http://example.com?blahblah=/foo)s   https   example.comr	   r	   s   blahblah=/foor	   )r   r   r   r   )r%   r+   r+   r,   Útest_noslash¬  s    zUrlParseTestCase.test_noslashc             C   s|   |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d	¡d
¡ |   tj d¡d¡ d S )Nr   )r   r   r   r   r   r   z//www.python.org:80)r   zwww.python.org:80r   r   r   r   zhttp://www.python.org:80)rR   zwww.python.org:80r   r   r   r   s   path)r	   r	   s   pathr	   r	   r	   s   //www.python.org:80)r	   s   www.python.org:80r	   r	   r	   r	   s   http://www.python.org:80)s   https   www.python.org:80r	   r	   r	   r	   )r   r   r   r   )r%   r+   r+   r,   Útest_withoutscheme³  s    z#UrlParseTestCase.test_withoutschemec             C   s¤   |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d	¡d
¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ d S )Nzpath:80)r   r   zpath:80r   r   r   zhttp:)rR   r   r   r   r   r   zhttps:)rS   r   r   r   r   r   zhttp://www.python.org:80)rR   zwww.python.org:80r   r   r   r   s   path:80)r	   r	   s   path:80r	   r	   r	   s   http:)s   httpr	   r	   r	   r	   r	   s   https:)s   httpsr	   r	   r	   r	   r	   s   http://www.python.org:80)s   https   www.python.org:80r	   r	   r	   r	   )r   r   r   r   )r%   r+   r+   r,   Útest_portseparatorÆ  s    z#UrlParseTestCase.test_portseparatorc             C   s   |   ttjjd¡ d S )Nre   )rh   Ú	TypeErrorr   r   Ú	urlencode)r%   r+   r+   r,   Útest_usingsysÖ  s    zUrlParseTestCase.test_usingsysc             C   s¤   |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d	¡d
¡ |   tj d¡d¡ |   tj d¡d¡ |   tj d¡d¡ d S )Nzs3://foo.com/stuff)Zs3zfoo.comz/stuffr   r   r   zx-newscheme://foo.com/stuff)zx-newschemezfoo.comz/stuffr   r   r   z*x-newscheme://foo.com/stuff?query#fragment)zx-newschemezfoo.comz/stuffr   r   r   z!x-newscheme://foo.com/stuff?query)zx-newschemezfoo.comz/stuffr   r   r   s   s3://foo.com/stuff)s   s3s   foo.coms   /stuffr	   r	   r	   s   x-newscheme://foo.com/stuff)s   x-newschemes   foo.coms   /stuffr	   r	   r	   s*   x-newscheme://foo.com/stuff?query#fragment)s   x-newschemes   foo.coms   /stuffr	   s   querys   fragments!   x-newscheme://foo.com/stuff?query)s   x-newschemes   foo.coms   /stuffr	   s   queryr	   )r   r   r   r   )r%   r+   r+   r,   Útest_anyschemeÚ  s     zUrlParseTestCase.test_anyschemec          
   C   sÞ   xØt jjt jjfD ]Ä}| j|d® |ddƒ}|  |jd¡ |ddƒ}|  |jd¡ |  |ddƒjd¡ |  |ddd	jd¡ |  |d
dd	jd¡ |  |dƒjd¡ |  |d
ƒjd¡ |  |d
dƒjd¡ W d Q R X qW d S )N)Úfunctionzhttp://example.net/ÚftprR   s   http://example.net/s   ftps   httpr   )r   s   pathr   r	   )r   r   r   r#   rt   r   r   )r%   Úfuncr)   r+   r+   r,   Útest_default_schemeï  s    

z$UrlParseTestCase.test_default_schemec             C   s  d}x |D ]ø\}}}xìt jjt jjfD ]Ø}|dkrD|t jjkrDd}| j||d¨ ||dd}|  |jd¡ |  t||ƒ 	d| ¡¡ |  ||ddƒjd¡ ||d	d}|  |j|¡ |  
t||ƒ 	|¡¡ |  ||dd	ƒj|¡ |  ||ƒj|¡ W d Q R X q(W qW d S )
N)
)z
http:#fragr   rk   )z//example.net#fragr   rk   )zindex.html#fragr   rk   )z	;a=b#fragr   rk   )z	?a=b#fragr   rk   )z#fragr   rk   )z	abc#@fragr   z@frag)z//abc#@fragr   z@frag)z//abc:80#@fragr   z@frag)z//abc#@frag:80r   z@frag:80r   r   )r&   r~   F)Zallow_fragmentsr   ú#T)r   r   r   r#   rt   r   r   Z
assertTrueÚgetattrÚendswithZassertFalse)r%   Ztestsr&   ÚattrZexpected_fragr€   r)   r+   r+   r,   Útest_parse_fragmentsþ  s$    z%UrlParseTestCase.test_parse_fragmentsc          	   C   sx  |   td¡ tj dd¡ W d Q R X |   td¡ tj dd¡ W d Q R X |   td¡ tj dd¡ W d Q R X |   td¡ tj dd¡ W d Q R X |   td¡ tj d¡ W d Q R X |   td¡ tj d¡ W d Q R X |   td¡ tj d¡ W d Q R X |   td¡ tj d	¡ W d Q R X |   td¡ tj d
d¡ W d Q R X |   td¡ tj dd
¡ W d Q R X d S )NzCannot mix strzwww.python.orgs   https   www.python.orgrR   )s   httpzwww.python.orgr   r   r   r   )rR   s   www.python.orgr   r   r   r   )s   httpzwww.python.orgr   r   r   )rR   s   www.python.orgr   r   r   zhttp://python.orgs   http://python.org)	rq   rz   r   r   r   r#   r   r$   rU   )r%   r+   r+   r,   Útest_mixed_types_rejected  s(    z*UrlParseTestCase.test_mixed_types_rejectedc       
      C   s:  t |jƒ}|j}|  |j|¡ d| }d| }||Ž }||Ž }d}d}	|  ||¡ |  | ¡ |¡ |  | ¡ |¡ |  | |¡|¡ |  | |¡|¡ |  | ||	¡|¡ |  | ||	¡|¡ |  ||¡ |  | ¡ |¡ |  | ¡ |¡ |  | |¡|¡ |  | |¡|¡ |  | ||	¡|¡ |  | ||	¡|¡ d S )N)r   )r	   rC   Ústrict)r0   Ú_fieldsZ_encoded_counterpartZassertIsZ_decoded_counterpartr   ÚdecoderD   )
r%   Zstr_typeZnum_argsZ
bytes_typeZstr_argsZ
bytes_argsZ
str_resultZbytes_resultÚencodingÚerrorsr+   r+   r,   Ú_check_result_type7  s.    
z#UrlParseTestCase._check_result_typec             C   s2   t jjt jjt jjg}x|D ]}|  |¡ qW d S )N)r   r   ZDefragResultZSplitResultZParseResultr   )r%   Zresult_typesZresult_typer+   r+   r,   Útest_result_pairsP  s
    

z"UrlParseTestCase.test_result_pairsc             C   s°   t jjddd}|  |ddgi¡ t jjddd}|  |ddgi¡ t jjddd}|  |dd	gi¡ t jjd
dd}|  |ddgi¡ t jjd
ddd}|  |ddgi¡ d S )Nu	   key=Å%E9zlatin-1)r‹   Úkeyu   ÅÃ©u   key=Å%C3%A9zutf-8rC   u   Åï¿½ï¿½u
   key=Å%E9-u   Åï¿½-Úignore)r‹   rŒ   u   Å-)r   r   r<   r   )r%   r)   r+   r+   r,   Útest_parse_qs_encodingZ  s    
z'UrlParseTestCase.test_parse_qs_encodingc             C   sœ   t jjddd}|  |dg¡ t jjddd}|  |dg¡ t jjddd}|  |dg¡ t jjd	dd}|  |d
g¡ t jjd	ddd}|  |dg¡ d S )Nu	   key=Å%E9zlatin-1)r‹   )r   u   ÅÃ©u   key=Å%C3%A9zutf-8rC   )r   u   Åï¿½ï¿½u
   key=Å%E9-)r   u   Åï¿½-r   )r‹   rŒ   )r   u   Å-)r   r   r5   r   )r%   r)   r+   r+   r,   Útest_parse_qsl_encodingg  s    
z(UrlParseTestCase.test_parse_qsl_encodingc          	   C   s„   |   t¡" tjjd dgd ¡dd W d Q R X |   t¡" tjjd dgd ¡dd W d Q R X tjjd dgd ¡dd d S )Nr   za=aé   é
   )Zmax_num_fieldsr   )rh   ri   r   r   r<   Újoin)r%   r+   r+   r,   Útest_parse_qsl_max_num_fieldst  s
    &&z.UrlParseTestCase.test_parse_qsl_max_num_fieldsc             C   sJ   t j ddgddœd¡}G dd„ dƒ}t j d|ƒ id¡}|  |d	¡ d S )
Nr/   rG   )é   ro   é   )r   r   Tc               @   s   e Zd Zdd„ ZdS )z:UrlParseTestCase.test_urlencode_sequences.<locals>.Trivialc             S   s   dS )NZtrivialr+   )r%   r+   r+   r,   Ú__str__ƒ  s    zBUrlParseTestCase.test_urlencode_sequences.<locals>.Trivial.__str__N)Ú__name__Ú
__module__Ú__qualname__r™   r+   r+   r+   r,   ÚTrivial‚  s   r   r   z	a=trivial)r   r   r{   r   )r%   r)   r   r+   r+   r,   Útest_urlencode_sequences{  s    z)UrlParseTestCase.test_urlencode_sequencesc             C   sj   t j ddi¡}|  |d¡ t jjddit jjd}|  |d¡ t jjddidt jjd}|  |d	¡ d S )
Nr   z
some valueza=some+valuezsome value/another)Ú	quote_viaza=some%20value%2FanotherrN   )ZsaferŸ   za=some%20value/another)r   r   r{   r   Úquote)r%   r)   r+   r+   r,   Útest_urlencode_quote_via‰  s    z)UrlParseTestCase.test_urlencode_quote_viac             C   sF   |   ttjjd¡ tj d¡}|  |d¡ tj d¡}|  |d¡ d S )Nre   s   archaeological arcanazarchaeological%20arcanar	   r   )rh   rz   r   r   Zquote_from_bytesr   )r%   r)   r+   r+   r,   Útest_quote_from_bytes“  s
    z&UrlParseTestCase.test_quote_from_bytesc             C   s4   t j d¡}|  |d¡ t j d¡}|  |d¡ d S )Nz	abc%20defs   abc defr   r	   )r   r   Zunquote_to_bytesr   )r%   r)   r+   r+   r,   Útest_unquote_to_bytesš  s    z&UrlParseTestCase.test_unquote_to_bytesc             C   s0   | j ttjjddd | j ttjjddd d S )Ns   foozutf-8)r‹   rˆ   )rŒ   )rh   rz   r   r   r    )r%   r+   r+   r,   Útest_quote_errors   s    z"UrlParseTestCase.test_quote_errorsc             C   s¤   t j d¡}|  |jd¡ |  |jd¡ t j d¡}|  |jd¡ |  |jd¡ t j d¡}|  |jd¡ |  |jd¡ t j d¡}|  |jd¡ |  |jd¡ d S )Nztel:+31-641044153Útelz+31-641044153ztel:+31641044153z+31641044153)r   r   r#   r   r   r   r   )r%   Úp1Zp2r+   r+   r,   Útest_issue14072¥  s    z UrlParseTestCase.test_issue14072c             C   sÜ   t j d¡}|  |jd¡ |  |jd¡ |  |jd¡ t j d¡}|  |jd¡ |  |jd¡ |  |jd¡ t j d¡}|  |jd¡ |  |jd	¡ |  |jd
¡ t j d¡}|  |jd¡ |  |jd¡ |  |jd¡ d S )Nz"tel:123-4;phone-context=+1-650-516r¥   z123-4zphone-context=+1-650-516ztel:+1-201-555-0123z+1-201-555-0123r   z"tel:7042;phone-context=example.comZ7042zphone-context=example.comz%tel:863-1234;phone-context=+1-914-555z863-1234zphone-context=+1-914-555)r   r   r   r   r   r   r   )r%   r¦   r+   r+   r,   Útest_telurl_params´  s     z#UrlParseTestCase.test_telurl_paramsc             C   s$   t j t jj¡}|  dt|ƒ¡ d S )NÚQuoter)r   r   r©   Z_ALWAYS_SAFEÚassertInÚrepr)r%   Zquoterr+   r+   r,   Útest_Quoter_reprÉ  s    z!UrlParseTestCase.test_Quoter_reprc             C   sˆ   g }ddddddddd	d
dddddh}xLt tjƒD ]>}| d¡s2||krJq2ttj|ƒ}t|dd ƒdkr2| |¡ q2W |  tjj|¡ d S )NÚ	splitattrÚ	splithostÚ
splitnportÚsplitpasswdÚ	splitportÚ
splitqueryÚsplittagÚ	splittypeÚ	splituserÚ
splitvaluer©   Z
ResultBaseZclear_cacheÚto_bytesÚunwrapÚ_r›   zurllib.parse)Údirr   r   Ú
startswithrƒ   ÚappendZassertCountEqualÚ__all__)r%   rW   ZundocumentedÚnameÚobjectr+   r+   r,   Útest_allÍ  s    
zUrlParseTestCase.test_allc                s   d‰dd„ ˆD ƒ‰ ‡ ‡fdd„t ttdtjƒƒD ƒ}|  d|¡ |  d|¡ tj d	¡ |  	t
¡ tj d
¡ W d Q R X x€dD ]x}xrdD ]j}xd|D ]\}d || |¡¡}| j|d t|ƒ¡d( |  	t
¡ tj |¡ W d Q R X W d Q R X q”W qŠW q€W d S )Nz/:#?@c             S   s   h | ]}d   t|ƒ¡’qS )z{:04X})ÚformatÚord)r1   Úcr+   r+   r,   ú	<setcomp>â  s    z?UrlParseTestCase.test_urlsplit_normalization.<locals>.<setcomp>c                s.   g | ]&}ˆ t t |¡ ¡ ƒ@ r|ˆkr|‘qS r+   )ÚsetÚunicodedataÚdecompositionr(   )r1   rÃ   )Ú	hex_charsÚillegal_charsr+   r,   r3   ä  s    z@UrlParseTestCase.test_urlsplit_normalization.<locals>.<listcomp>é€   u   â„€u   ï¼ƒu   http://ãƒ•ã‚š:80u   http://ãƒ•ã‚šï¸“80)rR   rS   r   )znetloc{}false.netloczn{}user@netlocz{}://{}/pathz{:04X})r&   Úchar)ÚmapÚchrÚrangeÚsysÚ
maxunicoderª   r   r   r#   rh   ri   rÁ   rt   rÂ   )r%   Zdenorm_charsr   r   rÃ   r&   r+   )rÈ   rÉ   r,   Útest_urlsplit_normalizationÝ  s    "


z,UrlParseTestCase.test_urlsplit_normalizationN),rš   r›   rœ   r-   r9   r=   rL   rT   rX   r[   r_   r`   rb   rd   rg   rj   rm   rn   rr   ru   rv   rw   rx   ry   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   S   sR   3	
#&0-972	])!

r   c               @   sl   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )ÚUtility_Testsc             C   s\   t jj}|  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |d	ƒd
¡ d S )Nztype:opaquestring)rl   ÚopaquestringrÓ   )NrÓ   z:opaquestring)Nz:opaquestringztype:)rl   r   ztype:opaque:string)rl   zopaque:string)r   r   r´   r   )r%   r´   r+   r+   r,   Útest_splittypeþ  s    zUtility_Tests.test_splittypec             C   s¬   t jj}|  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |d	ƒd
¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ d S )Nz%//www.example.org:80/foo/bar/baz.html)zwww.example.org:80z/foo/bar/baz.htmlz//www.example.org:80)zwww.example.org:80r   z/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)r   z/filez//example.net/file;)zexample.netz/file;z//example.net/file?)zexample.netz/file?z//example.net/file#)zexample.netz/file#)r   r   r®   r   )r%   r®   r+   r+   r,   Útest_splithost  s*    









zUtility_Tests.test_splithostc             C   s\   t jj}|  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |d	ƒd
¡ d S )NzUser:Pass@www.python.org:080)z	User:Passzwww.python.org:080z@www.python.org:080)r   zwww.python.org:080zwww.python.org:080)Nzwww.python.org:080z
User:Pass@)z	User:Passr   z(User@example.com:Pass@www.python.org:080)zUser@example.com:Passzwww.python.org:080)r   r   rµ   r   )r%   rµ   r+   r+   r,   Útest_splituser#  s    




zUtility_Tests.test_splituserc             C   sÜ   t jj}|  |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¡ d S )Nzuser:ab)ÚuserÚabzuser:a
b)r×   za
bzuser:a	b)r×   za	bzuser:ab)r×   zabzuser:ab)r×   zabzuser:ab)r×   zabzuser:a:b)r×   za:bzuser:a b)r×   za bz	user 2:ab)zuser 2rØ   z
user+1:a+b)zuser+1za+bzuser:)r×   r   r×   )r×   Nz:ab)r   rØ   )r   r   r°   r   )r%   r°   r+   r+   r,   Útest_splitpasswd0  s    zUtility_Tests.test_splitpasswdc             C   sŒ   t jj}|  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd	¡ |  |d
ƒd¡ |  |dƒd¡ |  |dƒd¡ d S )Nz	parrot:88)ÚparrotÚ88rÚ   )rÚ   Nzparrot: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)r   rÛ   )r   r   r±   r   )r%   r±   r+   r+   r,   Útest_splitportB  s    zUtility_Tests.test_splitportc             C   s¤   t jj}|  |dƒd¡ |  |dƒd¡ |  |ddƒd¡ |  |dƒd¡ |  |ddƒd¡ |  |dƒd	¡ |  |ddƒd
¡ |  |dƒd¡ |  |ddƒd¡ d S )Nz	parrot:88)rÚ   éX   rÚ   )rÚ   éÿÿÿÿé7   )rÚ   rß   zparrot:z	127.0.0.1)z	127.0.0.1rÞ   )z	127.0.0.1rß   zparrot:cheese)rÚ   N)r   r   r¯   r   )r%   r¯   r+   r+   r,   Útest_splitnportM  s    zUtility_Tests.test_splitnportc             C   sL   t jj}|  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ d S )	Nzhttp://python.org/fake?foo=bar)zhttp://python.org/fakezfoo=barzhttp://python.org/fake?foo=bar?)zhttp://python.org/fake?foo=barr   zhttp://python.org/fake)zhttp://python.org/fakeNz?foo=bar)r   zfoo=bar)r   r   r²   r   )r%   r²   r+   r+   r,   Útest_splitqueryY  s    


zUtility_Tests.test_splitqueryc             C   s\   t jj}|  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |d	ƒd
¡ d S )Nzhttp://example.com?foo=bar#baz)zhttp://example.com?foo=barÚbazzhttp://example.com?foo=bar#)zhttp://example.com?foo=barr   z#baz)r   râ   zhttp://example.com?foo=bar)zhttp://example.com?foo=barNz"http://example.com?foo=bar#baz#boo)zhttp://example.com?foo=bar#bazZboo)r   r   r³   r   )r%   r³   r+   r+   r,   Útest_splittage  s    



zUtility_Tests.test_splittagc             C   sf   t jj}|  |dƒdddgf¡ |  |dƒddgf¡ |  |dƒdddgf¡ |  |dƒdg f¡ d S )Nz/path;attr1=value1;attr2=value2z/pathzattr1=value1zattr2=value2z/path;r   z;attr1=value1;attr2=value2)r   r   r­   r   )r%   r­   r+   r+   r,   Útest_splitattrq  s    

zUtility_Tests.test_splitattrc             C   s\   t jj}|  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |dƒd¡ |  |d	ƒd
¡ d S )Nzfoo=bar)re   Úbarzfoo=)re   r   z=bar)r   rå   Úfoobar)ræ   Nzfoo=bar=baz)re   zbar=baz)r   r   r¶   r   )r%   r¶   r+   r+   r,   Útest_splitvaluez  s    zUtility_Tests.test_splitvaluec             C   s.   t j d¡}|  |d¡ |  tt jjd¡ d S )Nzhttp://www.python.orgu   http://www.python.org/mediÃ¦val)r   r   r·   r   rh   ÚUnicodeError)r%   r)   r+   r+   r,   Útest_to_bytes„  s    zUtility_Tests.test_to_bytesc             C   s   t j d¡}|  |d¡ d S )Nz<URL:type://host/path>ztype://host/path)r   r   r¸   r   )r%   r&   r+   r+   r,   Útest_unwrapŠ  s    zUtility_Tests.test_unwrapN)rš   r›   rœ   rÔ   rÕ   rÖ   rÙ   rÜ   rà   rá   rã   rä   rç   ré   rê   r+   r+   r+   r,   rÒ   ú  s   	
rÒ   Ú__main__)rÏ   rÆ   ZunittestZurllib.parser   r^   ra   rc   rf   r4   r;   ZTestCaser   rÒ   rš   Úmainr+   r+   r+   r,   Ú<module>   sž   






       . 
