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ÚuÚsegÚ_kÚv© r0   ú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*   r3   r4   ÚactualÚexpectedr0   r0   r1   Ú	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   )r2   r8   )r,   ©r+   r0   r1   Úchecká   s   
z(TestURL.test_initDefaults.<locals>.checkr9   r   N)r   )r+   r<   r0   r;   r1   Ú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/   )rB   NÚfNr9   õ   Ã õ   Ã©)u   Î»u   Ï€u   âŠ¥r:   ©r   r2   r8   ©r+   r,   r0   r0   r1   Ú	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)rI   Nz%66NrF   rG   r0   r0   r1   Ú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.
        r9   ÚfooÚbar)ÚbazNrA   Úfrob©r"   r%   r&   r)   r*   zURL.from_text(%s)zhttp://foo/bar?baz&k=v#frobN)r'   r$   r   r;   r0   r0   r1   Ú	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+   Úurlpathr0   r0   r1   Ú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©Úwith_passwordN)ÚROUNDTRIP_TESTSr   rQ   rS   r'   )r+   ÚtestÚresultr0   r0   r1   Ú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 )NTrW   )rY   r   rQ   Úto_irirS   )r+   rZ   ÚurlÚiriÚ
double_iriÚiri_textÚdouble_iri_textr0   r0   r1   Ú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   rQ   rR   r'   ÚassertNotEqualrT   r0   r0   r1   Ú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   rQ   r;   r0   r0   r1   Ú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&zutÚ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   rQ   rR   r'   ÚchildrS   rT   r0   r0   r1   Ú
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   rQ   r'   rh   rS   ©r+   r^   r0   r0   r1   Ú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%   rj   zhttp://www.foo.com/cN)r   rh   r    Úrootedr'   rS   )r+   ÚchildURLr0   r0   r1   Ú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}.
        ro   rp   N)r   r'   rh   rm   r0   r0   r1   Ú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&zutÚsisterz)http://www.foo.com/a/nice/path?zot=23&zutz+http://www.foo.com/a/nice/sister?zot=23&zutN)r   rQ   rR   r'   ÚsiblingrS   )r+   rU   Úurl_textr0   r0   r1   Ú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=defrL   zhttp://localhost/foo/barN)r   rQ   rR   r'   ry   rS   r    ÚfromText)r+   rU   r,   ÚresÚu2Úu3r0   r0   r1   Ú
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   rQ   ÚrelativeLinkBaseForRFC3986ÚrelativeLinkTestsForRFC3986r'   ry   rS   )r+   ÚbaseÚrefr7   r0   r0   r1   Ú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   rQ   r   ÚassertRaisesÚNotImplementedErrorry   )r+   r   r0   r0   r1   Ú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   rQ   r'   Úreplacer"   r%   r&   r)   r*   r3   rT   r0   r0   r1   Ú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})Ústartry   r6   r7   N)r   rQ   ry   rS   r'   Úformatr$   )r+   Útestsr   ry   r7   r6   r0   r0   r1   Ú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/rK   rL   zhttp://www.foo.com/?foo=barro   rp   z/http://www.foo.com/a/nice/path/?zot=23&zut&burpÚburpz3http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxxÚxxxz8http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx&zingÚ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   rQ   ÚaddrS   rR   rT   r0   r0   r1   Ú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=itworkedÚzutÚitworkedr’   N)r   rQ   rR   r'   ÚsetrS   r–   rT   r0   r0   r1   Ú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=3rK   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   rQ   r'   Úremoverm   r0   r0   r1   Ú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))rK   r¢   )rL   Úyz7https://example.com/?argument=3&argument=4&operator=%3DÚoperatorú=N)r   rQ   r'   ÚgetrS   r)   r]   Úto_uri)r+   r,   r_   r0   r0   r1   Ú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   rS   r;   r0   r0   r1   Ú
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'   rS   rG   r0   r0   r1   Útest_justQueryTextŸ  s   zTestURL.test_justQueryTextc                 C   s   t  d¡}|  ||¡ dS )z2
        L{URL} compares equal to itself.
        r   N©r   rQ   r'   rG   r0   r0   r1   Ú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+   Úu1r|   r0   r0   r1   Ú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   rQ   ÚassertFalserd   r²   r0   r0   r1   Ú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   rQ   r¸   Úobjectrd   rG   r0   r0   r1   Ú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   rQ   r¸   rG   r0   r0   r1   Ú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²   r0   r0   r1   Ú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   rQ   r    r²   r0   r0   r1   Ú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   rQ   r    r»   rG   r0   r0   r1   Ú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   rQ   ÚasURIr'   r%   r&   rS   )r+   Úunicodeyr_   ÚuriÚexpectedURIÚ	actualURIr0   r0   r1   Ú
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   rQ   ÚasIRIr'   r%   r&   rS   )r+   ÚasciiishrÉ   r_   ÚexpectedIRIÚ	actualIRIr0   r0   r1   Ú
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   rQ   rÍ   rS   r'   )r+   ÚurlWithBinaryrÉ   r_   rÏ   rÐ   r0   r0   r1   Ú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   rQ   rÍ   r'   rS   )r+   rÈ   r_   ÚalsoIRIr0   r0   r1   Ú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   rQ   rÇ   rS   r'   )r+   rÊ   rÉ   rË   r0   r0   r1   Ú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:somepasswordÚsomeuserz0http://someuser:@example.com/some-segment@ignore©r4   z/http://someuser@example.com/some-segment@ignoreN)r   rQ   r'   Ú	authorityr4   ÚuserrS   r‡   rm   r0   r0   r1   Ú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   rQ   r'   r3   rS   )r+   ÚportURLr0   r0   r1   Ú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   rQ   rS   r;   r0   r0   r1   Ú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   rQ   r'   r%   r&   Úuses_netlocrS   )r+   Úwithout_hostr0   r0   r1   Ú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+   r7   r^   r0   r0   r1   Ú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&   rm   r0   r0   r1   Ú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 )NÚwrongr0   r;   r0   r0   r1   Ú__str__¬  ó   z9TestURL.test_invalidArguments.<locals>.Unexpected.__str__c                 S   rè   )Nú<unexpected>r0   r;   r0   r0   r1   Ú__repr__°  rë   z:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__N)Ú__name__Ú
__module__Ú__qualname__rê   rí   r0   r0   r0   r1   Ú
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;   r0   r1   ÚassertRaised¶  s   ÿþz3TestURL.test_invalidArguments.<locals>.assertRaisedc                    sN   ˆ  t¡}tdi | ˆ ƒ i¤Ž W d   ƒ n1 sw   Y  ˆ||| ƒ d S )Nr0   )r„   Ú	TypeErrorr   )Úparamrõ   rô   ©rñ   rö   r+   r0   r1   r<   ¿  s   ÿz,TestURL.test_invalidArguments.<locals>.checkr"   r%   r*   rq   Úboolr4   r3   zint or NoneTyperæ   Nzpath segmentr   r­   z or NoneTypezquery parameter valuerž   zquery parameter name)rB   r/   Úvv)rB   zhttps://valid.example.com/zrelative URL)r»   Úbytesrò   r„   r÷   r   r   r   r   Ú
ValueErrorrQ   rh   rv   ry   )r+   ÚdefaultExpectationr<   rô   r^   r0   rù   r1   Ú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.
        rK   ræ   Nz,expected iterable of text for path, not: {0})r„   r÷   r   r'   rò   ró   rŽ   r$   )r+   rô   r0   r0   r1   Ú!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ß   rS   rQ   rm   r0   r0   r1   Ú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:7334r:   )r   rQ   r%   r3   r   r"   )r+   Útr^   r0   r0   r1   Ú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   rQ   r"   r4   r%   r&   r*   ©r+   Útextr^   r0   r0   r1   Ú
test_basic,  s&   


zTestURL.test_basicc                 C   ó   |   ttjd¡ d S )Nz#

©r„   r   r   rQ   r;   r0   r0   r1   Útest_invalid_urlD  ó   zTestURL.test_invalid_urlc                 C   r  )Nzhttp://abc:

/#r  r;   r0   r0   r1   Ú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://[ú])r„   ÚsocketÚerrorr   ÚAF_INET6r   r   rQ   )r+   Úinvalid_ipv6_ipsÚiprw   r0   r0   r1   Ú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   rQ   rý   r;   r0   r0   r1   Ú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   rQ   r'   r%   rS   r§   r]   r²   r0   r0   r1   Ú	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.comr9   znewscheme:a:b:cÚ	newschemeznewerscheme://a/b/cÚnewerschemez%git+ftp://gitstub.biz/glyph/lefkowitzzgit+ftpz'what+mailto:freerealestate@enotuniq.orgzwhat+mailtor  )Úxr£   ÚzT)r"   r&   rq   z
ztp:/x/y/z)r!  r£   r"  r   )r"   r&   rq   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   rQ   r'   r"   rS   r‡   )r+   r^   Úurl2rw   Úno_netloc_urlÚ
netloc_urlr0   r0   r1   Ú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)rq   z/helloN)r   r'   rS   r‡   rd   )r+   ÚaÚbr0   r0   r1   Ú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   rK   F)r&   rq   TrL   )r%   r&   rq   )r%   r&   N)r   r'   rq   )r+   Úrelative_path_rootedÚrelative_flag_rootedÚattempt_unrooted_absoluteÚnormal_absoluter0   r0   r1   Ú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.
        Úudpi$  F)r"   r3   rq   )r"   r3   Tzudp://:4900N)r   r'   rq   rQ   rò   ÚasText)r+   Údirectly_constructedÚdirectly_constructed_implictÚdirectly_constructed_rootedÚparsedr0   r0   r1   Ú!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 )NÚHTTP_____more_like_imHoTTeP)r„   rý   r   rR   r;   r0   r0   r1   Ú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Ø   TrW   zhttp://us her:pass@example.comFzhttp://us her:@example.comz http://us%20her:pass@example.com)r   rQ   r4   r‡   r]   rS   r§   ©r+   r^   r_   r0   r0   r1   Ú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/askÚ
utm_sourceÚgeocityr   )r   rQ   Úhashrš   ÚlenÚlistÚvalues)r+   Úurl_mapÚurl1r#  r0   r0   r1   Ú	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é   rz   r0  rÇ   rÍ   )r   Údirr=  )r+   r^   r{   r0   r0   r1   Ú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   rz   r0  rÇ   rm   r0   r0   r1   Ú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   rQ   rš   r–   rS   rm   r0   r0   r1   Ú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   rQ   rS   r]   r§   )r+   r³   r|   r}   Úu4Úu5Úu6r0   r0   r1   Ú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   rQ   r]   rS   r8  r0   r0   r1   Ú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 #8r9   za/c)r"   r%   )ú?ræ   )ú#)ú&rZ   r­   N)r„   rý   r   r;   r0   r0   r1   Ú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   rQ   r²   r0   r0   r1   Ú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   rQ   r*   r„   r÷   r»   r;   r0   r0   r1   Ú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;   r0   r0   r1   Ú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%64ÚBbzB%62zC%63é   r9   r	  )ÚAaÚCcÚDdzhttp://example.com/Aa?Bb=Cc#DdFrO   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*   r4   TrW   zftp://%:%@/%%%/%a%b?%=%%#%z0ftp://%25:%25@/%25%25%25/%25a%25b?%25=%25%25#%25)
r   rQ   r¦   r=  r&   Ú	normalizer"   r%   r*   rS   )	r+   r^   Únorm_urlÚnoop_norm_urlÚslashless_urlÚslashful_urlÚdelimited_urlÚnorm_delimited_urlÚpercenty_urlr0   r0   r1   Ú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   rQ   r#   rü   ÚPY2r!   rò   r  r0   r0   r1   Ú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   rQ   r]   r%   r§   Úget_decoded_url)r+   r^   r  r0   r0   r1   Útest_idna_cornersÈ  s   


ÿzTestURL.test_idna_cornersN)r   )Orî   rï   rð   Ú__doc__r2   r8   r=   rH   rJ   rP   rV   r\   rc   re   rf   ri   rn   rs   rt   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.  r5  r7  r9  rB  rE  rF  rG  rK  rL  rP  rQ  rS  rT  re  rg  ri  r0   r0   r0   r1   r   ‘   sœ    
÷3		
>		*'				
		U"	;	9r   )Ú
__future__r   Úsysr  Útypingr   r   r   r   r   r   Úcommonr
   r   r   r   Ú_urlr   r   Úversion_inforf  r(   r#   rR   r   r€   rY   r   r0   r0   r0   r1   Ú<module>   s    4D