U
    ±[Öe?Õ  ã                (   @   sò   d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZmZ ejd  dkZed	ƒZd
ZdZ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&d'd(d)d*d+d,d-d.d/d0d1d2d3g(Zd4ZG d5d6„ d6eƒZdS )7é    )Úunicode_literalsN)ÚAnyÚIterableÚOptionalÚTextÚTupleÚcasté   )ÚHyperlinkTestCaseé   )ÚURLÚURLParseError)Ú	inet_ptonÚSCHEME_PORT_MAPÚ ú*http://www.foo.com/a/nice/path/?zot=23&zutúhttp://a/b/c/d;p?q)Úgúhttp://a/b/c/g)z./gr   )zg/úhttp://a/b/c/g/)z/gú
http://a/g)z//gzhttp://g)z?yzhttp://a/b/c/d;p?y)zg?yzhttp://a/b/c/g?y)z#szhttp://a/b/c/d;p?q#s)zg#szhttp://a/b/c/g#s)zg?y#szhttp://a/b/c/g?y#s)z;xzhttp://a/b/c/;x)zg;xzhttp://a/b/c/g;x)zg;x?y#szhttp://a/b/c/g;x?y#s)r   r   )Ú.úhttp://a/b/c/)z./r   )ú..úhttp://a/b/)z../r   )z../gúhttp://a/b/g)z../..ú	http://a/)z../../r   )z../../gr   )z
../../../gr   )z../../../../gr   )z/./gr   )z/../gr   )zg.zhttp://a/b/c/g.)z.gzhttp://a/b/c/.g)zg..zhttp://a/b/c/g..)z..gzhttp://a/b/c/..g)z./../gr   )z./g/.r   )zg/./hzhttp://a/b/c/g/h)zg/../hzhttp://a/b/c/h)z	g;x=1/./yzhttp://a/b/c/g;x=1/y)z
g;x=1/../yzhttp://a/b/c/y)zg?y/./xzhttp://a/b/c/g?y/./x)zg?y/../xzhttp://a/b/c/g?y/../x)zg#s/./xzhttp://a/b/c/g#s/./x)zg#s/../xzhttp://a/b/c/g#s/../x)6zhttp://localhostúhttp://localhost/zhttp://127.0.0.1/zhttp://[::127.0.0.1]/zhttp://[::1]/zhttp://localhost/foozhttp://localhost/foo/zhttp://localhost/foo!!bar/zhttp://localhost/foo%20bar/zhttp://localhost/foo%2Fbar/zhttp://localhost/foo?nzhttp://localhost/foo?n=vzhttp://localhost/foo?n=/a/bz%http://example.com/foo!@$bar?b!@z=123z$http://localhost/asd?a=asd%20sdf/345z6http://(%2525)/(%2525)?(%2525)&(%2525)=(%2525)#(%2525)z<http://(%C3%A9)/(%C3%A9)?(%C3%A9)&(%C3%A9)=(%C3%A9)#(%C3%A9)zG?sslrootcert=/Users/glyph/Downloads/rds-ca-2015-root.pem&sslmode=verifyz%http://googlewebsite.com/e-shops.aspxz?http://example.com:8080/search?q=123&business=Nothing%20Specialz*http://hatnote.com:9000/?arg=1&arg=2&arg=3úhttps://xn--bcher-kva.chz"http://xn--ggbla1c4e.xn--ngbc5azd/z.http://tools.ietf.org/html/rfc3986#section-3.4z:ftp://ftp.rfc-editor.org/in-notes/tar/RFCs0001-0500.tar.gzz.http://[1080:0:0:0:8:800:200C:417A]/index.htmlzssh://192.0.2.16:2222/z$https://[::101.45.75.219]:80/?hi=byez7ldap://[::192.9.5.5]/dc=example,dc=com??sub?(sn=Jensen)zFmailto:me@example.com?to=me@example.com&body=hi%20http://wikipedia.orgznews:alt.rec.motorcycleztel:+1-800-867-5309zurn:oasis:member:A00024:xa  magnet:?xt=urn:btih:1a42b9e04e122b97a5254e3df77ab3c4b7da725f&dn=Puppy%20Linux%20precise-5.7.1.iso&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.publicbt.com:80&tr=udp://tracker.istole.it:6969&tr=udp://tracker.ccc.de:80&tr=udp://open.demonii.com:1337zhttps://%3A@example.com/zhttps://%40@example.com/zhttps://%2f@example.com/zhttps://a:%3a@example.com/zhttps://a:%40@example.com/zhttps://a:%2f@example.com/zhttps://a:%3f@example.com/zhttps://example.com/%2F/zhttps://example.com/%3F/zhttps://example.com/%23/zhttps://example.com/?%23=bzhttps://example.com/?%3D=bzhttps://example.com/?%26=bzhttps://example.com/?a=%23zhttps://example.com/?a=%26zhttps://example.com/?a=%3Dz https://example.com/?foo+bar=bazz https://example.com/?foo=bar+bazzChttp://(%2525):(%2525)@example.com/(%2525)/?(%2525)=(%2525)#(%2525)z8first_seg_rel_path__colon%3Anotok/second_seg__colon%3Aokc                   @   sj  e Zd ZdZdd„ Zdš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+dSdT„ Z,dUdV„ Z-dWdX„ Z.dYdZ„ Z/d[d\„ Z0d]d^„ Z1d_d`„ Z2dadb„ Z3dcdd„ Z4dedf„ Z5dgdh„ Z6didj„ Z7dkdl„ Z8dmdn„ Z9dodp„ Z:dqdr„ Z;dsdt„ Z<dudv„ Z=dwdx„ Z>dydz„ Z?d{d|„ Z@d}d~„ ZAdd€„ ZBdd‚„ ZCdƒd„„ ZDd…d†„ ZEd‡dˆ„ ZFd‰dŠ„ ZGd‹dŒ„ ZHddŽ„ ZIdd„ ZJd‘d’„ ZKd“d”„ ZLd•d–„ ZMd—d˜„ ZNd™S )›ÚTestURLz
    Tests for L{URL}.
    c                 C   sÆ   |   t|jtƒp|jdkt|ƒ¡ |   t|jtƒp:|jdkt|ƒ¡ |jD ]}|  t|ƒtt|ƒ¡ qJ|j	D ]<\}}|  t|ƒtt|ƒ¡ |   |dkpžt|tƒt|ƒ¡ ql|  t|j
ƒtt|ƒ¡ dS )zl
        The given L{URL}'s components should be L{unicode}.

        @param u: The L{URL} to test.
        N)Ú
assertTrueÚ
isinstanceÚschemeÚunicodeÚreprÚhostÚpathÚassertEqualÚtypeÚqueryÚfragment)ÚselfÚuÚsegZ_kÚv© r/   úY/var/www/html/services/stratfitenv/lib/python3.8/site-packages/hyperlink/test/test_url.pyÚassertUnicoded–   s     ÿ"
 zTestURL.assertUnicodedr   c	                 C   sL   |j |j|j|j|j|j|jf}	||t|ƒt|ƒ|||jf}
|  |	|
¡ dS )aª  
        The given L{URL} should have the given components.

        @param u: The actual L{URL} to examine.

        @param scheme: The expected scheme.

        @param host: The expected host.

        @param path: The expected path.

        @param query: The expected query.

        @param fragment: The expected fragment.

        @param port: The expected port.

        @param userinfo: The expected userinfo.
        N)	r"   r%   r&   r)   r*   ÚportÚuserinfoÚtupler'   )r+   r,   r"   r%   r&   r)   r*   r2   r3   ÚactualÚexpectedr/   r/   r0   Ú	assertURL¨   s"     ù
ù	zTestURL.assertURLc                    sD   ‡ fdd„}|t ddƒƒ |t ddg g ƒƒ |t ddg g dƒƒ dS )z@
        L{URL} should have appropriate default values.
        c              
      s&   ˆ   | ¡ ˆ  | ddg g ddd¡ d S )NÚhttpr   éP   )r1   r7   )r,   ©r+   r/   r0   Úchecká   s    
z(TestURL.test_initDefaults.<locals>.checkr8   r   N)r   )r+   r;   r/   r:   r0   Útest_initDefaultsÛ   s    zTestURL.test_initDefaultsc              	   C   sj   t dddgddgdƒ}|  |¡ |  |dddgddgdd¡ |  t dd	d
gdgdƒdd	d
gdgdd¡ dS )z=
        L{URL} should accept L{unicode} parameters.
        ÚsÚhÚp©Úkr.   )rA   NÚfNr8   õ   Ã õ   Ã©)u   Î»u   Ï€u   âŠ¥r9   ©r   r1   r7   ©r+   r,   r/   r/   r0   Ú	test_initê   s    
ùzTestURL.test_initc              	   C   s@   t dddgddgdƒ}|  |¡ |  |dddgddgdd¡ dS )zN
        L{URL} should accept (and not interpret) percent characters.
        r=   z%68z%70)ú%6Bz%76)rH   Nz%66NrE   rF   r/   r/   r0   Útest_initPercentý   s    
      ÿzTestURL.test_initPercentc              
   C   s2   |   ttdddgddgddƒdtd	ƒf ¡ d
S )zº
        L{URL.__repr__} will display the canonical form of the URL, wrapped in
        a L{URL.from_text} invocation, so that it is C{eval}-able but still
        easy to read.
        r8   ÚfooÚbar)ZbazNr@   Zfrob©r"   r%   r&   r)   r*   zURL.from_text(%s)zhttp://foo/bar?baz&k=v#frobN)r'   r$   r   r:   r/   r/   r0   Ú	test_repr  s    ûÿ	özTestURL.test_reprc                 C   s   t  t¡}|  t| ¡ ¡ dS )zc
        Round-tripping L{URL.from_text} with C{str} results in an equivalent
        URL.
        N)r   Ú	from_textÚ	BASIC_URLr'   Úto_text©r+   Úurlpathr/   r/   r0   Útest_from_text  s    
zTestURL.test_from_textc                 C   s,   t D ]"}t |¡jdd}|  ||¡ qdS )z@
        L{URL.to_text} should invert L{URL.from_text}.
        T©Zwith_passwordN)ÚROUNDTRIP_TESTSr   rN   rP   r'   )r+   ÚtestÚresultr/   r/   r0   Útest_roundtrip%  s    zTestURL.test_roundtripc                 C   sX   t D ]N}t |¡}| ¡ }| ¡ }||ks.t‚|jdd}|jdd}||kst‚qd S )NTrT   )rU   r   rN   Úto_iriÚAssertionErrorrP   )r+   rV   ÚurlÚiriZ
double_iriZiri_textZdouble_iri_textr/   r/   r0   Útest_roundtrip_double_iri.  s    
z!TestURL.test_roundtrip_double_iric                 C   s2   t  t¡}|  |t  t¡¡ |  |t  d¡¡ dS )z·
        Two URLs decoded using L{URL.from_text} will be equal (C{==}) if they
        decoded same URL string, and unequal (C{!=}) if they decoded different
        strings.
        z:ftp://www.anotherinvaliddomain.com/foo/bar/baz/?zot=21&zutN)r   rN   rO   r'   ÚassertNotEqualrQ   r/   r/   r0   Útest_equality;  s    
ÿþzTestURL.test_equalityc                 C   s0   |   tddtƒ ¡ |   t d¡t d¡¡ dS )zŒ
        An URL created with the empty string for a fragment compares equal
        to an URL created with an unspecified fragment.
        r   )r*   zhttp://localhost/#r   N)r'   r   rN   r:   r/   r/   r0   Útest_fragmentEqualityK  s
    þzTestURL.test_fragmentEqualityc                 C   sf   t  t¡}|  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ d	S )
zm
        L{URL.child} appends a new path segment, but does not affect the query
        or fragment.
        z.http://www.foo.com/a/nice/path/gong?zot=23&zutZgongz1http://www.foo.com/a/nice/path/gong%2F?zot=23&zutzgong/z7http://www.foo.com/a/nice/path/gong%2Fdouble?zot=23&zutzgong/doublez:http://www.foo.com/a/nice/path/gong%2Fdouble%2F?zot=23&zutzgong/double/N)r   rN   rO   r'   ÚchildrP   rQ   r/   r/   r0   Ú
test_childW  s"    
þþþþzTestURL.test_childc                 C   s(   t  d¡}|  | ddd¡ ¡ d¡ dS )zg
        L{URL.child} receives multiple segments as C{*args} and appends each in
        turn.
        zhttp://example.com/a/bÚcÚdÚezhttp://example.com/a/b/c/d/eN)r   rN   r'   ra   rP   ©r+   r[   r/   r/   r0   Útest_multiChildo  s
    
 ÿzTestURL.test_multiChildc                 C   s0   t dd d¡}|  |j¡ |  d| ¡ ¡ dS )zo
        L{URL.child} of a L{URL} without a path produces a L{URL} with a single
        path segment.
        úwww.foo.com©r%   rc   zhttp://www.foo.com/cN)r   ra   r    Úrootedr'   rP   )r+   ZchildURLr/   r/   r0   Útest_childInitRootz  s    zTestURL.test_childInitRootc                 C   s   t dd}|  | ¡ |¡ dS )zT
        L{URL.child} without any new segments returns the original L{URL}.
        rh   ri   N)r   r'   ra   rf   r/   r/   r0   Útest_emptyChild„  s    
zTestURL.test_emptyChildc                 C   sH   t  t¡}|  d| d¡ ¡ ¡ d}t  |¡}|  d| d¡ ¡ ¡ dS )z
        L{URL.sibling} of a L{URL} replaces the last path segment, but does not
        affect the query or fragment.
        z0http://www.foo.com/a/nice/path/sister?zot=23&zutZsisterz)http://www.foo.com/a/nice/path?zot=23&zutz+http://www.foo.com/a/nice/sister?zot=23&zutN)r   rN   rO   r'   ÚsiblingrP   )r+   rR   Úurl_textr/   r/   r0   Útest_siblingŒ  s    
þ
þzTestURL.test_siblingc                 C   s$  t  t¡}|  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d	| d
¡ ¡ k¡ t  d¡}|  d| d¡ ¡ ¡ t  d¡}|  | d¡ ¡ d¡ t  d¡}d}|  | d¡ ¡ |¡ |  | ¡  ¡ |¡ t  d¡}t  d¡}| |¡}|  | ¡ d¡ dS )z¦
        L{URL.click} interprets the given string as a relative URI-reference
        and returns a new L{URL} interpreting C{self} as the base absolute URI.
        r   r   z$http://www.foo.com/a/nice/path/clickÚclickzhttp://www.foo.com/clickz/clickz$http://www.foo.com/a/nice/path/?burpz?burpz//foobarzhttp://www.foo.com/foobarzhttp://www.foo.com/me/noqueryz!http://www.foo.com/me/17?spam=158z/me/17?spam=158zhttp://localhost/foo?abc=defzhttp://www.python.orgz$http://hatnote.com/a/b/../c/./d/e/..zhttp://hatnote.com/a/c/d/zhttp://localhost/foo/?abc=defrK   zhttp://localhost/foo/barN)r   rN   rO   r'   rp   rP   r    ÚfromText)r+   rR   r,   ÚresÚu2Úu3r/   r/   r0   Ú
test_clickŸ  sP    
þþ ÿþÿÿ
þ
 ÿ



zTestURL.test_clickc                 C   s2   t  t¡}tD ]\}}|  | |¡ ¡ |¡ qdS )zQ
        L{URL.click} should correctly resolve the examples in RFC 3986.
        N)r   rN   ÚrelativeLinkBaseForRFC3986ÚrelativeLinkTestsForRFC3986r'   rp   rP   )r+   ÚbaseÚrefr6   r/   r/   r0   Útest_clickRFC3986Ý  s    
zTestURL.test_clickRFC3986c                 C   s.   t  t¡}|  t|jd¡ |  t|jd¡ dS )zM
        L{URL.click} should not accept schemes with relative paths.
        zg:hzhttp:hN)r   rN   rv   ÚassertRaisesÚNotImplementedErrorrp   )r+   rx   r/   r/   r0   Útest_clickSchemeRelPathæ  s    
zTestURL.test_clickSchemeRelPathc              
   C   sF   t  d¡}|  | |j|j|j|j|j|j	¡|¡ |  | ¡ |¡ dS )zf
        Verify that L{URL.replace} doesn't change any of the arguments it
        is passed.
        zhttps://x:1/y?z=1#AN)
r   rN   r'   Úreplacer"   r%   r&   r)   r*   r2   rQ   r/   r/   r0   Útest_cloneUnchangedï  s    
ú÷zTestURL.test_cloneUnchangedc                 C   s´   dddgdddgdddgdddgdddgdd	d
gdddgdddgdddgdd	dgdd	d
gdddgdddgg}|D ]>\}}}t  |¡ |¡ ¡ }|  ||dj|t|ƒ||d¡ qpdS )zd
        L{URL.click} collapses C{.} and C{..} according to RFC 3986 section
        5.2.4.
        r   r   r   zhttp://localhost/a/b/czhttp://localhost/a/b/zhttp://localhost/a/z./d/ezhttp://localhost/a/b/d/ez../d/ezhttp://localhost/a/d/ez/./d/ezhttp://localhost/d/ez/../d/ezhttp://localhost/a/b/c/z
../../d/e/zhttp://localhost/a/d/e/zhttp://localhost/a/./czhttp://localhost/a/./c/zhttp://localhost/a/b/c/dz./e/../f/../gzhttp://localhost/a/b/c/gzd//ezhttp://localhost/a/b/d//ez1{start}.click({click}) => {actual} not {expected})Ústartrp   r5   r6   N)r   rN   rp   rP   r'   Úformatr$   )r+   Útestsr€   rp   r6   r5   r/   r/   r0   Útest_clickCollapse  s@    ýýëüýzTestURL.test_clickCollapsec                 C   sÔ   |   dt d¡ dd¡ ¡ ¡ |   dtdd dd¡ ¡ ¡ t t¡}|   d| d	¡ ¡ ¡ |   d
| d	d¡ ¡ ¡ |   d| d	d¡ d¡ ¡ ¡ |   d| d¡ d	d¡ ¡ ¡ |   d| d	d¡ dd¡ ¡ ¡ dS )z3
        L{URL.add} adds query parameters.
        z'http://www.foo.com/a/nice/path/?foo=barzhttp://www.foo.com/a/nice/path/rJ   rK   zhttp://www.foo.com/?foo=barrh   ri   z/http://www.foo.com/a/nice/path/?zot=23&zut&burpZburpz3http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxxÚxxxz8http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx&zingZzingz8http://www.foo.com/a/nice/path/?zot=23&zut&zing&burp=xxxz:http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx&zot=32ÚzotÚ32N)r'   r   rN   ÚaddrP   rO   rQ   r/   r/   r0   Útest_queryAdd-  s@    
 ÿþþ
þþþþþzTestURL.test_queryAddc                 C   sd   t  t¡}|  d| dd¡ ¡ ¡ |  d| d¡ dd¡ ¡ ¡ |  d| dd¡ dd¡ ¡ ¡ dS )	z?
        L{URL.set} replaces query parameters by name.
        z*http://www.foo.com/a/nice/path/?zot=32&zutr…   r†   z0http://www.foo.com/a/nice/path/?zot&zut=itworkedZzutZitworkedr„   N)r   rN   rO   r'   ÚsetrP   r‡   rQ   r/   r/   r0   Útest_querySetT  s    
þþþzTestURL.test_querySetc                 C   s|   t  d¡}|  | d¡t  d¡¡ |  |jdddt  d¡¡ |  |jdddt  d¡¡ |  |jddd	d
t  d¡¡ dS )zG
        L{URL.remove} removes instances of a query parameter.
        z*https://example.com/a/b/?foo=1&bar=2&foo=3rJ   zhttps://example.com/a/b/?bar=2Ú1)ÚnameÚvaluez$https://example.com/a/b/?bar=2&foo=3r	   )rŒ   Úlimitr   )rŒ   r   rŽ   N)r   rN   r'   Úremoverf   r/   r/   r0   Útest_queryRemovej  s"    
 ÿþþþzTestURL.test_queryRemovec                 C   s˜   t  d¡}|  | d¡dg¡ |  | ¡ d¡ t  d¡}|  |jd¡ |  | ¡ d¡ t  d¡}| ¡ }|  | d¡dg¡ |  | ¡  d¡dg¡ d	S )
z€
        Every C{=}-sign after the first in a query parameter is simply included
        in the value of the parameter.
        zhttp://localhost/?=x=x=xr   úx=x=xz!http://localhost/?foo=x=x=x&bar=y))rJ   r‘   )rK   Úyz7https://example.com/?argument=3&argument=4&operator=%3DÚoperatorú=N)r   rN   r'   ÚgetrP   r)   rY   Úto_uri)r+   r,   r\   r/   r/   r0   Útest_parseEqualSignInParamValueƒ  s    

ÿz'TestURL.test_parseEqualSignInParamValuec                 C   s   |   tƒ  ¡ d¡ dS )zG
        An empty L{URL} should serialize as the empty string.
        r   N)r'   r   rP   r:   r/   r/   r0   Ú
test_empty˜  s    zTestURL.test_emptyc                 C   s    t dgd}|  | ¡ d¡ dS )zP
        An L{URL} with query text should serialize as just query text.
        ©ÚhelloÚworld©r)   z?hello=worldN)r   r'   rP   rF   r/   r/   r0   Útest_justQueryTextŸ  s    zTestURL.test_justQueryTextc                 C   s   t  d¡}|  ||¡ dS )z2
        L{URL} compares equal to itself.
        r   N©r   rN   r'   rF   r/   r/   r0   Útest_identicalEqual§  s    
zTestURL.test_identicalEqualc                 C   s$   t  d¡}t  d¡}|  ||¡ dS )zG
        URLs with equivalent components should compare equal.
        ú%http://u@localhost:8080/p/a/t/h?q=p#fNrž   ©r+   Úu1rs   r/   r/   r0   Útest_similarEqual¯  s    

zTestURL.test_similarEqualc                 C   s<   t  d¡}t  d¡}|  ||kd||f ¡ |  ||¡ dS )z|
        L{URL}s that refer to different resources are both unequal (C{!=}) and
        also not equal (not C{==}).
        úhttp://localhost/aúhttp://localhost/bú%r != %rN)r   rN   ÚassertFalser^   r¡   r/   r/   r0   Útest_differentNotEqual¸  s    

zTestURL.test_differentNotEqualc                 C   sJ   t  d¡}|  |dkd¡ |  |tƒ kd¡ |  |d¡ |  |tƒ ¡ dS )z=
        L{URL} is not equal (C{==}) to other types.
        r   é*   zURL must not equal a number.zURL must not equal an object.N)r   rN   r§   Úobjectr^   rF   r/   r/   r0   Útest_otherTypesNotEqualÃ  s
    
zTestURL.test_otherTypesNotEqualc                 C   s"   t  d¡}|  ||kd| ¡ dS )zJ
        Identical L{URL}s are not unequal (C{!=}) to each other.
        r    z%r == itselfN©r   rN   r§   rF   r/   r/   r0   Útest_identicalNotUnequalÎ  s    
z TestURL.test_identicalNotUnequalc                 C   s0   t  d¡}t  d¡}|  ||kd||f ¡ dS )zU
        Structurally similar L{URL}s are not unequal (C{!=}) to each other.
        r    ú%r == %rNr¬   r¡   r/   r/   r0   Útest_similarNotUnequalÖ  s    

zTestURL.test_similarNotUnequalc                 C   s0   t  d¡}t  d¡}|  ||kd||f ¡ dS )zS
        Structurally different L{URL}s are unequal (C{!=}) to each other.
        r¤   r¥   r®   N)r   rN   r    r¡   r/   r/   r0   Útest_differentUnequalß  s    

zTestURL.test_differentUnequalc                 C   s0   t  d¡}|  |dkd¡ |  |tƒ kd¡ dS )z;
        L{URL} is unequal (C{!=}) to other types.
        r   r©   zURL must differ from a number.z"URL must be differ from an object.N)r   rN   r    rª   rF   r/   r/   r0   Útest_otherTypesUnequalè  s    
zTestURL.test_otherTypesUnequalc                 C   sl   d}t  |¡}| ¡ }|  |jd¡ |  |jd d¡ |  | ¡ |¡ d}| ¡ }|  ||d||f ¡ dS )z‹
        L{URL.asURI} produces an URI which converts any URI unicode encoding
        into pure US-ASCII and returns a new L{URL}.
        õ   http://Ã©.com/eÌ?aÌ=iÌ#uÌu   Ã©.comr   u   eÌú.http://xn--9ca.com/%C3%A9?%C3%A1=%C3%AD#%C3%BAr¦   N)r   rN   ÚasURIr'   r%   r&   rP   )r+   Úunicodeyr\   ÚuriÚexpectedURIÚ	actualURIr/   r/   r0   Ú
test_asURIñ  s"    ÿ
 ÿ  
ÿzTestURL.test_asURIc                 C   sl   d}t  |¡}| ¡ }|  |jd¡ |  |jd d¡ |  | ¡ |¡ d}| ¡ }|  ||d||f ¡ dS )zœ
        L{URL.asIRI} decodes any percent-encoded text in the URI, making it
        more suitable for reading by humans, and returns a new L{URL}.
        r³   zxn--9ca.comr   z%C3%A9u   http://Ã©.com/Ã©?Ã¡=Ã­#Ãºr¦   N)r   rN   ÚasIRIr'   r%   r&   rP   )r+   Zasciiishr¶   r\   ÚexpectedIRIÚ	actualIRIr/   r/   r0   Ú
test_asIRI  s    
ÿ  
ÿzTestURL.test_asIRIc                 C   s<   d}t  |¡}| ¡ }d}| ¡ }|  ||d||f ¡ dS )zœ
        Bad UTF-8 in a path segment, query parameter, or fragment results in
        that portion of the URI remaining percent-encoded in the IRI.
        z http://xn--9ca.com/%00%FF/%C3%A9u   http://Ã©.com/%00%FF/Ã©r¦   N)r   rN   rº   rP   r'   )r+   ZurlWithBinaryr¶   r\   r»   r¼   r/   r/   r0   Útest_badUTF8AsIRI#  s    
ÿ  
ÿzTestURL.test_badUTF8AsIRIc                 C   s*   d}t  |¡}| ¡ }|  | ¡ |¡ dS )zT
        A L{URL} composed of non-ASCII text will result in non-ASCII text.
        r²   N)r   rN   rº   r'   rP   )r+   rµ   r\   ZalsoIRIr/   r/   r0   Útest_alreadyIRIAsIRI6  s
    ÿ
zTestURL.test_alreadyIRIAsIRIc                 C   s*   d}t  |¡}| ¡  ¡ }|  ||¡ dS )zH
        A L{URL} composed of encoded text will remain encoded.
        r³   N)r   rN   r´   rP   r'   )r+   r·   r¶   r¸   r/   r/   r0   Útest_alreadyURIAsURIF  s    
zTestURL.test_alreadyURIAsURIc                 C   sv   t  d¡}|  | d¡d¡ |  | d¡d¡ |  |jd¡ |  |jd¡ |  | ¡ d¡ |  |jdd	 ¡ d
¡ dS )z{
        L{URL.from_text} will parse the C{userinfo} portion of the URI
        separately from the host and port.
        z<http://someuser:somepassword@example.com/some-segment@ignoreTz!someuser:somepassword@example.comFzsomeuser:@example.comzsomeuser:somepasswordZsomeuserz0http://someuser:@example.com/some-segment@ignore©r3   z/http://someuser@example.com/some-segment@ignoreN)r   rN   r'   Ú	authorityr3   ÚuserrP   r~   rf   r/   r/   r0   Útest_userinfoP  s$    ÿ ÿ ÿþzTestURL.test_userinfoc                 C   s,   t  d¡}|  |jd¡ |  | ¡ d¡ dS )zJ
        L{URL.from_text} parses custom port numbers as integers.
        zhttp://www.example.com:8080/i  N)r   rN   r'   r2   rP   )r+   ZportURLr/   r/   r0   Útest_portTextg  s    
zTestURL.test_portTextc                 C   s   |   t d¡ ¡ d¡ dS )a  
        Although L{URL} instances are mainly for dealing with HTTP, other
        schemes (such as C{mailto:}) should work as well.  For example,
        L{URL.from_text}/L{URL.to_text} round-trips cleanly for a C{mailto:}
        URL representing an email address.
        zmailto:user@example.comN)r'   r   rN   rP   r:   r/   r/   r0   Útest_mailtop  s    þzTestURL.test_mailtoc                 C   sH   t  d¡}|  |jd¡ |  |jd¡ |  |jd¡ |  | ¡ d¡ dS )zj
        An HTTP URL without a hostname, but with a path, should also round-trip
        cleanly.
        zhttp:relative-pathr   )zrelative-pathFN)r   rN   r'   r%   r&   Úuses_netlocrP   )r+   Zwithout_hostr/   r/   r0   Útest_httpWithoutHost}  s
    
zTestURL.test_httpWithoutHostc                 C   s>   d}t dgd}|  |j|¡ t ddid}|  |j|¡ dS )z´
        When a L{URL} is created with a C{query} argument, the C{query}
        argument is converted into an N-tuple of 2-tuples, sensibly
        handling dictionaries.
        )©ÚalphaÚbetarÉ   rœ   rÊ   rË   N)r   r'   r)   )r+   r6   r[   r/   r/   r0   Útest_queryIterable‰  s
    zTestURL.test_queryIterablec                 C   s    t ddgd}|  |jd¡ dS )zr
        When a L{URL} is created with a C{path} argument, the C{path} is
        converted into a tuple.
        rš   r›   ©r&   r™   N)r   r'   r&   rf   r/   r/   r0   Útest_pathIterable–  s    zTestURL.test_pathIterablec              	      s^  G dd„ dt ƒ‰ ttkrdnd}‡fdd„‰|f‡ ‡‡fdd„	}|d	ƒ |d
ƒ |dƒ |ddƒ |dƒ |ddƒ ˆ t¡}tttˆ ƒ ƒgd W 5 Q R X ˆ||dƒ ˆ t¡}tdttˆ ƒ ƒfgd W 5 Q R X ˆ||d dƒ ˆ t¡}tttˆ ƒ ƒdfgd W 5 Q R X ˆ||dƒ ˆ t¡" tttttf ˆ ƒ ƒgd W 5 Q R X ˆ t	¡  tttttf dƒgd W 5 Q R X ˆ t	¡  tttttf dƒgd W 5 Q R X t 
d¡}ˆ t¡}| ttˆ ƒ ƒ¡ W 5 Q R X ˆ||dƒ ˆ t¡}| ttˆ ƒ ƒ¡ W 5 Q R X ˆ||dƒ ˆ t¡}| ttˆ ƒ ƒ¡ W 5 Q R X ˆ||dƒ dS )a¤  
        Passing an argument of the wrong type to any of the constructor
        arguments of L{URL} will raise a descriptive L{TypeError}.

        L{URL} typechecks very aggressively to ensure that its constitutent
        parts are all properly immutable and to prevent confusing errors when
        bad data crops up in a method call long after the code that called the
        constructor is off the stack.
        c                   @   s   e Zd Zdd„ Zdd„ ZdS )z1TestURL.test_invalidArguments.<locals>.Unexpectedc                 S   s   dS )NZwrongr/   r:   r/   r/   r0   Ú__str__¬  s    z9TestURL.test_invalidArguments.<locals>.Unexpected.__str__c                 S   s   dS )Nú<unexpected>r/   r:   r/   r/   r0   Ú__repr__°  s    z:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__N)Ú__name__Ú
__module__Ú__qualname__rÏ   rÑ   r/   r/   r/   r0   Ú
Unexpected«  s   rÕ   r#   Ústrc                    s    ˆ   t| jƒd ||d¡¡ d S )Nzexpected {0} for {1}, got {2}rÐ   )r'   rÖ   Ú	exceptionr   )ÚraisedÚexpectationrŒ   r:   r/   r0   ÚassertRaised¶  s      ÿþz3TestURL.test_invalidArguments.<locals>.assertRaisedc              	      s6   ˆ  t¡}tf | ˆ ƒ iŽ W 5 Q R X ˆ||| ƒ d S )N)r{   Ú	TypeErrorr   )ÚparamrÙ   rØ   ©rÕ   rÚ   r+   r/   r0   r;   ¿  s    z,TestURL.test_invalidArguments.<locals>.checkr"   r%   r*   rj   Úboolr3   r2   zint or NoneTyperÍ   zpath segmentrŒ   rœ   z or NoneTypezquery parameter valuer   zquery parameter name)rA   r.   Úvv)rA   zhttps://valid.example.com/zrelative URLN)rª   ÚbytesrÖ   r{   rÛ   r   r   r   r   Ú
ValueErrorrN   ra   rm   rp   )r+   ZdefaultExpectationr;   rØ   r[   r/   rÝ   r0   Útest_invalidArgumentsŸ  sN    		

"  ÿ"&$$
zTestURL.test_invalidArgumentsc              	   C   s@   |   t¡}tdd W 5 Q R X |  t|jƒd tdƒ¡¡ dS )z¸
        Technically, L{str} (or L{unicode}, as appropriate) is iterable, but
        C{URL(path="foo")} resulting in C{URL.from_text("f/o/o")} is never what
        you want.
        rJ   rÍ   z,expected iterable of text for path, not: {0}N)r{   rÛ   r   r'   rÖ   r×   r   r$   )r+   rØ   r/   r/   r0   Ú!test_technicallyTextIsIterableButô  s    þz)TestURL.test_technicallyTextIsIterableButc                 C   s:  t dd}|  |jd¡ |  | ¡ d¡ |  t  d¡jd¡ |  t  d¡jd¡ |  t  d¡jd¡ t ddd}|  |jd¡ |  | ¡ d¡ t d	d}|  |jd¡ |  | ¡ d
¡ t dd}|  |jd¡ |  | ¡ d¡ t dd}|  |jd ¡ |  | ¡ d¡ t  d¡}|  |jd¡ t  d¡}|  |jd¡ d S )NÚhttps©r"   Tzhttps://zhttps:Fzhttps:/)r"   rÇ   z	git+httpszgit+https://Úmailtozmailto:Úztpzztp:zztp://test.comzztp:test:com)r   r'   rÇ   rP   rN   rf   r/   r/   r0   Útest_netloc  s,    





zTestURL.test_netlocc                 C   sB   d}t  |¡}|jdkst‚|jdks*t‚t|j |jks>t‚d S )Nz5https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:80/z'2001:0db8:85a3:0000:0000:8a2e:0370:7334r9   )r   rN   r%   rZ   r2   r   r"   )r+   Útr[   r/   r/   r0   Útest_ipv6_with_port$  s
    
zTestURL.test_ipv6_with_portc                 C   sä   d}t  |¡}|jdkst‚|jdks*t‚|jdks8t‚|jdksFt‚|jdksTt‚d}t  |¡}|jdkspt‚|jdks~t‚|jdksŒt‚|jdksšt‚d	}t  |¡}|jdks¶t‚|jdksÄt‚|jd
ksÒt‚|jdksàt‚d S )Nz3https://user:pass@example.com/path/to/here?k=v#nicerä   ú	user:passúexample.com)r&   ÚtoÚhereÚnicez1https://user:pass@127.0.0.1/path/to/here?k=v#nicez	127.0.0.1z-https://user:pass@[::1]/path/to/here?k=v#nicez::1)r   rN   r"   rZ   r3   r%   r&   r*   ©r+   Útextr[   r/   r/   r0   Ú
test_basic,  s&    


zTestURL.test_basicc                 C   s   |   ttjd¡ d S )Nz#

©r{   r   r   rN   r:   r/   r/   r0   Útest_invalid_urlD  s    zTestURL.test_invalid_urlc                 C   s   |   ttjd¡ d S )Nzhttp://abc:

/#ró   r:   r/   r/   r0   Útest_invalid_authority_urlH  s    z"TestURL.test_invalid_authority_urlc                 C   sL   dddddg}|D ]4}d| d }|   tjttj|¡ |   ttj|¡ qd S )Nz2001::0234:C1ab::A0:aabc:003Fz2001::1::3Fú:z::::z::256.0.0.1zhttp://[ú])r{   ÚsocketÚerrorr   ÚAF_INET6r   r   rN   )r+   Zinvalid_ipv6_ipsÚiprn   r/   r/   r0   Útest_invalid_ipv6L  s    ûzTestURL.test_invalid_ipv6c                 C   s$   |   ttjd¡ |   ttjd¡ d S )Nzftp://portmouth:smashz+http://reader.googlewebsite.com:neverforget)r{   r   r   rN   rá   r:   r/   r/   r0   Útest_invalid_portZ  s    ýzTestURL.test_invalid_portc                 C   s|   t  d¡}|  |jd¡ |  | ¡ d¡ |  | ¡  ¡ d¡ t  d¡}|  |jd¡ |  | ¡ d¡ |  | ¡  ¡ d¡ d S )Nu   http://bÃ¼cher.chu
   bÃ¼cher.chzhttp://xn--bcher-kva.chr   zxn--bcher-kva.chu   https://bÃ¼cher.ch)r   rN   r'   r%   rP   r–   rY   r¡   r/   r/   r0   Ú	test_idnac  s    

zTestURL.test_idnac                 C   sž  t  d¡}|  |jd¡ |  | ¡ d¡ t  d¡}|  |jd¡ |  | ¡ d¡ t  d¡}|  |jd¡ |  | ¡ d¡ t  d¡}|  |jd¡ |  | ¡ d¡ t  d	¡}|  |jd
¡ |  | ¡ d	¡ t  d¡}|  |jd¡ |  | ¡ d¡ t dddd}|  | ¡ d¡ t d
dddd}|  | ¡ d¡ t  d¡}|jdd}|  | ¡ d¡ d}t  |¡}|jdd}|  | ¡ d¡ |jdd}|  | ¡ |¡ d S )Nzmailto:mahmoud@hatnote.comræ   zhttp://hatnote.comr8   znewscheme:a:b:cZ	newschemeznewerscheme://a/b/cZnewerschemez%git+ftp://gitstub.biz/glyph/lefkowitzzgit+ftpz'what+mailto:freerealestate@enotuniq.orgzwhat+mailtorç   )Úxr’   ÚzT)r"   r&   rj   z
ztp:/x/y/z)rÿ   r’   r   r   )r"   r&   rj   rÇ   zgit+ftp:///x/y/z/zfile:///path/to/heckrå   zmailto:/path/to/heckzunregisteredscheme:///a/b/cF)rÇ   zunregisteredscheme:/a/b/c)r   rN   r'   r"   rP   r~   )r+   r[   Úurl2rn   Zno_netloc_urlZ
netloc_urlr/   r/   r0   Útest_netloc_slasheso  sP    





 ÿü

zTestURL.test_netloc_slashesc                 C   sH   t dgd}|  | ¡ d¡ |jdd}|  | ¡ d¡ |  ||¡ dS )z•
        On host-relative URLs, the C{rooted} flag can be updated to indicate
        that the path should no longer be treated as absolute.
        rš   rÍ   T)rj   z/helloN)r   r'   rP   r~   r^   )r+   ÚaÚbr/   r/   r0   Útest_rooted_to_relativeª  s
    zTestURL.test_rooted_to_relativec                 C   s   t ddgdd}|  |jd¡ t dgdd}|  |jd¡ |  ||¡ t ddgdd}t ddgd}|  ||¡ |  |jd¡ |  |jd¡ d	S )
a	  
        The C{rooted} flag can be updated in some cases, but it cannot be made
        to conflict with other facts surrounding the URL; for example, all URLs
        involving an authority (host) are inherently rooted because it is not
        syntactically possible to express otherwise; also, once an unrooted URL
        gains a path that starts with an empty string, that empty string is
        elided and it becomes rooted, because these cases are syntactically
        indistinguisable in real URL text.
        r   rJ   F)r&   rj   TrK   )r%   r&   rj   )r%   r&   N)r   r'   rj   )r+   Zrelative_path_rootedZrelative_flag_rootedZattempt_unrooted_absoluteZnormal_absoluter/   r/   r0   Útest_autorooted¶  s    zTestURL.test_autorootedc                 C   sØ   t dddd}t ddd}t dddd}|  |jd¡ |  |jd¡ |  |jd¡ t  d¡}|  t|ƒt|ƒ¡ |  t|ƒt|ƒ¡ |  | ¡ | ¡ ¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ |  ||¡ dS )	a¤  
        URLs which include a ``://`` netloc-separator for any reason are
        inherently rooted, regardless of the value or presence of the
        ``rooted`` constructor argument.

        They may include a netloc-separator because their constructor was
        directly invoked with an explicit host or port, or because they were
        parsed from a string which included the literal ``://`` separator.
        Zudpi$  F)r"   r2   rj   )r"   r2   Tzudp://:4900N)r   r'   rj   rN   rÖ   ÚasText)r+   Zdirectly_constructedZdirectly_constructed_implictZdirectly_constructed_rootedÚparsedr/   r/   r0   Ú!test_rooted_with_port_but_no_hostÍ  s    
z)TestURL.test_rooted_with_port_but_no_hostc              	   C   s@   |   t¡ ttƒ W 5 Q R X |   t¡ tdƒ W 5 Q R X d S )NZHTTP_____more_like_imHoTTeP)r{   rá   r   rO   r:   r/   r/   r0   Útest_wrong_constructorè  s    zTestURL.test_wrong_constructorc                 C   sp   t  d¡}|jdkst‚|jdd}| ¡ }|jdddks@t‚|jddd	ksTt‚| ¡ jddd
kslt‚d S )Nzhttp://user:pass@example.comrë   zus%20her:passrÁ   TrT   zhttp://us her:pass@example.comFzhttp://us her:@example.comz http://us%20her:pass@example.com)r   rN   r3   rZ   r~   rY   rP   r–   ©r+   r[   r\   r/   r/   r0   Útest_encoded_userinfoñ  s    
ÿÿÿzTestURL.test_encoded_userinfoc                 C   sŠ   i }t  d¡}t|ƒt|ƒks"t‚d||< t  d¡}| dd¡}d||< t|ƒdksXt‚t| ¡ ƒdgksnt‚tt ƒ ƒtt ƒ ƒks†t‚d S )Nz.http://blog.hatnote.com/ask?utm_source=geocityr	   zhttp://blog.hatnote.com/askZ
utm_sourceZgeocityr   )r   rN   ÚhashrZ   r‰   ÚlenÚlistÚvalues)r+   Zurl_mapÚurl1r  r/   r/   r0   Ú	test_hash   s    

zTestURL.test_hashc                 C   sR   t ƒ }t|ƒ}t|ƒdkst‚d|ks*t‚d|ks6t‚d|ksBt‚d|ksNt‚d S )Né   rq   r  r´   rº   )r   Údirr  rZ   )r+   r[   rr   r/   r/   r0   Útest_dir  s    zTestURL.test_dirc                 C   s2   t  d¡}| ¡ dkst‚| ¡  ¡ dks.t‚d S )Nu"   http://example.com/a%20tÃ©%C3%A9stz&http://example.com/a%20t%C3%A9%C3%A9st)r   rq   r  rZ   r´   rf   r/   r/   r0   Útest_twisted_compat  s    
zTestURL.test_twisted_compatc                 C   s6   t  d¡}| dd¡}| dd¡}| ¡ dks2t‚d S )Nzhttp://example.com/?a=b&crÿ   r’   z!http://example.com/?a=b&x=x&c&x=y)r   rN   r‰   r‡   rP   rZ   rf   r/   r/   r0   Útest_set_ordering%  s    
zTestURL.test_set_orderingc                 C   s’   t  d¡}t  | ¡ ¡}||ks$t‚t  | ¡  ¡ ¡}||ksBt‚||ksNt‚t  d¡}| ¡ }| ¡ dkspt‚t  | ¡ ¡ ¡ }||ksŽt‚dS )zSee issue #4z#urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoobz1first-segment/urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoobz'first-segment/urn:ietf:wg:oauth:2.0:oobN)r   rN   rP   rZ   rY   r–   )r+   r¢   rs   rt   Zu4Zu5Zu6r/   r/   r0   Útest_schemeless_path0  s    

zTestURL.test_schemeless_pathc                 C   s   t  d¡}| ¡ }| ¡  dS )z4See issue #7, affecting only narrow builds (2.6-3.3)zhttps://xn--vi8hiv.wsN)r   rN   rY   rP   r  r/   r/   r0   Útest_emoji_domainC  s    
zTestURL.test_emoji_domainc                 C   sF   | j ttddd | j ttdd | j ttdd | j ttdd d	S )
zPer issue #6 and #8r8   za/c)r"   r%   )ú?rÍ   )ú#)ú&rV   rœ   N)r{   rá   r   r:   r/   r/   r0   Útest_delim_in_paramK  s    zTestURL.test_delim_in_paramc                 C   s„   t  d¡}t  d¡}||ks t‚t  d¡}t  d¡}||ks@t‚t  d¡}t  d¡}||ks`t‚t  d¡}t  d¡}||ks€t‚d S )Nzhttp://example.com/zhttp://example.com)r   rN   rZ   r¡   r/   r/   r0   Útest_empty_paths_eqS  s    







zTestURL.test_empty_paths_eqc                 C   s:   t  d¡jdkst‚|  tt jd¡ |  tt jtƒ ¡ d S )Nz#okÚoks   bytes://x.y.z)r   rN   r*   rZ   r{   rÛ   rª   r:   r/   r/   r0   Útest_from_text_typei  s    zTestURL.test_from_text_typec                 C   st   |   ttjd¡ |   ttjd¡ |   ttjd¡ |   ttjd¡ |   ttjd¡ |   ttjd¡ |   ttjd¡ d S )Nzhttp://[::1/zhttp://::1]/zhttp://[[::1]/zhttp://[::1]]/zhttp://127.0.0.1:zhttp://127.0.0.1:hizhttp://127.0.0.1::80ró   r:   r/   r/   r0   Útest_from_text_bad_authorityo  s    z$TestURL.test_from_text_bad_authorityc           	      C   s”  t  d¡}| d¡g kst‚| d¡dgks0t‚t|jƒdksBt‚| ¡ }|jdksXt‚|jdksft‚|jdkstt‚| d¡d	gksˆt‚|j	d
ks–t‚| 
¡ dks¦t‚|jdddddd}||ksÆt‚t  d¡}| ¡ }| 
¡ dksèt‚t  d¡}| ¡ }| 
¡ dkst‚t ddjdd 
¡ dks,t‚t dd ¡  
¡ dksHt‚t dddgdgddd}|j
ddd ksvt‚| ¡ j
ddd!kst‚d S )"Nz0HTTP://Example.com/A%61/./../A%61?B%62=C%63#D%64ÚBbzB%62zC%63é   r8   rì   )ZAaÚCcZDdzhttp://example.com/Aa?Bb=Cc#DdFrL   zhttp://example.iozhttp://example.io/z/a%2fb/cd%3f?k%3d=v%23#testz/a%2Fb/cd%3F?k%3D=v%23#test)r   z%te%stsrÍ   )Úpercentsz/%te%stsz/%25te%25stsÚftpz%%%z%a%b)ú%z%%r'  z%:%)r"   r&   r)   r*   r3   TrT   zftp://%:%@/%%%/%a%b?%=%%#%z0ftp://%25:%25@/%25%25%25/%25a%25b?%25=%25%25#%25)r   rN   r•   rZ   r  r&   Ú	normalizer"   r%   r*   rP   )	r+   r[   Znorm_urlZnoop_norm_urlZslashless_urlZslashful_urlZdelimited_urlZnorm_delimited_urlZpercenty_urlr/   r/   r0   Útest_normalize  sZ    
    ÿ

ÿÿû	
ÿÿÿÿzTestURL.test_normalizec                 C   s€   d}t  |¡}t|ƒ|kst‚t|ƒdks.t‚trXtt|ƒtƒsDt‚tt|ƒtƒs|t‚n$tt|ƒtƒsjt‚tt|ƒtƒs|t‚d S )Nu&   http://example.com/Ã¡/y%20a%20y/?b=%25s*   http://example.com/%C3%A1/y%20a%20y/?b=%25)r   rN   r#   rZ   rà   ÚPY2r!   rÖ   rð   r/   r/   r0   Útest_str¸  s    
zTestURL.test_strc                 C   s–   t  d¡}| ¡ jdkst‚| ¡ jdks.t‚t  d¡}| ¡ jdksJt‚| ¡ jdks\t‚| ¡  ¡ jdksrt‚d}t  |¡ ¡  ¡ jdks’t‚d S )	Nu   http://abÃ©.com/u   abÃ©.comzxn--ab-cja.comu(   http://ãƒ‰ãƒ¡ã‚¤ãƒ³.ãƒ†ã‚¹ãƒˆ.co.jp#testu   ãƒ‰ãƒ¡ã‚¤ãƒ³.ãƒ†ã‚¹ãƒˆ.co.jpzxn--eckwd4c7c.xn--zckzah.co.jpzhttp://Example.comrì   )r   rN   rY   r%   rZ   r–   Zget_decoded_url)r+   r[   rñ   r/   r/   r0   Útest_idna_cornersÈ  s    

ÿzTestURL.test_idna_cornersN)r   )OrÒ   rÓ   rÔ   Ú__doc__r1   r7   r<   rG   rI   rM   rS   rX   r]   r_   r`   rb   rg   rk   rl   ro   ru   rz   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È   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  r   r!  r)  r+  r,  r/   r/   r/   r0   r   ‘   sš    ÷
3		
>		*'				
		U"	;	9r   )Ú
__future__r   Úsysrø   Útypingr   r   r   r   r   r   Úcommonr
   r   r   r   Ú_urlr   r   Úversion_infor*  r(   r#   rO   rv   rw   rU   r   r/   r/   r/   r0   Ú<module>   sj    Ð4D