o
    Gï÷_?Õ  ã                   @   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g d¢ZdZG dd„ deƒZdS )é    )Ú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                   @   sl  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u t|ƒ¡ |   t|jtƒp|jdu t|ƒ¡ |jD ]}|  t|ƒtt|ƒ¡ q%|j	D ]\}}|  t|ƒtt|ƒ¡ |   |du pOt|tƒt|ƒ¡ q6|  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ÚuZsegZ_kÚv© r.   ú9/usr/lib/python3/dist-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*   r1   r2   ÚactualÚexpectedr.   r.   r/   Ú	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   )r0   r6   )r,   ©r+   r.   r/   Úchecká   s   
z(TestURL.test_initDefaults.<locals>.checkr7   r   N)r   )r+   r:   r.   r9   r/   Ú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-   )r@   NÚfNr7   õ   Ã õ   Ã©)u   Î»u   Ï€u   âŠ¥r8   ©r   r0   r6   ©r+   r,   r.   r.   r/   Ú	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)rG   Nz%66NrD   rE   r.   r.   r/   Ú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.
        r7   Ú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   r9   r.   r.   r/   Ú	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.   r/   Ú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   rM   rO   r'   )r+   ÚtestÚresultr.   r.   r/   Útest_roundtrip%  s   þzTestURL.test_roundtripc                 C   sX   t D ]'}t |¡}| ¡ }| ¡ }||ksJ ‚|jdd}|jdd}||ks)J ‚qd S )NTrS   )rT   r   rM   Úto_irirO   )r+   rU   ÚurlÚiriZ
double_iriZiri_textZdouble_iri_textr.   r.   r/   Ú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   rM   rN   r'   ÚassertNotEqualrP   r.   r.   r/   Ú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   rM   r9   r.   r.   r/   Ú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   rM   rN   r'   ÚchildrO   rP   r.   r.   r/   Ú
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   rM   r'   r_   rO   ©r+   rY   r.   r.   r/   Ú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%   ra   zhttp://www.foo.com/cN)r   r_   r    Úrootedr'   rO   )r+   ZchildURLr.   r.   r/   Ú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}.
        rf   rg   N)r   r'   r_   rd   r.   r.   r/   Ú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   rM   rN   r'   ÚsiblingrO   )r+   rQ   Úurl_textr.   r.   r/   Útest_siblingŒ  s   
þ
þzTestURL.test_siblingc                 C   s$  t  t¡}|  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d| d¡ ¡ ¡ |  d	| d
¡ ¡ v¡ 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=defrJ   zhttp://localhost/foo/barN)r   rM   rN   r'   rn   rO   r    ÚfromText)r+   rQ   r,   ÚresÚu2Úu3r.   r.   r/   Ú
test_clickŸ  sL   
þþÿþÿÿ
þ
ÿ



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   rM   ÚrelativeLinkBaseForRFC3986ÚrelativeLinkTestsForRFC3986r'   rn   rO   )r+   ÚbaseÚrefr5   r.   r.   r/   Ú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   rM   rt   ÚassertRaisesÚNotImplementedErrorrn   )r+   rv   r.   r.   r/   Ú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   rM   r'   Úreplacer"   r%   r&   r)   r*   r1   rP   r.   r.   r/   Útest_cloneUnchangedï  s   
ú÷zTestURL.test_cloneUnchangedc                 C   sš   g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d	¢g d
¢g d¢g d¢g d¢g}|D ]\}}}t  |¡ |¡ ¡ }|  ||dj|t|ƒ||d¡ q+dS )zd
        L{URL.click} collapses C{.} and C{..} according to RFC 3986 section
        5.2.4.
        )r   r   r   )r   r   r   )úhttp://localhost/a/b/cr   zhttp://localhost/a/b/)r~   r   zhttp://localhost/a/)r~   z./d/ezhttp://localhost/a/b/d/e)r~   ú../d/eúhttp://localhost/a/d/e)r~   z/./d/eúhttp://localhost/d/e)r~   z/../d/er   )zhttp://localhost/a/b/c/z
../../d/e/zhttp://localhost/a/d/e/)zhttp://localhost/a/./cr   r   )zhttp://localhost/a/./c/r   r€   )zhttp://localhost/a/b/c/dz./e/../f/../gzhttp://localhost/a/b/c/g)r~   zd//ezhttp://localhost/a/b/d//ez1{start}.click({click}) => {actual} not {expected})Ústartrn   r4   r5   N)r   rM   rn   rO   r'   Úformatr$   )r+   Ztestsr‚   rn   r5   r4   r.   r.   r/   Útest_clickCollapse  s6   ëüýþ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/rI   rJ   zhttp://www.foo.com/?foo=barrf   rg   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   rM   ÚaddrO   rN   rP   r.   r.   r/   Ú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   rM   rN   r'   ÚsetrO   rˆ   rP   r.   r.   r/   Ú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=3rI   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   rM   r'   Úremoverd   r.   r.   r/   Ú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))rI   r’   )rJ   Úyz7https://example.com/?argument=3&argument=4&operator=%3DÚoperatorú=N)r   rM   r'   ÚgetrO   r)   rX   Úto_uri)r+   r,   rZ   r.   r.   r/   Ú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   rO   r9   r.   r.   r/   Ú
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'   rO   rE   r.   r.   r/   Útest_justQueryTextŸ  s   zTestURL.test_justQueryTextc                 C   s   t  d¡}|  ||¡ dS )z2
        L{URL} compares equal to itself.
        r   N©r   rM   r'   rE   r.   r.   r/   Ú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+   Úu1rq   r.   r.   r/   Ú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   rM   ÚassertFalser\   r¢   r.   r.   r/   Ú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   rM   r¨   Úobjectr\   rE   r.   r.   r/   Ú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   rM   r¨   rE   r.   r.   r/   Ú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.   r/   Útest_similarNotUnequalÖ  ó   

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   rM   r    r¢   r.   r.   r/   Útest_differentUnequalß  r±   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   rM   r    r«   rE   r.   r.   r/   Útest_otherTypesUnequalè  s   
zTestURL.test_otherTypesUnequalc                 C   ól   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   rM   ÚasURIr'   r%   r&   rO   )r+   ÚunicodeyrZ   ÚuriÚexpectedURIÚ	actualURIr.   r.   r/   Ú
test_asURIñ  s   ÿ

ÿÿzTestURL.test_asURIc                 C   r´   )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   rM   ÚasIRIr'   r%   r&   rO   )r+   Zasciiishr¹   rZ   ÚexpectedIRIÚ	actualIRIr.   r.   r/   Ú
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   rM   r½   rO   r'   )r+   ZurlWithBinaryr¹   rZ   r¾   r¿   r.   r.   r/   Ú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   rM   r½   r'   rO   )r+   r¸   rZ   ZalsoIRIr.   r.   r/   Ú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   rM   r·   rO   r'   )r+   rº   r¹   r»   r.   r.   r/   Ú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©r2   z/http://someuser@example.com/some-segment@ignoreN)r   rM   r'   Z	authorityr2   ÚuserrO   r|   rd   r.   r.   r/   Ú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   rM   r'   r1   rO   )r+   ZportURLr.   r.   r/   Ú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   rM   rO   r9   r.   r.   r/   Ú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   rM   r'   r%   r&   Úuses_netlocrO   )r+   Zwithout_hostr.   r.   r/   Ú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+   r5   rY   r.   r.   r/   Ú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&   rd   r.   r.   r/   Útest_pathIterable–  s   zTestURL.test_pathIterablec                    s  G dd„ dt ƒ‰ ttu 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 d  ƒ n1 sTw   Y  ˆ||dƒ ˆ t¡}tdttˆ ƒ ƒfgd W d  ƒ n1 s{w   Y  ˆ||d dƒ ˆ t¡}tttˆ ƒ ƒdfgd W d  ƒ n1 s¤w   Y  ˆ||dƒ ˆ t¡ tttttf ˆ ƒ ƒgd W d  ƒ n1 sÍw   Y  ˆ t	¡ tttttf dƒgd W d  ƒ n1 sïw   Y  ˆ t	¡ tttttf dƒgd W d  ƒ n	1 sw   Y  t 
d¡}ˆ t¡}| ttˆ ƒ ƒ¡ W d  ƒ n	1 s6w   Y  ˆ||dƒ ˆ t¡}| ttˆ ƒ ƒ¡ W d  ƒ n	1 s[w   Y  ˆ||dƒ ˆ t¡}| ttˆ ƒ ƒ¡ W d  ƒ n	1 s€w   Y  ˆ||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   ó   dS )NZwrongr.   r9   r.   r.   r/   Ú__str__¬  ó   z9TestURL.test_invalidArguments.<locals>.Unexpected.__str__c                 S   rÑ   )Nú<unexpected>r.   r9   r.   r.   r/   Ú__repr__°  rÓ   z:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__N)Ú__name__Ú
__module__Ú__qualname__rÒ   rÕ   r.   r.   r.   r/   Ú
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   r9   r.   r/   ÚassertRaised¶  s   ÿþz3TestURL.test_invalidArguments.<locals>.assertRaisedc                    sN   ˆ  t¡}tdi | ˆ ƒ i¤Ž W d   ƒ n1 sw   Y  ˆ||| ƒ d S )Nr.   )ry   Ú	TypeErrorr   )ZparamrÝ   rÜ   ©rÙ   rÞ   r+   r.   r/   r:   ¿  s   ÿz,TestURL.test_invalidArguments.<locals>.checkr"   r%   r*   rh   Úboolr2   r1   zint or NoneTyperÏ   Nzpath segmentr   r   z or NoneTypezquery parameter valuerŽ   zquery parameter name)r@   r-   Zvv)r@   zhttps://valid.example.com/zrelative URL)r«   ÚbytesrÚ   ry   rß   r   r   r   r   Ú
ValueErrorrM   r_   rk   rn   )r+   ZdefaultExpectationr:   rÜ   rY   r.   rà   r/   Útest_invalidArgumentsŸ  s\   		

ÿÿ
ÿÿÿÿÿ
ÿÿÿzTestURL.test_invalidArgumentsc                 C   sT   |   t¡}tdd W d  ƒ n1 sw   Y  |  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.
        rI   rÏ   Nz,expected iterable of text for path, not: {0})ry   rß   r   r'   rÚ   rÛ   rƒ   r$   )r+   rÜ   r.   r.   r/   Ú!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É   rO   rM   rd   r.   r.   r/   Útest_netloc  s,   





zTestURL.test_netlocc                 C   sB   d}t  |¡}|jdksJ ‚|jdksJ ‚t|j |jksJ ‚d S )Nz5https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:80/z'2001:0db8:85a3:0000:0000:8a2e:0370:7334r8   )r   rM   r%   r1   r   r"   )r+   ÚtrY   r.   r.   r/   Útest_ipv6_with_port$  s
   
zTestURL.test_ipv6_with_portc                 C   sä   d}t  |¡}|jdksJ ‚|jdksJ ‚|jdksJ ‚|jdks#J ‚|jdks*J ‚d}t  |¡}|jdks8J ‚|jdks?J ‚|jdksFJ ‚|jdksMJ ‚d	}t  |¡}|jdks[J ‚|jdksbJ ‚|jd
ksiJ ‚|jdkspJ ‚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   rM   r"   r2   r%   r&   r*   ©r+   ÚtextrY   r.   r.   r/   Ú
test_basic,  s&   


zTestURL.test_basicc                 C   ó   |   ttjd¡ d S )Nz#

©ry   r   r   rM   r9   r.   r.   r/   Útest_invalid_urlD  ó   zTestURL.test_invalid_urlc                 C   rõ   )Nzhttp://abc:

/#rö   r9   r.   r.   r/   Útest_invalid_authority_urlH  rø   z"TestURL.test_invalid_authority_urlc                 C   sF   g d¢}|D ]}d| d }|   tjttj|¡ |   ttj|¡ qd S )N)z2001::0234:C1ab::A0:aabc:003Fz2001::1::3Fú:z::::z::256.0.0.1zhttp://[ú])ry   ÚsocketÚerrorr   ZAF_INET6r   r   rM   )r+   Zinvalid_ipv6_ipsZiprl   r.   r.   r/   Ú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)ry   r   r   rM   rã   r9   r.   r.   r/   Ú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   rM   r'   r%   rO   r—   rX   r¢   r.   r.   r/   Ú	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.comr7   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&   rh   z
ztp:/x/y/z)r  r“   r  r   )r"   r&   rh   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   rM   r'   r"   rO   r|   )r+   rY   Úurl2rl   Zno_netloc_urlZ
netloc_urlr.   r.   r/   Útest_netloc_slasheso  sN   





ÿü

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)rh   z/helloN)r   r'   rO   r|   r\   )r+   ÚaÚbr.   r.   r/   Ú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   rI   F)r&   rh   TrJ   )r%   r&   rh   )r%   r&   N)r   r'   rh   )r+   Zrelative_path_rootedZrelative_flag_rootedZattempt_unrooted_absoluteZnormal_absoluter.   r.   r/   Ú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"   r1   rh   )r"   r1   Tzudp://:4900N)r   r'   rh   rM   rÚ   ÚasText)r+   Zdirectly_constructedZdirectly_constructed_implictZdirectly_constructed_rootedZparsedr.   r.   r/   Ú!test_rooted_with_port_but_no_hostÍ  s   
z)TestURL.test_rooted_with_port_but_no_hostc                 C   sj   |   t¡ ttƒ W d   ƒ n1 sw   Y  |   t¡ tdƒ W d   ƒ d S 1 s.w   Y  d S )NZHTTP_____more_like_imHoTTeP)ry   rã   r   rN   r9   r.   r.   r/   Útest_wrong_constructorè  s   
þ
"þzTestURL.test_wrong_constructorc                 C   sp   t  d¡}|jdksJ ‚|jdd}| ¡ }|jdddks J ‚|jddd	ks*J ‚| ¡ jddd
ks6J ‚d S )Nzhttp://user:pass@example.comrí   zus%20her:passrÄ   TrS   zhttp://us her:pass@example.comFzhttp://us her:@example.comz http://us%20her:pass@example.com)r   rM   r2   r|   rX   rO   r—   ©r+   rY   rZ   r.   r.   r/   Útest_encoded_userinfoñ  s   
ÿÿ
ÿzTestURL.test_encoded_userinfoc                 C   sŠ   i }t  d¡}t|ƒt|ƒksJ ‚d||< t  d¡}| dd¡}d||< t|ƒdks,J ‚t| ¡ ƒdgks7J ‚tt ƒ ƒtt ƒ ƒksCJ ‚d S )Nz.http://blog.hatnote.com/ask?utm_source=geocityr	   zhttp://blog.hatnote.com/askZ
utm_sourceZgeocityr   )r   rM   ÚhashrŠ   ÚlenÚlistÚvalues)r+   Zurl_mapZurl1r  r.   r.   r/   Ú	test_hash   s   

zTestURL.test_hashc                 C   sR   t ƒ }t|ƒ}t|ƒdksJ ‚d|vsJ ‚d|vsJ ‚d|vs!J ‚d|vs'J ‚d S )Né   ro   r	  r·   r½   )r   Údirr  )r+   rY   rp   r.   r.   r/   Útest_dir  s   zTestURL.test_dirc                 C   s2   t  d¡}| ¡ dksJ ‚| ¡  ¡ dksJ ‚d S )Nu"   http://example.com/a%20tÃ©%C3%A9stz&http://example.com/a%20t%C3%A9%C3%A9st)r   ro   r	  r·   rd   r.   r.   r/   Útest_twisted_compat  s   
zTestURL.test_twisted_compatc                 C   s6   t  d¡}| dd¡}| dd¡}| ¡ dksJ ‚d S )Nzhttp://example.com/?a=b&cr  r“   z!http://example.com/?a=b&x=x&c&x=y)r   rM   rŠ   rˆ   rO   rd   r.   r.   r/   Útest_set_ordering%  s   
zTestURL.test_set_orderingc                 C   s’   t  d¡}t  | ¡ ¡}||ksJ ‚t  | ¡  ¡ ¡}||ks!J ‚||ks'J ‚t  d¡}| ¡ }| ¡ dks8J ‚t  | ¡ ¡ ¡ }||ksGJ ‚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   rM   rO   rX   r—   )r+   r£   rq   rr   Zu4Zu5Zu6r.   r.   r/   Ú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   rM   rX   rO   r  r.   r.   r/   Ú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 #8r7   za/c)r"   r%   )ú?rÏ   )ú#)ú&rU   r   N)ry   rã   r   r9   r.   r.   r/   Útest_delim_in_paramK  s   zTestURL.test_delim_in_paramc                 C   s„   t  d¡}t  d¡}||ksJ ‚t  d¡}t  d¡}||ks J ‚t  d¡}t  d¡}||ks0J ‚t  d¡}t  d¡}||ks@J ‚d S )Nzhttp://example.com/zhttp://example.com)r   rM   r¢   r.   r.   r/   Útest_empty_paths_eqS  s   







zTestURL.test_empty_paths_eqc                 C   s:   t  d¡jdks
J ‚|  tt jd¡ |  tt jtƒ ¡ d S )Nz#okÚoks   bytes://x.y.z)r   rM   r*   ry   rß   r«   r9   r.   r.   r/   Ú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ö   r9   r.   r.   r/   Útest_from_text_bad_authorityo  s   z$TestURL.test_from_text_bad_authorityc           	      C   sŠ  t  d¡}| d¡g ksJ ‚| d¡dgksJ ‚t|jƒdks!J ‚| ¡ }|jdks,J ‚|jdks3J ‚|jdks:J ‚| d¡d	gksDJ ‚|jd
ksKJ ‚| 	¡ dksSJ ‚|jdddddd}||kscJ ‚t  d¡}| ¡ }| 	¡ dkstJ ‚t  d¡}| ¡ }| 	¡ dks…J ‚t ddjdd 	¡ dks”J ‚t dd ¡  	¡ dks¡J ‚t dddgdgddd}|j	ddd ks·J ‚| ¡ j	ddd!ksÃJ ‚d S )"Nz0HTTP://Example.com/A%61/./../A%61?B%62=C%63#D%64ZBbzB%62zC%63é   r7   rî   )ZAaZCcZDdzhttp://example.com/Aa?Bb=Cc#DdFrK   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%25stsZftpz%%%z%a%b)ú%z%%r$  z%:%)r"   r&   r)   r*   r2   TrS   zftp://%:%@/%%%/%a%b?%=%%#%z0ftp://%25:%25@/%25%25%25/%25a%25b?%25=%25%25#%25)
r   rM   r–   r  r&   Ú	normalizer"   r%   r*   rO   )	r+   rY   Znorm_urlZnoop_norm_urlZslashless_urlZslashful_urlZdelimited_urlZnorm_delimited_urlZpercenty_urlr.   r.   r/   Útest_normalize  sR   

ÿ

ÿÿû
	ÿÿÿ
ÿzTestURL.test_normalizec                 C   s‚   d}t  |¡}t|ƒ|ksJ ‚t|ƒdksJ ‚tr-tt|ƒtƒs"J ‚tt|ƒtƒs+J ‚d S tt|ƒtƒs6J ‚tt|ƒtƒs?J ‚d S )Nu&   http://example.com/Ã¡/y%20a%20y/?b=%25s*   http://example.com/%C3%A1/y%20a%20y/?b=%25)r   rM   r#   râ   ÚPY2r!   rÚ   rò   r.   r.   r/   Útest_str¸  s   
zTestURL.test_strc                 C   s–   t  d¡}| ¡ jdksJ ‚| ¡ jdksJ ‚t  d¡}| ¡ jdks%J ‚| ¡ jdks.J ‚| ¡  ¡ jdks9J ‚d}t  |¡ ¡  ¡ jdksIJ ‚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   rM   rX   r%   r—   Zget_decoded_url)r+   rY   ró   r.   r.   r/   Útest_idna_cornersÈ  s   


ÿzTestURL.test_idna_cornersN)r   )OrÖ   r×   rØ   Ú__doc__r0   r6   r;   rF   rH   rL   rR   rW   r[   r]   r^   r`   re   ri   rj   rm   rs   rx   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.   r/   r   ‘   sœ    
÷3		
>		*'				
		U"	;	9r   )Z
__future__r   Úsysrü   Útypingr   r   r   r   r   r   Úcommonr
   r   r   r   Z_urlr   r   Úversion_infor'  r(   r#   rN   rt   ru   rT   r   r.   r.   r.   r/   Ú<module>   s    4D