
    h?                         S SK Jr  S SKrS SKrS SKJrJrJrJrJ	r	J
r
  SSKJr  SSKJrJr  SSKJrJr  \R&                  S    S:H  r\" S	5      rS
rSr/ SQrSr " S S\5      rg)    )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                      \ rS rSrSrS r SPS jrS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-S, r.S- r/S. r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5 r7S6 r8S7 r9S8 r:S9 r;S: r<S; r=S< r>S= r?S> r@S? rAS@ rBSA rCSB rDSC rESD rFSE rGSF rHSG rISH rJSI rKSJ rLSK rMSL rNSM rOSNrPgO)QTestURL   z
Tests for L{URL}.
c                    U R                  [        UR                  [        5      =(       d    UR                  SL [	        U5      5        U R                  [        UR
                  [        5      =(       d    UR
                  SL [	        U5      5        UR                   H,  nU R                  [        U5      [        [	        U5      5        M.     UR                   Hb  u  p4U R                  [        W5      [        [	        U5      5        U R                  USL =(       d    [        U[        5      [	        U5      5        Md     U R                  [        UR                  5      [        [	        U5      5        g)zT
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        ^/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/hyperlink/test/test_url.pyassertUnicodedTestURL.assertUnicoded   s     	qxx)=QXX-=tAw	
 	
16673Eqvv~tAwO66CT#Ya9 wwGRT#Ya9OOAI?Aw)?aI  	ajj)7DG<    c	                    UR                   UR                  UR                  UR                  UR                  UR
                  UR                  4n	UU[        U5      [        U5      UUUR                  4n
U R                  X5        g)aZ  
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/   r0   r&   r)   r*   r-   r.   r9   r:   actualexpecteds              r4   	assertURLTestURL.assertURL   sw    @ HHFFFFGGJJFFJJ
 $K%LJJ
 	*r7   c           	         ^  U 4S jnU" [        SS5      5        U" [        SS/ / 5      5        U" [        SS/ / S5      5        g)z0
L{URL} should have appropriate default values.
c           
      X   > TR                  U 5        TR                  U SS/ / SSS5        g )Nhttpr   P   )r5   r>   )r0   r/   s    r4   check(TestURL.test_initDefaults.<locals>.check   s+    "NN1fb"b"b"=r7   rB   r   N)r   )r/   rD   s   ` r4   test_initDefaultsTestURL.test_initDefaults   s@    	>
 	c&"oc&"b"%&c&"b"b)*r7   c           	          [        SSS/SS/S5      nU R                  U5        U R                  USSS/SS/SS5        U R                  [        SS	S
/S/S5      SS	S
/S/SS5        g)z-
L{URL} should accept L{unicode} parameters.
shpkr3   )rM   NfNrB      à   é)u   λu   πu   ⊥rC   r   r5   r>   r/   r0   s     r4   	test_initTestURL.test_init   s    
 S3%*k!:C@Aq#sSEJ+Dc4P+?*@(KH!"	
r7   c           	      ~    [        SSS/SS/S5      nU R                  U5        U R                  USSS/SS/SS5        g)z>
L{URL} should accept (and not interpret) percent characters.
rI   z%68z%70)%6Bz%76)rV   Nz%66NrQ   rR   s     r4   test_initPercentTestURL.test_initPercent   sM    
 UUGnm%DeLAsEE7^]$CUD	
r7   c                 r    U R                  [        [        SSS/SS/SS95      S[        S	5      < S
35        g)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.
rB   foobar)bazNrL   frobr&   r)   r*   r-   r.   zURL.from_text(zhttp://foo/bar?baz&k=v#frob)N)r+   r(   r   r/   s    r4   	test_reprTestURL.test_repr  sF     	!(*5# $((E#FH	
r7   c                     [         R                  " [        5      nU R                  [        UR	                  5       5        g)zK
Round-tripping L{URL.from_text} with C{str} results in an equivalent
URL.
N)r   	from_text	BASIC_URLr+   to_textr/   urlpaths     r4   test_from_textTestURL.test_from_text  s)     --	*GOO$56r7   c                     [          H7  n[        R                  " U5      R                  SS9nU R	                  X5        M9     g)z0
L{URL.to_text} should invert L{URL.from_text}.
Twith_passwordN)ROUNDTRIP_TESTSr   rd   rf   r+   )r/   testresults      r4   test_roundtripTestURL.test_roundtrip%  s8    
 $D]]4(00t0DFT* $r7   c                     [          He  n[        R                  " U5      nUR                  5       nUR                  5       nX4:X  d   eUR	                  SS9nUR	                  SS9nXV:X  a  Me   e   g )NTrl   )rn   r   rd   to_irirf   )r/   ro   urliri
double_iriiri_textdouble_iri_texts          r4   test_roundtrip_double_iri!TestURL.test_roundtrip_double_iri.  sp    #D--%C**,CJ$$${{{6H(00t0DO... $ 	r7   c                     [         R                  " [        5      nU R                  U[         R                  " [        5      5        U R	                  U[         R                  " S5      5        g)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   rd   re   r+   assertNotEqualrg   s     r4   test_equalityTestURL.test_equality;  sK     --	*#--	":;MMO	
r7   c                     U R                  [        SS9[        5       5        U R                  [        R                  " S5      [        R                  " S5      5        g)zt
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   rd   r`   s    r4   test_fragmentEqualityTestURL.test_fragmentEqualityK  sC     	b)351MM./MM-.	
r7   c                    [         R                  " [        5      nU R                  SUR	                  S5      R                  5       5        U R                  SUR	                  S5      R                  5       5        U R                  SUR	                  S5      R                  5       5        U R                  SUR	                  S5      R                  5       5        g	)
zU
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   rd   re   r+   childrf   rg   s     r4   
test_childTestURL.test_childW  s     --	*<MM&!))+	
 	?MM'"**,	
 	EMM-(002	
 	HMM.)113	
r7   c                     [         R                  " S5      nU R                  UR                  SSS5      R	                  5       S5        g)zO
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   rd   r+   r   rf   r/   ru   s     r4   test_multiChildTestURL.test_multiChildo  s=     mm45IIc3$,,.0N	
r7   c                     [        SS9R                  S5      nU R                  UR                  5        U R	                  SUR                  5       5        g)zW
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   r   r$   rootedr+   rf   )r/   childURLs     r4   test_childInitRootTestURL.test_childInitRootz  sC     M*005(/1A1A1CDr7   c                 V    [        SS9nU R                  UR                  5       U5        g)zD
L{URL.child} without any new segments returns the original L{URL}.
r   r   N)r   r+   r   r   s     r4   test_emptyChildTestURL.test_emptyChild  s$    
 }%c*r7   c                 $   [         R                  " [        5      nU R                  SUR	                  S5      R                  5       5        Sn[         R                  " U5      nU R                  SUR	                  S5      R                  5       5        g)zg
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   rd   re   r+   siblingrf   )r/   rh   url_texts      r4   test_siblingTestURL.test_sibling  ss     --	*>OOH%--/	

 ?--)9OOH%--/	
r7   c                    [         R                  " [        5      nU R                  SUR	                  S5      R                  5       5        U R                  SUR	                  S5      R                  5       5        U R                  SUR	                  S5      R                  5       5        U R                  SUR	                  S5      R                  5       5        U R                  S	UR	                  S
5      R                  5       ;  5        [         R                  " S5      nU R                  SUR	                  S5      R                  5       5        [         R                  " S5      nU R                  UR	                  S5      R                  5       S5        [         R                  " S5      nSnU R                  UR	                  S5      R                  5       U5        U R                  UR	                  5       R                  5       U5        [         R                  " S5      n[         R                  " S5      nUR	                  U5      nU R                  UR                  5       S5        g)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=defr[   zhttp://localhost/foo/barN)r   rd   re   r+   r   rf   r$   fromText)r/   rh   r0   resu2u3s         r4   
test_clickTestURL.test_click  s    --	*8MM"%%'	

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

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

 MM@A),,.4 	**,c2 LL89]]5!WWR['ABr7   c                     [         R                  " [        5      n[         H4  u  p#U R	                  UR                  U5      R                  5       U5        M6     g)zA
L{URL.click} should correctly resolve the examples in RFC 3986.
N)r   rd   relativeLinkBaseForRFC3986relativeLinkTestsForRFC3986r+   r   rf   )r/   baserefr=   s       r4   test_clickRFC3986TestURL.test_clickRFC3986  s@    
 }}78:OSTZZ_446A  ;r7   c                     [         R                  " [        5      nU R                  [        UR
                  S5        U R                  [        UR
                  S5        g)z=
L{URL.click} should not accept schemes with relative paths.
zg:hzhttp:hN)r   rd   r   assertRaisesNotImplementedErrorr   )r/   r   s     r4   test_clickSchemeRelPathTestURL.test_clickSchemeRelPath  sA    
 }}78-tzz5A-tzz8Dr7   c           
      4   [         R                  " S5      nU R                  UR                  UR                  UR
                  UR                  UR                  UR                  UR                  5      U5        U R                  UR                  5       U5        g)zN
Verify that L{URL.replace} doesn't change any of the arguments it
is passed.
zhttps://x:1/y?z=1#AN)
r   rd   r+   replacer&   r)   r*   r-   r.   r9   rg   s     r4   test_cloneUnchangedTestURL.test_cloneUnchanged  sw     -- 56OO   
	
 	*G4r7   c                 ,   / SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ SQ/ S	Q/ S
Q/ SQ/ SQ/ SQ/nU He  u  p#n[         R                  " U5      R                  U5      R                  5       nU R	                  UUSR                  U[        U5      UUS95        Mg     g)zL
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   rd   r   rf   r+   formatr(   )r/   testsr   r   r=   r<   s         r4   test_clickCollapseTestURL.test_clickCollapse  s     <<DCKJHI
 IK
 L+
. ',"E(]]5)//6>>@FCJJu+!%	 K 	 ',r7   c                 h   U R                  S[        R                  " S5      R                  SS5      R	                  5       5        U R                  S[        SS9R                  SS5      R	                  5       5        [        R                  " [
        5      nU R                  SUR                  S	5      R	                  5       5        U R                  S
UR                  S	S5      R	                  5       5        U R                  SUR                  S	S5      R                  S5      R	                  5       5        U R                  SUR                  S5      R                  S	S5      R	                  5       5        U R                  SUR                  S	S5      R                  SS5      R	                  5       5        g)z#
L{URL.add} adds query parameters.
z'http://www.foo.com/a/nice/path/?foo=barzhttp://www.foo.com/a/nice/path/rZ   r[   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   rd   addrf   re   rg   s     r4   test_queryAddTestURL.test_queryAdd-  sg   
 	5MM;<SWY		
 	)]#''u5==?	
 --	*=KK'')	
 	AKK&..0	
 	FKK&**62::<	

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

 	HKK&**5$7??A	
r7   c                    [         R                  " [        5      nU R                  SUR	                  SS5      R                  5       5        U R                  SUR	                  S5      R	                  SS5      R                  5       5        U R                  SUR                  SS5      R	                  SS5      R                  5       5        g)	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   rd   re   r+   setrf   r   rg   s     r4   test_querySetTestURL.test_querySetT  s    
 --	*8KKt$,,.	

 	>KK""5*5==?	
 	8KKu%))%6>>@	
r7   c                    [         R                  " S5      nU R                  UR                  S5      [         R                  " S5      5        U R                  UR                  SSS9[         R                  " S5      5        U R                  UR                  SSS9[         R                  " S5      5        U R                  UR                  SSS	S
9[         R                  " S5      5        g)z7
L{URL.remove} removes instances of a query parameter.
z*https://example.com/a/b/?foo=1&bar=2&foo=3rZ   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   rd   r+   remover   s     r4   test_queryRemoveTestURL.test_queryRemovej  s    
 mmHIJJus}}-MN	
 	JJEJ-MM@A	

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

 	JJEAJ6MMFG	
r7   c                 H   [         R                  " S5      nU R                  UR                  S5      S/5        U R                  UR	                  5       S5        [         R                  " S5      nU R                  UR
                  S5        U R                  UR	                  5       S5        [         R                  " S5      nUR                  5       nU R                  UR                  S5      S/5        U R                  UR                  5       R                  S5      S/5        g	)
zh
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))rZ   r   )r[   yz7https://example.com/?argument=3&argument=4&operator=%3Doperator=N)r   rd   r+   getrf   r-   rt   to_uri)r/   r0   rv   s      r4   test_parseEqualSignInParamValue'TestURL.test_parseEqualSignInParamValue  s     MM45rWI.&@AMM=>"BC&IJMME
 hhj,se4))*5u=r7   c                 T    U R                  [        5       R                  5       S5        g)z7
An empty L{URL} should serialize as the empty string.
r   N)r+   r   rf   r`   s    r4   
test_emptyTestURL.test_empty  s    
 	"-r7   c                 X    [        S/S9nU R                  UR                  5       S5        g)z@
An L{URL} with query text should serialize as just query text.
helloworldr-   z?hello=worldN)r   r+   rf   rR   s     r4   test_justQueryTextTestURL.test_justQueryText  s(    
 )*+n5r7   c                 R    [         R                  " S5      nU R                  X5        g)z"
L{URL} compares equal to itself.
r   Nr   rd   r+   rR   s     r4   test_identicalEqualTestURL.test_identicalEqual  s!    
 MM-.r7   c                 ~    [         R                  " S5      n[         R                  " S5      nU R                  X5        g)z7
URLs with equivalent components should compare equal.
%http://u@localhost:8080/p/a/t/h?q=p#fNr   r/   u1r   s      r4   test_similarEqualTestURL.test_similarEqual  s0    
 ]]BC]]BC r7   c                     [         R                  " S5      n[         R                  " S5      nU R                  X:H  U< SU< 35        U R                  X5        g)zd
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   rd   assertFalser}   r   s      r4   test_differentNotEqualTestURL.test_differentNotEqual  sG     ]]/0]]/0R#89B#r7   c                     [         R                  " S5      nU R                  US:H  S5        U R                  U[        5       :H  S5        U R	                  US5        U R	                  U[        5       5        g)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   rd   r   objectr}   rR   s     r4   test_otherTypesNotEqualTestURL.test_otherTypesNotEqual  sa    
 MM-.b"@Afh(GHAr"Avx(r7   c                 ^    [         R                  " S5      nU R                  X:g  SU-  5        g)z:
Identical L{URL}s are not unequal (C{!=}) to each other.
r   z%r == itselfNr   rd   r   rR   s     r4   test_identicalNotUnequal TestURL.test_identicalNotUnequal  s*    
 MMAB!!34r7   c                     [         R                  " S5      n[         R                  " S5      nU R                  X:g  U< SU< 35        g)zE
Structurally similar L{URL}s are not unequal (C{!=}) to each other.
r    == Nr  r   s      r4   test_similarNotUnequalTestURL.test_similarNotUnequal  s9    
 ]]BC]]BCR#89r7   c                     [         R                  " S5      n[         R                  " S5      nU R                  X:g  U< SU< 35        g)zC
Structurally different L{URL}s are unequal (C{!=}) to each other.
r   r   r  N)r   rd   r$   r   s      r4   test_differentUnequalTestURL.test_differentUnequal  s7    
 ]]/0]]/0B"78r7   c                     [         R                  " S5      nU R                  US:g  S5        U R                  U[        5       :g  S5        g)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   rd   r$   r   rR   s     r4   test_otherTypesUnequalTestURL.test_otherTypesUnequal  s;    
 MM-.R!ABVX'KLr7   c                 `   Sn[         R                  " U5      nUR                  5       nU R                  UR                  S5        U R                  UR
                  S   S5        U R                  UR                  5       U5        SnUR                  5       nU R                  XTU< SU< 35        g)zs
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   rd   asURIr+   r)   r*   rf   )r/   unicodeyrv   uriexpectedURI	actualURIs         r4   
test_asURITestURL.test_asURI  s    B 	 mmH%iik#LMHHQKM	
 	1FKKM	)[$I	
r7   c                 `   Sn[         R                  " U5      nUR                  5       nU R                  UR                  S5        U R                  UR
                  S   S5        U R                  UR                  5       U5        SnUR                  5       nU R                  XTU< SU< 35        g)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   rd   asIRIr+   r)   r*   rf   )r/   asciiishr  rv   expectedIRI	actualIRIs         r4   
test_asIRITestURL.test_asIRI  s     DmmH%iik=1!h/13 	 KKM	)[$I	
r7   c                     Sn[         R                  " U5      nUR                  5       nSnUR                  5       nU R	                  XTU< SU< 35        g)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   rd   r  rf   r+   )r/   urlWithBinaryr  rv   r  r  s         r4   test_badUTF8AsIRITestURL.test_badUTF8AsIRI#  sQ     ;mmM*iik2 	
 KKM	)[$I	
r7   c                     Sn[         R                  " U5      nUR                  5       nU R                  UR	                  5       U5        g)zD
A L{URL} composed of non-ASCII text will result in non-ASCII text.
r  N)r   rd   r  r+   rf   )r/   r  rv   alsoIRIs       r4   test_alreadyIRIAsIRITestURL.test_alreadyIRIAsIRI6  s?    B 	 mmH%))+*H5r7   c                     Sn[         R                  " U5      nUR                  5       R                  5       nU R	                  X15        g)z8
A L{URL} composed of encoded text will remain encoded.
r  N)r   rd   r  rf   r+   )r/   r  r  r  s       r4   test_alreadyURIAsURITestURL.test_alreadyURIAsURIF  s:    
 GmmK(IIK'')	0r7   c                    [         R                  " S5      nU R                  UR                  S5      S5        U R                  UR                  S5      S5        U R                  UR                  S5        U R                  UR
                  S5        U R                  UR                  5       S5        U R                  UR                  SS	9R                  5       S
5        g)zc
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r:   z/http://someuser@example.com/some-segment@ignoreN)r   rd   r+   	authorityr:   userrf   r   r   s     r4   test_userinfoTestURL.test_userinfoP  s     mmJ
 	MM$!D	
 	u-/FG'>?:.KKMM	
 	KKK,446=	
r7   c                     [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        g)z:
L{URL.from_text} parses custom port numbers as integers.
zhttp://www.example.com:8080/i  N)r   rd   r+   r9   rf   )r/   portURLs     r4   test_portTextTestURL.test_portTextg  s?    
 -- >?t,*,JKr7   c                 l    U R                  [        R                  " S5      R                  5       S5        g)z
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   rd   rf   r`   s    r4   test_mailtoTestURL.test_mailtop  s+     	MM34<<>%	
r7   c                    [         R                  " S5      nU R                  UR                  S5        U R                  UR                  S5        U R                  UR
                  S5        U R                  UR                  5       S5        g)zR
An HTTP URL without a hostname, but with a path, should also round-trip
cleanly.
zhttp:relative-pathr   )zrelative-pathFN)r   rd   r+   r)   r*   uses_netlocrf   )r/   without_hosts     r4   test_httpWithoutHostTestURL.test_httpWithoutHost}  sp     }}%9:**B/**,>?1159--/1EFr7   c                     Sn[        S/S9nU R                  UR                  U5        [        SS0S9nU R                  UR                  U5        g)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@  rA  N)r   r+   r-   )r/   r=   ru   s      r4   test_queryIterableTestURL.test_queryIterable  sN     (*+,H-&)*H-r7   c                 R    [        SS/S9nU R                  UR                  S5        g)zZ
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     r4   test_pathIterableTestURL.test_pathIterable  s(     )*#56r7   c           	      B  ^ ^^  " S S[         5      m[        [        L a  SOSnU 4S jmU4UUU 4S jjnU" S5        U" S5        U" S	5        U" S
S5        U" S5        U" SS5        T R                  [        5       n[        [        [        T" 5       5      /S9  SSS5        T" WUS5        T R                  [        5       n[        S[        [        T" 5       5      4/S9  SSS5        T" X1S-   S5        T R                  [        5       n[        [        [        T" 5       5      S4/S9  SSS5        T" X1S5        T R                  [        5         [        [        [        [        [        4   T" 5       5      /S9  SSS5        T R                  [        5         [        [        [        [        [        4   S5      /S9  SSS5        T R                  [        5         [        [        [        [        [        4   S5      /S9  SSS5        [
        R                  " S5      nT R                  [        5       nUR                  [        [        T" 5       5      5        SSS5        T" X1S5        T R                  [        5       nUR                  [        [        T" 5       5      5        SSS5        T" X1S5        T R                  [        5       nUR                  [        [        T" 5       5      5        SSS5        T" X1S5        g! , (       d  f       GNn= f! , (       d  f       GN9= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNa= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       N= f)al  
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                        \ rS rSrS rS rSrg)1TestURL.test_invalidArguments.<locals>.Unexpectedi  c                     g)Nwrong r`   s    r4   __str__9TestURL.test_invalidArguments.<locals>.Unexpected.__str__  s    r7   c                     g)N<unexpected>rM  r`   s    r4   __repr__:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__  s    %r7   rM  N)__name__
__module____qualname____firstlineno__rN  rR  __static_attributes__rM  r7   r4   
UnexpectedrJ    s    &r7   rY  r'   strc                 p   > TR                  [        U R                  5      SR                  XS5      5        g )Nzexpected {0} for {1}, got {2}rQ  )r+   rZ  	exceptionr   )raisedexpectationr   r/   s      r4   assertRaised3TestURL.test_invalidArguments.<locals>.assertRaised  s2    F$$%/66~r7   c                    > TR                  [        5       n[        S0 U T" 5       0D6  S S S 5        T" WX5        g ! , (       d  f       N= f)NrM  )r   	TypeErrorr   )paramr^  r]  rY  r_  r/   s      r4   rD   ,TestURL.test_invalidArguments.<locals>.check  s?    ""9-,ujl+, . 4 .-s	   <
A
r&   r)   r.   r   boolr:   r9   zint or NoneTyperE  Nzpath segmentr   r   z or NoneTypezquery parameter valuer   zquery parameter name)rM   r3   vv)rM   zhttps://valid.example.com/zrelative URL)r   bytesrZ  r   rb  r   r	   r   r   
ValueErrorrd   r   r   r   )r/   defaultExpectationrD   r]  ru   rY  r_  s   `    @@r4   test_invalidArgumentsTestURL.test_invalidArguments  s   	& 	& +03,YE	 &8 	5 	5 	hfjhjf'(y)Vd4./0 * 	V/@y)VT:< 89:; * 	79P	
 y)VT:<0':;< * 	V1GH y)tE$*-z|<=> * z*tE$*-/?@AB + z*tE$*-v678 + mm89y)VIId4./ *V@y)VKKT:<01 *V@y)VIId4./ *V@K *)
 *) *) *) +* +* *) *) *)sl   <L L
 L%+L7&M	&M4%M-?%M?
%N
L
L"%
L47
M	
M
M*-
M<?
N
Nc                     U R                  [        5       n[        SS9  SSS5        U R                  [	        WR
                  5      SR                  [        S5      5      5        g! , (       d  f       NL= f)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.
rZ   rE  Nz,expected iterable of text for path, not: {0})r   rb  r   r+   rZ  r\  r   r(   )r/   r]  s     r4   !test_technicallyTextIsIterableBut)TestURL.test_technicallyTextIsIterableBut  sW     y)VUO *  !:AA$u+N	
 *)s   
A&&
A4c                    [        SS9nU R                  UR                  S5        U R                  UR                  5       S5        U R                  [         R                  " S5      R                  S5        U R                  [         R                  " S5      R                  S5        U R                  [         R                  " S5      R                  S5        [        SSS9nU R                  UR                  S5        U R                  UR                  5       S5        [        S	S9nU R                  UR                  S5        U R                  UR                  5       S
5        [        SS9nU R                  UR                  S5        U R                  UR                  5       S5        [        SS9nU R                  UR                  S 5        U R                  UR                  5       S5        [         R                  " S5      nU R                  UR                  S5        [         R                  " S5      nU R                  UR                  S5        g )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:  rf   rd   r   s     r4   test_netlocTestURL.test_netloc  s   !$/
3x0<<eDy1==uEz2>>Ee4%01%$/7"%0	2$//mm,-$/mmN+%0r7   c                     Sn[         R                  " U5      nUR                  S:X  d   eUR                  S:X  d   e[        UR
                     UR                  :w  d   eg )Nz5https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:80/z'2001:0db8:85a3:0000:0000:8a2e:0370:7334rC   )r   rd   r)   r9   r   r&   )r/   tru   s      r4   test_ipv6_with_portTestURL.test_ipv6_with_port$  sS    CmmAxxDDDDxx2~~szz*chh666r7   c                 h   Sn[         R                  " U5      nUR                  S:X  d   eUR                  S:X  d   eUR                  S:X  d   eUR
                  S:X  d   eUR                  S:X  d   eSn[         R                  " U5      nUR                  S:X  d   eUR                  S:X  d   eUR                  S:X  d   eUR
                  S:X  d   eS	n[         R                  " U5      nUR                  S:X  d   eUR                  S:X  d   eUR                  S
:X  d   eUR
                  S:X  d   eg )Nz3https://user:pass@example.com/path/to/here?k=v#nicerp  	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   rd   r&   r:   r)   r*   r.   r/   textru   s      r4   
test_basicTestURL.test_basic,  s(   DmmD!zzW$$$||{***xx=(((xx1111||v%%%BmmD!zzW$$$||{***xx;&&&xx1111>mmD!zzW$$$||{***xx5   xx1111r7   c                 N    U R                  [        [        R                  S5        g )Nz#

r   r   r   rd   r`   s    r4   test_invalid_urlTestURL.test_invalid_urlD  s    -@r7   c                 N    U R                  [        [        R                  S5        g )Nzhttp://abc:

/#r  r`   s    r4   test_invalid_authority_url"TestURL.test_invalid_authority_urlH  s    -8KLr7   c                     / SQnU Hd  nSU-   S-   nU R                  [        R                  [        [        R                  U5        U R                  [
        [        R                  U5        Mf     g )N)z2001::0234:C1ab::A0:aabc:003Fz2001::1::3F:z::::z::256.0.0.1zhttp://[])r   socketerrorr   AF_INET6r   r   rd   )r/   invalid_ipv6_ipsipr   s       r4   test_invalid_ipv6TestURL.test_invalid_ipv6L  sV    
 #B!B,HfllIvKmS]]HE #r7   c                     U R                  [        [        R                  S5        U R                  [        [        R                  S5        g )Nzftp://portmouth:smashz+http://reader.googlewebsite.com:neverforget)r   r   r   rd   rh  r`   s    r4   test_invalid_portTestURL.test_invalid_portZ  s4    -8OPMM9	
r7   c                    [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        U R                  UR                  5       R	                  5       S5        [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        U R                  UR                  5       R	                  5       S5        g )Nu   http://bücher.chu
   bücher.chzhttp://xn--bcher-kva.chr   zxn--bcher-kva.chu   https://bücher.ch)r   rd   r+   r)   rf   r   rt   r   s      r4   	test_idnaTestURL.test_idnac  s    ]]./,/':;,,.0IJ]]56"45'AB,,.0DEr7   c                     [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        [         R                  " S	5      nU R                  UR                  S
5        U R                  UR	                  5       S	5        [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        [        SSSS9nU R                  UR	                  5       S5        [        S
SSSS9nU R                  UR	                  5       S5        [         R                  " S5      nUR                  SS9nU R                  UR	                  5       S5        Sn[         R                  " U5      nUR                  SS9nU R                  UR	                  5       S5        UR                  SS9nU R                  UR	                  5       U5        g )Nzmailto:mahmoud@hatnote.comrr  zhttp://hatnote.comrB   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+mailtors  )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/heckrq  zmailto:/path/to/heckzunregisteredscheme:///a/b/cF)r:  zunregisteredscheme:/a/b/c)r   rd   r+   r&   rf   r   )r/   ru   url2r   no_netloc_url
netloc_urls         r4   test_netloc_slashesTestURL.test_netloc_slasheso  s_    mm89X.(DEmm01V,(<= mm-.[1(9:mm12]3(=> mmCDY/(OPmmEF]3KKMD	
 _TB5 $	
 	(;< mm23{{({+)?@0mmH%6..02MN[[T[2
++-x8r7   c                     [        S/S9nU R                  UR                  5       S5        UR                  SS9nU R                  UR                  5       S5        U R	                  X5        g)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   rE  T)r   z/helloN)r   r+   rf   r   r}   )r/   abs      r4   test_rooted_to_relativeTestURL.test_rooted_to_relative  sZ     gYg.IITI"h/A!r7   c                    [        SS/SS9nU R                  UR                  S5        [        S/SS9nU R                  UR                  S5        U R                  X5        [        SS/SS9n[        SS/S9nU R                  X45        U R                  UR                  S5        U R                  UR                  S5        g	)
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   rZ   F)r*   r   Tr[   )r)   r*   r   )r)   r*   N)r   r+   r   )r/   relative_path_rootedrelative_flag_rootedattempt_unrooted_absolutenormal_absolutes        r4   test_autorootedTestURL.test_autorooted  s      #UEB-44d;"=-44d;-D$'U%$O!5w72D//62994@r7   c                    [        SSSS9n[        SSS9n[        SSSS9nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        [         R                  " S5      nU R                  [	        U5      [	        U5      5        U R                  [	        U5      [	        U5      5        U R                  UR                  5       UR                  5       5        U R                  X5        U R                  X5        U R                  X5        U R                  X$5        U R                  X45        g)	al  
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&   r9   r   )r&   r9   Tzudp://:4900N)r   r+   r   rd   rZ  asText)r/   directly_constructeddirectly_constructed_implictdirectly_constructed_rootedparseds        r4   !test_rooted_with_port_but_no_host)TestURL.test_rooted_with_port_but_no_host  s!     #%d5I'*%d'C$&)T$&O#-44d;5<<dC4;;TB}-12CK@9:CKH-446H-6-L-K5>4=r7   c                     U R                  [        5         [        [        5        S S S 5        U R                  [        5         [        S5        S S S 5        g ! , (       d  f       N8= f! , (       d  f       g = f)NHTTP_____more_like_imHoTTeP)r   rh  r   re   r`   s    r4   test_wrong_constructorTestURL.test_wrong_constructor  sO    z*	N + z*-. +* +* +*s   AA)
A&)
A7c                 ,   [         R                  " S5      nUR                  S:X  d   eUR                  SS9nUR	                  5       nUR                  SS9S:X  d   eUR                  SS9S	:X  d   eUR                  5       R                  SS9S
:X  d   eg )Nzhttp://user:pass@example.comr{  zus%20her:passr-  Trl   zhttp://us her:pass@example.comFzhttp://us her:@example.comz http://us%20her:pass@example.com)r   rd   r:   r   rt   rf   r   r/   ru   rv   s      r4   test_encoded_userinfoTestURL.test_encoded_userinfo  s    mm:;||{***kk?k3jjlKKdK+/OO	
O{{{/3OOOOJJL  t 412	
2r7   c                 ~   0 n[         R                  " S5      n[        U5      [        U5      :X  d   eSX'   [         R                  " S5      nUR                  SS5      nSX'   [	        U5      S:X  d   e[        UR                  5       5      S/:X  d   e[        [        5       5      [        [        5       5      :X  d   eg )Nz.http://blog.hatnote.com/ask?utm_source=geocityr
   zhttp://blog.hatnote.com/ask
utm_sourcegeocityr   )r   rd   hashr   lenlistvalues)r/   url_mapurl1r  s       r4   	test_hashTestURL.test_hash   s    }}MNDzT$Z'''}}:;xxi07|q   GNN$%!,,,CE{d35k)))r7   c                     [        5       n[        U5      n[        U5      S:  d   eSU;  d   eSU;  d   eSU;  d   eSU;  d   eg )N   r   r  r  r  )r   dirr  )r/   ru   r   s      r4   test_dirTestURL.test_dir  sZ    e#h3x"}}$$$s"""c!!!c!!!r7   c                     [         R                  " S5      nUR                  5       S:X  d   eUR                  5       R                  5       S:X  d   eg )Nu"   http://example.com/a%20té%C3%A9stz&http://example.com/a%20t%C3%A9%C3%A9st)r   r   r  r  r   s     r4   test_twisted_compatTestURL.test_twisted_compat  sD    ll?@zz|CCCCyy{!!#'OOOOr7   c                     [         R                  " S5      nUR                  SS5      nUR                  SS5      nUR	                  5       S:X  d   eg )Nzhttp://example.com/?a=b&cr  r   z!http://example.com/?a=b&x=x&c&x=y)r   rd   r   r   rf   r   s     r4   test_set_orderingTestURL.test_set_ordering%  sH     mm78ggc3ggc3{{} CCCCr7   c                    [         R                  " S5      n[         R                  " UR                  5       5      nX:X  d   e[         R                  " UR                  5       R                  5       5      nX:X  d   eX#:X  d   e[         R                  " S5      nUR                  5       nUR                  5       S:X  d   e[         R                  " UR                  5       5      R	                  5       nXV:X  d   eg)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   rd   rf   rt   r   )r/   r   r   r   u4u5u6s          r4   test_schemeless_pathTestURL.test_schemeless_path0  s     ]]@A]]2::<(xx]]299;..01xxxx ]]NOYY[zz|HHHH]]2::<(//1xxr7   c                 p    [         R                  " S5      nUR                  5       nUR                  5         g)z4See issue #7, affecting only narrow builds (2.6-3.3)zhttps://xn--vi8hiv.wsN)r   rd   rt   rf   r  s      r4   test_emoji_domainTestURL.test_emoji_domainC  s'     mm34jjlr7   c                     U R                  [        [        SSS9  U R                  [        [        SS9  U R                  [        [        SS9  U R                  [        [        SS9  g	)
zPer issue #6 and #8rB   za/c)r&   r)   )?rE  )#)&ro   r   N)r   rh  r   r`   s    r4   test_delim_in_paramTestURL.test_delim_in_paramK  sZ     	*c&uE*c7*c7*c-Ar7   c                    [         R                  " S5      n[         R                  " S5      nX:X  d   e[         R                  " S5      n[         R                  " S5      nX:X  d   e[         R                  " S5      n[         R                  " S5      nX:X  d   e[         R                  " S5      n[         R                  " S5      nX:X  d   eg )Nzhttp://example.com/zhttp://example.com)r   rd   r   s      r4   test_empty_paths_eqTestURL.test_empty_paths_eqS  s    ]]01]]/0xx]]/0]]/0xx]]/0]]01xx]]01]]01xxr7   c                     [         R                  " S5      R                  S:X  d   eU R                  [        [         R                  S5        U R                  [        [         R                  [        5       5        g )Nz#okoks   bytes://x.y.z)r   rd   r.   r   rb  r   r`   s    r4   test_from_text_typeTestURL.test_from_text_typei  sN    }}U#,,444)S]]4DE)S]]FH=r7   c                 
   U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        U R                  [        [        R                  S5        g )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`   s    r4   test_from_text_bad_authority$TestURL.test_from_text_bad_authorityo  s     	-G-G-8HI-8HI 	-8KL-8MN-8NOr7   c                 .   [         R                  " S5      nUR                  S5      / :X  d   eUR                  S5      S/:X  d   e[        UR                  5      S:X  d   eUR                  5       nUR                  S:X  d   eUR                  S:X  d   eUR                  S:X  d   eUR                  S5      S	/:X  d   eUR                  S
:X  d   eUR                  5       S:X  d   eUR                  SSSSSS9nX1:X  d   e[         R                  " S5      nUR                  5       nUR                  5       S:X  d   e[         R                  " S5      nUR                  5       nUR                  5       S:X  d   e[        SS9R                  SS9R                  5       S:X  d   e[        SS9R                  5       R                  5       S:X  d   e[        SSS/S/SSS9nUR                  SS9S :X  d   eUR                  5       R                  SS9S!:X  d   eg )"Nz0HTTP://Example.com/A%61/./../A%61?B%62=C%63#D%64BbzB%62zC%63   rB   r|  )AaCcDdzhttp://example.com/Aa?Bb=Cc#DdFr^   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%stsrE  )percentsz/%te%stsz/%25te%25stsftpz%%%z%a%b)%z%%r  z%:%)r&   r*   r-   r.   r:   Trl   zftp://%:%@/%%%/%a%b?%=%%#%z0ftp://%25:%25@/%25%25%25/%25a%25b?%25=%25%25#%25)
r   rd   r   r  r*   	normalizer&   r)   r.   rf   )	r/   ru   norm_urlnoop_norm_urlslashless_urlslashful_urldelimited_urlnorm_delimited_urlpercenty_urls	            r4   test_normalizeTestURL.test_normalize  sH   mmNOwwt}"""wwv6(***388}!!! ==?&(((}}---}}'''||D!dV+++  D(((!%EEEE u5 & 
 ### &9:$..0##%)==== &CD*446!))+/LLLL _%///?GGI	
 (224<<>.PPP-
   t 4+,	
, ""$,,4,@AB	
Br7   c                    Sn[         R                  " U5      n[        U5      U:X  d   e[        U5      S:X  d   e[        (       aA  [        [        U5      [        5      (       d   e[        [        U5      [        5      (       d   eg [        [        U5      [        5      (       d   e[        [        U5      [        5      (       d   eg )Nu&   http://example.com/á/y%20a%20y/?b=%25s*   http://example.com/%C3%A1/y%20a%20y/?b=%25)r   rd   r'   rg  PY2r%   rZ  r  s      r4   test_strTestURL.test_str  s     8mmD!s|t###SzJJJJ3c#h....gclG4444c#h0000eCj%0000r7   c                 @   [         R                  " S5      nUR                  5       R                  S:X  d   eUR	                  5       R                  S:X  d   e[         R                  " S5      nUR                  5       R                  S:X  d   eUR	                  5       R                  S:X  d   eUR	                  5       R                  5       R                  S:X  d   eSn[         R                  " U5      R	                  5       R                  5       R                  S:X  d   eg )	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   rd   rt   r)   r   get_decoded_url)r/   ru   r  s      r4   test_idna_cornersTestURL.test_idna_corners  s    mm./zz|  J...zz|  $4444mmFGzz|  $BBBBzz|  $DDDDzz|++-226TTTT#MM$&&(88:??=P	
Pr7   rM  N)r   )QrT  rU  rV  rW  __doc__r5   r>   rF   rS   rW   ra   ri   rq   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r"  r&  r)  r0  r4  r7  r<  rB  rF  rj  rm  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
  rX  rM  r7   r4   r!   r!      s   =6 1+f+
&	

(7+
 


0	
E+
&<C|BE5((T%
N
,
2>*.6!	$	)5:9M
4
0
&6 1
.L

G.7SAj
 1D720AMF

F9v
"A.>6/
*$
"PD&B,>P 7
r1 
r7   r!   )
__future__r   sysr  typingr   r   r   r   r   r	   commonr   r   r   r   _urlr   r   version_infor  r,   r'   re   r   r   rn   r!   rM  r7   r4   <module>r     so    ( 
  = = % ! - 
qQ
r( 9	 2 1 hAHF
 F
r7   