
    Tf?                         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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                      e Zd ZdZd Z	 dOdZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d  Z!d! Z"d" Z#d# Z$d$ Z%d% Z&d& Z'd' Z(d( Z)d) Z*d* Z+d+ Z,d, Z-d- Z.d. Z/d/ Z0d0 Z1d1 Z2d2 Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8d8 Z9d9 Z:d: Z;d; Z<d< Z=d= Z>d> Z?d? Z@d@ ZAdA ZBdB ZCdC ZDdD ZEdE ZFdF ZGdG ZHdH ZIdI ZJdJ ZKdK ZLdL ZMdM ZNdNS )PTestURLz
    Tests for L{URL}.
    c                    |                      t          |j        t                    p|j        du t	          |                     |                      t          |j        t                    p|j        du t	          |                     |j        D ]8}|                     t          |          t          t	          |                     9|j	        D ]u\  }}|                     t          |          t          t	          |                     |                      |du pt          |t                    t	          |                     v|                     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vs        I/var/www/html/env/lib/python3.11/site-packages/hyperlink/test/test_url.pyassertUnicodedzTestURL.assertUnicoded   sA    	qx))=QX-=tAww	
 	
 	
 	
16733Eqv~tAwwOOO6 	: 	:CT#YYa9999w 	J 	JGRT#YYa999OOAI?Aw)?)?aIIIIaj))7DGG<<<<<    r   c	                     |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-   r7   r8   actualexpecteds              r3   	assertURLzTestURL.assertURL   sy    @ HFFGJFJ
 $KK%LLJ
 	*****r5   c           	            f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           
      j                         |                                | ddg g ddd           d S )Nhttpr   P   )r4   r<   )r/   r.   s    r3   checkz(TestURL.test_initDefaults.<locals>.check   s=    """NN1fb"b"b"=====r5   r?   r   N)r   )r.   rA   s   ` r3   test_initDefaultszTestURL.test_initDefaults   sz    	> 	> 	> 	> 	>
 	c&"ooc&"b"%%&&&c&"b"b))*****r5   c           	          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kr2   )rH   NfNr?      à   é)u   λu   πu   ⊥r@   r   r4   r<   r.   r/   s     r3   	test_initzTestURL.test_init   s    
 S3%*k!:C@@Aq#sSEJ+Dc4PPP+?*@(KKH!"	
 	
 	
 	
 	
r5   c           	          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.
        rD   z%68z%70)%6Bz%76)rP   Nz%66NrL   rM   s     r3   test_initPercentzTestURL.test_initPercent   sj    
 UUGnm%DeLLAsEE7^]$CUD	
 	
 	
 	
 	
r5   c                     |                      t          t          dddgddgd                    dt          d	          d
           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.
        r?   foobar)bazNrG   frobr%   r(   r)   r,   r-   zURL.from_text(zhttp://foo/bar?baz&k=v#frob)N)r*   r'   r   r.   s    r3   	test_reprzTestURL.test_repr  sw     	!(*5#     $((E#F#F#F#FH	
 	
 	
 	
 	
r5   c                     t          j        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.   urlpaths     r3   test_from_textzTestURL.test_from_text  s9     -	**GOO$5$566666r5   c                     t           D ]@}t          j        |                              d          }|                     ||           AdS )z@
        L{URL.to_text} should invert L{URL.from_text}.
        Twith_passwordN)ROUNDTRIP_TESTSr   r\   r^   r*   )r.   testresults      r3   test_roundtripzTestURL.test_roundtrip%  sV    
 $ 	+ 	+D]4((00t0DDFT6****	+ 	+r5   c                 
   t           D ]z}t          j        |          }|                                }|                                }||k    sJ |                    d          }|                    d          }||k    sJ {d S )NTrc   )re   r   r\   to_irir^   )r.   rf   urliri
double_iriiri_textdouble_iri_texts          r3   test_roundtrip_double_iriz!TestURL.test_roundtrip_double_iri.  s    # 	/ 	/D-%%C**,,CJ*$$$${{{66H(00t0DDO.....r5   c                     t          j        t                    }|                     |t          j        t                               |                     |t          j        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   r\   r]   r*   assertNotEqualr_   s     r3   test_equalityzTestURL.test_equality;  sj     -	**#-	":":;;;MO 	
 	
 	
 	
 	
r5   c                     |                      t          d          t                                 |                      t          j        d          t          j        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   r\   rY   s    r3   test_fragmentEqualityzTestURL.test_fragmentEqualityK  sg     	b)))355111M.//M-..	
 	
 	
 	
 	
r5   c                    t          j        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   r\   r]   r*   childr^   r_   s     r3   
test_childzTestURL.test_childW  s     -	**<MM&!!))++	
 	
 	
 	?MM'""**,,	
 	
 	
 	EMM-((0022	
 	
 	
 	HMM.))1133	
 	
 	
 	
 	
r5   c                     t          j        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   r\   r*   rx   r^   r.   rk   s     r3   test_multiChildzTestURL.test_multiChildo  sX     m455IIc3$$,,..0N	
 	
 	
 	
 	
r5   c                     t          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(   r{   zhttp://www.foo.com/cN)r   rx   r#   rootedr*   r^   )r.   childURLs     r3   test_childInitRootzTestURL.test_childInitRootz  s_     M***0055(((/1A1A1C1CDDDDDr5   c                 v    t          d          }|                     |                                |           dS )zT
        L{URL.child} without any new segments returns the original L{URL}.
        r   r   N)r   r*   rx   r~   s     r3   test_emptyChildzTestURL.test_emptyChild  s8    
 }%%%c*****r5   c                 P   t          j        t                    }|                     d|                    d                                                     d}t          j        |          }|                     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   r\   r]   r*   siblingr^   )r.   r`   url_texts      r3   test_siblingzTestURL.test_sibling  s     -	**>OOH%%--//	
 	
 	

 ?-))9OOH%%--//	
 	
 	
 	
 	
r5   c                    t          j        t                    }|                     d|                    d                                                     |                     d|                    d                                                     |                     d|                    d                                                     |                     d|                    d                                                     |                     d	|                    d
                                          v           t          j        d          }|                     d|                    d                                                     t          j        d          }|                     |                    d                                          d           t          j        d          }d}|                     |                    d                                          |           |                     |                                                                |           t          j        d          }t          j        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=defrT   zhttp://localhost/foo/barN)r   r\   r]   r*   r   r^   r#   fromText)r.   r`   r/   resu2u3s         r3   
test_clickzTestURL.test_click  s    -	**8MM"%%''	
 	
 	

 	2MM'""**,,	
 	
 	

 	&h(?(?(G(G(I(I	
 	
 	
 	2MM'""**,,	
 	
 	
 	==!<==EEGGH	
 	
 	
 M9::/GG%&&..00	
 	
 	
 M899GG+,,44668O	
 	
 	

 M@AA),,..444 	**,,c222 L899]5!!WWR[['ABBBBBr5   c                     t          j        t                    }t          D ]@\  }}|                     |                    |                                          |           AdS )zQ
        L{URL.click} should correctly resolve the examples in RFC 3986.
        N)r   r\   relativeLinkBaseForRFC3986relativeLinkTestsForRFC3986r*   r   r^   )r.   baserefr;   s       r3   test_clickRFC3986zTestURL.test_clickRFC3986  sd    
 }788: 	B 	BOS(TZZ__4466AAAA	B 	Br5   c                     t          j        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   r\   r   assertRaisesNotImplementedErrorr   )r.   r   s     r3   test_clickSchemeRelPathzTestURL.test_clickSchemeRelPath  sP    
 }788-tz5AAA-tz8DDDDDr5   c           
         t          j        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   r\   r*   replacer%   r(   r)   r,   r-   r7   r_   s     r3   test_cloneUnchangedzTestURL.test_cloneUnchanged  s     - 566OO   
	
 
	
 
	
 	**G44444r5   c                 R   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 ]z\  }}}t          j        |                              |                                          }|                     ||d                    |t          |          ||                     {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})startr   r:   r;   N)r   r\   r   r^   r*   formatr'   )r.   testsr   r   r;   r:   s         r3   test_clickCollapsezTestURL.test_clickCollapse  s+    <;;<<<DDDCCCKKKJJJHHHIII  
 IHHKKK  
 LKK+
. ', 	 	"E5(]5))//66>>@@FCJJu++!%	 K  	 	 	 		 	r5   c                 2   |                      dt          j        d                              dd                                                     |                      dt          d                              dd                                                     t          j        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/rS   rT   zhttp://www.foo.com/?foo=barr   r   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   r\   addr^   r]   r_   s     r3   test_queryAddzTestURL.test_queryAdd-  s   
 	5M;<<SWYY		
 	
 	
 	)]###''u55==??	
 	
 	
 -	**=KK''))	
 	
 	
 	AKK&&..00	
 	
 	
 	FKK&&**622::<<	
 	
 	

 	FKK##FE22::<<	
 	
 	

 	HKK&&**5$77??AA	
 	
 	
 	
 	
r5   c                    t          j        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   r\   r]   r*   setr^   r   r_   s     r3   test_querySetzTestURL.test_querySetT  s    
 -	**8KKt$$,,..	
 	
 	

 	>KK""5*55==??	
 	
 	
 	8KKu%%))%66>>@@	
 	
 	
 	
 	
r5   c                    t          j        d          }|                     |                    d          t          j        d                     |                     |                    dd          t          j        d                     |                     |                    dd          t          j        d                     |                     |                    ddd	
          t          j        d                     dS )zG
        L{URL.remove} removes instances of a query parameter.
        z*https://example.com/a/b/?foo=1&bar=2&foo=3rS   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   r\   r*   remover~   s     r3   test_queryRemovezTestURL.test_queryRemovej  s   
 mHIIJJus}-MNN	
 	
 	
 	JJEJ--M@AA	
 	
 	

 	JJEJ++M@AA	
 	
 	

 	JJEAJ66MFGG	
 	
 	
 	
 	
r5   c                    t          j        d          }|                     |                    d          dg           |                     |                                d           t          j        d          }|                     |j        d           |                     |                                d           t          j        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))rS   r   )rT   yz7https://example.com/?argument=3&argument=4&operator=%3Doperator=N)r   r\   r*   getr^   r,   rj   to_uri)r.   r/   rl   s      r3   test_parseEqualSignInParamValuez'TestURL.test_parseEqualSignInParamValue  s    M455rWI...&@AAAM=>>"BCCC&IJJJME
 
 hhjj,,se444))*55u=====r5   c                 n    |                      t                                                      d           dS )zG
        An empty L{URL} should serialize as the empty string.
        r   N)r*   r   r^   rY   s    r3   
test_emptyzTestURL.test_empty  s,    
 	"-----r5   c                 x    t          dg          }|                     |                                d           dS )zP
        An L{URL} with query text should serialize as just query text.
        helloworldr,   z?hello=worldN)r   r*   r^   rM   s     r3   test_justQueryTextzTestURL.test_justQueryText  s<    
 )*+++n55555r5   c                 Z    t          j        d          }|                     ||           dS )z2
        L{URL} compares equal to itself.
        r   Nr   r\   r*   rM   s     r3   test_identicalEqualzTestURL.test_identicalEqual  s0    
 M-..Ar5   c                     t          j        d          }t          j        d          }|                     ||           dS )zG
        URLs with equivalent components should compare equal.
        %http://u@localhost:8080/p/a/t/h?q=p#fNr   r.   u1r   s      r3   test_similarEqualzTestURL.test_similarEqual  s@    
 ]BCC]BCCR     r5   c                     t          j        d          }t          j        d          }|                     ||k    |d|           |                     ||           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 != N)r   r\   assertFalserr   r   s      r3   test_differentNotEqualzTestURL.test_differentNotEqual  se     ]/00]/00rRR#8999B#####r5   c                    t          j        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   r\   r   objectrr   rM   s     r3   test_otherTypesNotEqualzTestURL.test_otherTypesNotEqual  s    
 M-..b"@AAAfhh(GHHHAr"""Avxx(((((r5   c                 h    t          j        d          }|                     ||k    d|z             dS )zJ
        Identical L{URL}s are not unequal (C{!=}) to each other.
        r   z%r == itselfNr   r\   r   rM   s     r3   test_identicalNotUnequalz TestURL.test_identicalNotUnequal  s9    
 MABBa!!344444r5   c                     t          j        d          }t          j        d          }|                     ||k    |d|           dS )zU
        Structurally similar L{URL}s are not unequal (C{!=}) to each other.
        r    == Nr   r   s      r3   test_similarNotUnequalzTestURL.test_similarNotUnequal  sO    
 ]BCC]BCCrRR#899999r5   c                     t          j        d          }t          j        d          }|                     ||k    |d|           dS )zS
        Structurally different L{URL}s are unequal (C{!=}) to each other.
        r   r   r   N)r   r\   r#   r   s      r3   test_differentUnequalzTestURL.test_differentUnequal  sM    
 ]/00]/00bBB"788888r5   c                     t          j        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   r\   r#   r   rM   s     r3   test_otherTypesUnequalzTestURL.test_otherTypesUnequal  sP    
 M-..R!ABBBVXX'KLLLLLr5   c                    d}t          j        |          }|                                }|                     |j        d           |                     |j        d         d           |                     |                                |           d}|                                }|                     |||d|           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   r\   asURIr*   r(   r)   r^   )r.   unicodeyrl   uriexpectedURI	actualURIs         r3   
test_asURIzTestURL.test_asURI  s    B 	 mH%%iikk#LMMMHQKM	
 	
 	
 	111FKKMM	{)))[[$I	
 	
 	
 	
 	
r5   c                    d}t          j        |          }|                                }|                     |j        d           |                     |j        d         d           |                     |                                |           d}|                                }|                     |||d|           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   r\   asIRIr*   r(   r)   r^   )r.   asciiishr   rl   expectedIRI	actualIRIs         r3   
test_asIRIzTestURL.test_asIRI  s     DmH%%iikk=111!h///1113 	 KKMM	{)))[[$I	
 	
 	
 	
 	
r5   c                     d}t          j        |          }|                                }d}|                                }|                     |||d|           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   r\   r   r^   r*   )r.   urlWithBinaryr   rl   r   r   s         r3   test_badUTF8AsIRIzTestURL.test_badUTF8AsIRI#  sr     ;mM**iikk2 	
 KKMM	{)))[[$I	
 	
 	
 	
 	
r5   c                     d}t          j        |          }|                                }|                     |                                |           dS )zT
        A L{URL} composed of non-ASCII text will result in non-ASCII text.
        r   N)r   r\   r   r*   r^   )r.   r   rl   alsoIRIs       r3   test_alreadyIRIAsIRIzTestURL.test_alreadyIRIAsIRI6  sQ    B 	 mH%%))++**H55555r5   c                     d}t          j        |          }|                                                                }|                     ||           dS )zH
        A L{URL} composed of encoded text will remain encoded.
        r   N)r   r\   r   r^   r*   )r.   r   r   r   s       r3   test_alreadyURIAsURIzTestURL.test_alreadyURIAsURIF  sN    
 GmK((IIKK''))	K00000r5   c                    t          j        d          }|                     |                    d          d           |                     |                    d          d           |                     |j        d           |                     |j        d           |                     |                                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r8   z/http://someuser@example.com/some-segment@ignoreN)r   r\   r*   	authorityr8   userr^   r   r~   s     r3   test_userinfozTestURL.test_userinfoP  s    mJ
 
 	MM$!D	
 	
 	
 	u--/FGGG'>???:...KKMMM	
 	
 	
 	KKK,,4466=	
 	
 	
 	
 	
r5   c                     t          j        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   r\   r*   r7   r^   )r.   portURLs     r3   test_portTextzTestURL.test_portTextg  sS    
 - >??t,,,**,JKKKKKr5   c                 z    |                      t          j        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   r\   r^   rY   s    r3   test_mailtozTestURL.test_mailtop  sC     	M344<<>>%	
 	
 	
 	
 	
r5   c                     t          j        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   r\   r*   r(   r)   uses_netlocr^   )r.   without_hosts     r3   test_httpWithoutHostzTestURL.test_httpWithoutHost}  s     }%9::*B///*,>???15999--//1EFFFFFr5   c                     d}t          dg          }|                     |j        |           t          ddi          }|                     |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.   r;   rk   s      r3   test_queryIterablezTestURL.test_queryIterable  sh     (*+,,,H---&)***H-----r5   c                 `    t          ddg          }|                     |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)   r~   s     r3   test_pathIterablezTestURL.test_pathIterable  s8     )***#566666r5   c           	           G d dt                     t          t          u rdnd} fd|f fd	} |d            |d            |d	            |d
d            |d            |dd                                t                    5 }t          t          t                                 g           ddd           n# 1 swxY w Y    ||d                                t                    5 }t          dt          t                                 fg           ddd           n# 1 swxY w Y    ||dz   d                                t                    5 }t          t          t                                 dfg           ddd           n# 1 swxY w Y    ||d                                t                    5  t          t          t          t          t          f                                g           ddd           n# 1 swxY w Y                        t                    5  t          t          t          t          t          f         d          g           ddd           n# 1 swxY w Y                        t                    5  t          t          t          t          t          f         d          g           ddd           n# 1 swxY w Y   t          j
        d          }                     t                    5 }|                    t          t                                            ddd           n# 1 swxY w Y    ||d                                t                    5 }|                    t          t                                            ddd           n# 1 swxY w Y    ||d                                t                    5 }|                    t          t                                            ddd           n# 1 swxY 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                       e Zd Zd Zd ZdS )1TestURL.test_invalidArguments.<locals>.Unexpectedc                     dS )Nwrong rY   s    r3   __str__z9TestURL.test_invalidArguments.<locals>.Unexpected.__str__  s    wr5   c                     dS )N<unexpected>r  rY   s    r3   __repr__z:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__  s    %~r5   N)__name__
__module____qualname__r  r!  r  r5   r3   
Unexpectedr    s2          & & & & &r5   r%  r&   strc                                          t          | j                  d                    ||d                     d S )Nzexpected {0} for {1}, got {2}r   )r*   r&  	exceptionr   )raisedexpectationr   r.   s      r3   assertRaisedz3TestURL.test_invalidArguments.<locals>.assertRaised  sM    F$%%/66~     r5   c                                          t                    5 }t          di |              i d d d            n# 1 swxY w Y    |||            d S )Nr  )r   	TypeErrorr   )paramr*  r)  r%  r+  r.   s      r3   rA   z,TestURL.test_invalidArguments.<locals>.check  s    ""9-- -,,ujjll+,,,- - - - - - - - - - - - - - - Le44444s   ?AAr%   r(   r-   r   boolr8   r7   zint or NoneTyper  Nzpath segmentr   r   z or NoneTypezquery parameter valuer   zquery parameter name)rH   r2   vv)rH   zhttps://valid.example.com/zrelative URL)r   bytesr&  r   r-  r   r	   r   r   
ValueErrorr\   rx   r   r   )r.   defaultExpectationrA   r)  rk   r%  r+  s   `    @@r3   test_invalidArgumentszTestURL.test_invalidArguments  s   	& 	& 	& 	& 	& 	& 	& 	& +03,,YYE	 	 	 	 	 &8 	5 	5 	5 	5 	5 	5 	5 	5 	hfjhjf'(((y)) 	1Vd4../0000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	V/@@@y)) 	<VT::<< 8 89:;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	&79P	
 	
 	
 y)) 	=VT::<<00':;<<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	V/1GHHH y)) 	? 	?tE$*-zz||<<=>>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? z** 	C 	CtE$*-/?@@ABBBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C z** 	9 	9tE$*-v6678888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 m899y)) 	0VIId4..///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0V/@@@y)) 	2VKKT::<<00111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2V/@@@y)) 	0VIId4..///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0V/@@@@@s   -CCC /D;;D?D?0/F++F/2F/?H((H,/H,7JJJ57K88K<?K<11M..M25M2 1OO!$O!1QQQc                    |                      t                    5 }t          d           ddd           n# 1 swxY 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.
        rS   r  Nz,expected iterable of text for path, not: {0})r   r-  r   r*   r&  r(  r   r'   )r.   r)  s     r3   !test_technicallyTextIsIterableButz)TestURL.test_technicallyTextIsIterableBut  s     y)) 	VUOOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 !!:AA$u++NN	
 	
 	
 	
 	
s   8<<c                    t          d          }|                     |j        d           |                     |                                d           |                     t          j        d          j        d           |                     t          j        d          j        d           |                     t          j        d          j        d           t          dd          }|                     |j        d           |                     |                                d           t          d	          }|                     |j        d           |                     |                                d
           t          d          }|                     |j        d           |                     |                                d           t          d          }|                     |j        d            |                     |                                d           t          j        d          }|                     |j        d           t          j        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  r^   r\   r~   s     r3   test_netloczTestURL.test_netloc  s    !!!$///
333x00<eDDDy11=uEEEz22>EEEe444%000111%%%$///777"""%000	222$//////m,--$///mN++%00000r5   c                     d}t          j        |          }|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   r\   r(   r7   r   r%   )r.   trk   s      r3   test_ipv6_with_portzTestURL.test_ipv6_with_port$  sY    CmAxDDDDDx2~~~~sz*ch666666r5   c                    d}t          j        |          }|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        |          }|j        dk    sJ |j        dk    sJ |j        dk    sJ |j        dk    sJ d	}t          j        |          }|j        dk    sJ |j        dk    sJ |j        d
k    sJ |j        dk    sJ d S )Nz3https://user:pass@example.com/path/to/here?k=v#nicer8  	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   r\   r%   r8   r(   r)   r-   r.   textrk   s      r3   
test_basiczTestURL.test_basic,  s>   DmD!!zW$$$$|{****x=((((x11111|v%%%%BmD!!zW$$$$|{****x;&&&&x11111>mD!!zW$$$$|{****x5    x1111111r5   c                 R    |                      t          t          j        d           d S )Nz#

r   r   r   r\   rY   s    r3   test_invalid_urlzTestURL.test_invalid_urlD  s"    -@@@@@r5   c                 R    |                      t          t          j        d           d S )Nzhttp://abc:

/#rJ  rY   s    r3   test_invalid_authority_urlz"TestURL.test_invalid_authority_urlH  s#    -8KLLLLLr5   c                     g d}|D ]a}d|z   dz   }|                      t          j        t          t          j        |           |                      t
          t          j        |           bd 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   r\   )r.   invalid_ipv6_ipsipr   s       r3   test_invalid_ipv6zTestURL.test_invalid_ipv6L  s|    
 
 
 # 	F 	FB!B,HflIvKKKmS]HEEEE	F 	Fr5   c                     |                      t          t          j        d           |                      t          t          j        d           d S )Nzftp://portmouth:smashz+http://reader.googlewebsite.com:neverforget)r   r   r   r\   r2  rY   s    r3   test_invalid_portzTestURL.test_invalid_portZ  sJ    -8OPPPM9	
 	
 	
 	
 	
r5   c                 J   t          j        d          }|                     |j        d           |                     |                                d           |                     |                                                                d           t          j        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   r\   r*   r(   r^   r   rj   r   s      r3   	test_idnazTestURL.test_idnac  s    ].//,///':;;;,,..0IJJJ]566"4555'ABBB,,..0DEEEEEr5   c                    t          j        d          }|                     |j        d           |                     |                                d           t          j        d          }|                     |j        d           |                     |                                d           t          j        d          }|                     |j        d           |                     |                                d           t          j        d          }|                     |j        d           |                     |                                d           t          j        d	          }|                     |j        d
           |                     |                                d	           t          j        d          }|                     |j        d           |                     |                                d           t          ddd          }|                     |                                d           t          d
ddd          }|                     |                                d           t          j        d          }|                    d          }|                     |                                d           d}t          j        |          }|                    d          }|                     |                                d           |                    d          }|                     |                                |           d S )Nzmailto:mahmoud@hatnote.comr:  zhttp://hatnote.comr?   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)   r   z
ztp:/x/y/z)r^  r   r_  r   )r%   r)   r   r  zgit+ftp:///x/y/z/zfile:///path/to/heckr9  zmailto:/path/to/heckzunregisteredscheme:///a/b/cF)r  zunregisteredscheme:/a/b/c)r   r\   r*   r%   r^   r   )r.   rk   url2r   no_netloc_url
netloc_urls         r3   test_netloc_slasheszTestURL.test_netloc_slasheso  s    m899X...(DEEEm011V,,,(<=== m-..[111(9:::m122]333(=>>> mCDDY///(OPPPmEFF]333KKMMD	
 	
 	
 _TBBB555 $	
 
 
 	(;<<< m233{{({++)?@@@0mH%%66..002MNNN[[T[22
++--x888r5   c                     t          dg          }|                     |                                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)r   z/helloN)r   r*   r^   r   rr   )r.   abs      r3   test_rooted_to_relativezTestURL.test_rooted_to_relative  s     gYg...IITI""h///Aq!!!!!r5   c                    t          ddgd          }|                     |j        d           t          dgd          }|                     |j        d           |                     ||           t          ddgd          }t          ddg          }|                     ||           |                     |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   rS   F)r)   r   TrT   )r(   r)   r   )r(   r)   N)r   r*   r   )r.   relative_path_rootedrelative_flag_rootedattempt_unrooted_absolutenormal_absolutes        r3   test_autorootedzTestURL.test_autorooted  s      #UEBBB-4d;;;"===-4d;;;-/CDDD$'U%$O$O$O!5w7772ODDD/666294@@@@@r5   c                 J   t          ddd          }t          dd          }t          ddd          }|                     |j        d           |                     |j        d           |                     |j        d           t          j        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%   r7   r   )r%   r7   Tzudp://:4900N)r   r*   r   r\   r&  asText)r.   directly_constructeddirectly_constructed_implictdirectly_constructed_rootedparseds        r3   !test_rooted_with_port_but_no_hostz)TestURL.test_rooted_with_port_but_no_host  s     #%d5III'*%d'C'C'C$&)T$&O&O&O#-4d;;;5<dCCC4;TBBB}--122CKK@@@9::CKKHHH-4466HHH-v666-/KLLL-/JKKK5v>>>4f=====r5   c                    |                      t                    5  t          t                     d d d            n# 1 swxY w Y   |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )NHTTP_____more_like_imHoTTeP)r   r2  r   r]   rY   s    r3   test_wrong_constructorzTestURL.test_wrong_constructor  s    z** 	 		NNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 z** 	/ 	/-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s!   <A A !A>>BBc                 h   t          j        d          }|j        dk    sJ |                    d          }|                                }|                    d          dk    sJ |                    d          d	k    sJ |                                                    d          d
k    sJ d S )Nzhttp://user:pass@example.comrA  zus%20her:passr  Trc   zhttp://us her:pass@example.comFzhttp://us her:@example.comz http://us%20her:pass@example.com)r   r\   r8   r   rj   r^   r   r.   rk   rl   s      r3   test_encoded_userinfozTestURL.test_encoded_userinfo  s    m:;;|{****kk?k33jjllKKdK++/OOOOO{{{//3OOOOOJJLL  t 4412 2 2 2 2 2r5   c                    i }t          j        d          }t          |          t          |          k    sJ d||<   t          j        d          }|                    dd          }d||<   t	          |          dk    sJ t          |                                          dgk    sJ t          t                                t          t                                k    sJ d S )Nz.http://blog.hatnote.com/ask?utm_source=geocityr
   zhttp://blog.hatnote.com/ask
utm_sourcegeocityr   )r   r\   hashr   lenlistvalues)r.   url_mapurl1r`  s       r3   	test_hashzTestURL.test_hash   s    }MNNDzzT$ZZ''''}:;;xxi007||q    GNN$$%%!,,,,CEE{{d355kk))))))r5   c                     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   r   rp  r   r   )r   dirr  )r.   rk   r   s      r3   test_dirzTestURL.test_dir  ss    ee#hh3xx"}}}}$$$$s""""c!!!!c!!!!!!r5   c                     t          j        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   r   rp  r   r~   s     r3   test_twisted_compatzTestURL.test_twisted_compat  sX    l?@@zz||CCCCCyy{{!!##'OOOOOOOr5   c                     t          j        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   r\   r   r   r^   r~   s     r3   test_set_orderingzTestURL.test_set_ordering%  sZ     m788ggc3ggc3{{}} CCCCCCCr5   c                    t          j        d          }t          j        |                                          }||k    sJ t          j        |                                                                          }||k    sJ ||k    sJ t          j        d          }|                                }|                                dk    sJ t          j        |                                                                          }||k    sJ 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   r\   r^   rj   r   )r.   r   r   r   u4u5u6s          r3   test_schemeless_pathzTestURL.test_schemeless_path0  s     ]@AA]2::<<((Rxxxx]299;;..0011RxxxxRxxxx ]NOOYY[[zz||HHHHH]2::<<((//11Rxxxxxxr5   c                 ~    t          j        d          }|                                }|                                 dS )z4See issue #7, affecting only narrow builds (2.6-3.3)zhttps://xn--vi8hiv.wsN)r   r\   rj   r^   rz  s      r3   test_emoji_domainzTestURL.test_emoji_domainC  s2     m344jjllr5   c                    |                      t          t          dd           |                      t          t          d           |                      t          t          d           |                      t          t          d           d	S )
zPer issue #6 and #8r?   za/c)r%   r(   )?r  )#)&rf   r   N)r   r2  r   rY   s    r3   test_delim_in_paramzTestURL.test_delim_in_paramK  sx     	*c&uEEE*c777*c777*c-AAAAAr5   c                    t          j        d          }t          j        d          }||k    sJ t          j        d          }t          j        d          }||k    sJ t          j        d          }t          j        d          }||k    sJ t          j        d          }t          j        d          }||k    sJ d S )Nzhttp://example.com/zhttp://example.com)r   r\   r   s      r3   test_empty_paths_eqzTestURL.test_empty_paths_eqS  s    ]011]/00Rxxxx]/00]/00Rxxxx]/00]011Rxxxx]011]011Rxxxxxxr5   c                     t          j        d          j        dk    sJ |                     t          t           j        d           |                     t          t           j        t                                 d S )Nz#okoks   bytes://x.y.z)r   r\   r-   r   r-  r   rY   s    r3   test_from_text_typezTestURL.test_from_text_typei  s_    }U##,4444)S]4DEEE)S]FHH=====r5   c                    |                      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::80rJ  rY   s    r3   test_from_text_bad_authorityz$TestURL.test_from_text_bad_authorityo  s     	-GGG-GGG-8HIII-8HIII 	-8KLLL-8MNNN-8NOOOOOr5   c                    t          j        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    sJ |j        dk    sJ |                    d          d	gk    sJ |j        d
k    sJ |	                                dk    sJ |                    ddddd          }||k    sJ t          j        d          }|                                }|	                                dk    sJ t          j        d          }|                                }|	                                dk    sJ t          d                              d          	                                dk    sJ t          d                                          	                                dk    sJ t          dddgdgdd          }|	                    d          d k    sJ |                                	                    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   r?   rB  )AaCcDdzhttp://example.com/Aa?Bb=Cc#DdFrW   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-   r8   Trc   zftp://%:%@/%%%/%a%b?%=%%#%z0ftp://%25:%25@/%25%25%25/%25a%25b?%25=%25%25#%25)
r   r\   r   r  r)   	normalizer%   r(   r-   r^   )	r.   rk   norm_urlnoop_norm_urlslashless_urlslashful_urldelimited_urlnorm_delimited_urlpercenty_urls	            r3   test_normalizezTestURL.test_normalize  s   mNOOwwt}}""""wwv6(****38}}!!!! ==??&((((}----}''''||D!!dV++++ D((((!!%EEEEE u5 & 
 
 #### &9::$..00##%%)===== &CDD*4466!))++/LLLLL _%%%///??GGII    (((2244<<>>.PPPP-
 
 
   t 44+, , , , ""$$,,4,@@AB B B B B Br5   c                    d}t          j        |          }t          |          |k    sJ t          |          dk    sJ t          rJt          t          |          t                    sJ t          t          |          t                    sJ d S t          t          |          t                    sJ 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   r\   r&   r1  PY2r$   r&  rF  s      r3   test_strzTestURL.test_str  s     8mD!!s||t####SzzJJJJJ 	1c#hh.....gcllG4444444c#hh00000eCjj%0000000r5   c                 :   t          j        d          }|                                j        dk    sJ |                                j        dk    sJ t          j        d          }|                                j        dk    sJ |                                j        dk    sJ |                                                                j        dk    sJ d}t          j        |                                                                          j        dk    sJ 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.comrB  )r   r\   rj   r(   r   get_decoded_url)r.   rk   rG  s      r3   test_idna_cornerszTestURL.test_idna_corners  s    m.//zz|| J....zz|| $44444mFGGzz|| $BBBBBzz|| $DDDDDzz||++--26TTTTT#M$&&((88::?=PPPPPPr5   N)r   )Or"  r#  r$  __doc__r4   r<   rB   rN   rQ   rZ   ra   rh   rp   rs   ru   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r  r  r4  r6  r<  r?  rH  rK  rM  rV  rX  rZ  rc  rg  rm  ru  rx  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r5   r3   r!   r!      s        = = =6 1+ 1+ 1+ 1+f+ + +
 
 
&	
 	
 	

 
 
(7 7 7+ + +  
 
 
 

 

 


 
 
0	
 	
 	
E E E+ + +
 
 
&<C <C <C|B B BE E E5 5 5(( ( (T%
 %
 %
N
 
 
,
 
 
2> > >*. . .6 6 6  ! ! !	$ 	$ 	$	) 	) 	)5 5 5: : :9 9 9M M M
 
 
4
 
 
0
 
 
&6 6 6 1 1 1
 
 
.L L L
 
 

G 
G 
G. . .7 7 7SA SA SAj
 
 
 1  1  1D7 7 72 2 20A A AM M MF F F
 
 

F 
F 
F9 9 9v
" 
" 
"A A A.> > >6/ / /
 
 
* * *$
" 
" 
"P P PD D D  &  B B B  ,> > >P P P 7
 7
 7
r1 1 1 
 
 
 
 
r5   r!   )
__future__r   sysrQ  typingr   r   r   r   r   r	   commonr   r   r   r   _urlr   r   version_infor  r+   r&   r]   r   r   re   r!   r  r5   r3   <module>r     s(   ( ' ' ' ' ' 



  = = = = = = = = = = = = = = = = % % % % % % ! ! ! ! ! ! ! ! - - - - - - - - 
qQ
$r(( 9	 2 1 1 1 hAHF
 F
 F
 F
 F
 F
 F
 F
 F
 F
r5   