+
    Dfjmu                    :   R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^RIH	t	 Rt
Rt. RNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR NR!NR"NR#NR$NR%NR&NR'NR(NR)NR*NR+NR,NR-NR.NR/NR0NR1NR2NR3NR4NR5NR6NR7NtR t ! R	 R
]4      t ! R R]4      t ! R R]4      tR# )8z"
Tests for L{twisted.python.url}.
)annotations)Iterable)Protocol)SynchronousTestCaseURL*http://www.foo.com/a/nice/path/?zot=23&zuthttp://a/b/c/d;p?qc                2    R P                  R V  4       4      # ) c              3  F   "   T F  pR \        V4      ,          x  K  	  R# 5i)z%%%02XN)ord).0cs   & >/usr/lib/python3/dist-packages/twisted/python/test/test_url.py	<genexpr><lambda>.<locals>.<genexpr>L   s     =1a3q6 1 11s   !)join)ss   &r   <lambda>r   L   s    =1==    c                  ,    ] tR t^Ot]R R l4       tRtR# )_HasExceptionc                   V ^8  d   QhRR/# )   returnBaseException )formats   "r   __annotate___HasException.__annotate__Q   s      = r   c                	    R # )Nr   selfs   &r   	exception_HasException.exceptionP   s    r   r   N)__name__
__module____qualname____firstlineno__propertyr$   __static_attributes__r   r   r   r   r   O   s     r   r   c                  .   ] tR t^UtRtR R ltR\R R lltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR  R! ltR" R# ltR$ R% ltR& R' ltR( R) ltR* R+ ltR, R- ltR. R/ ltR0 R1 ltR2 R3 ltR4 R5 ltR6 R7 ltR8 R9 lt R: R; lt!R< R= lt"R> R? lt#R@ RA lt$RB RC lt%RD RE lt&RF RG lt'RH RI lt(RJ RK lt)RL RM lt*RN RO lt+RP RQ lt,RR RS lt-RT RU lt.RV RW lt/RX RY lt0RZt1R[# )]TestURLz
Tests for L{URL}.
c                    V ^8  d   QhRRRR/# r   ur   r   Noner   )r   s   "r   r   TestURL.__annotate__Z   s     8 8 8 8r   c                <   V P                  VP                  \        \        V4      4       V P                  VP                  \        \        V4      4       VP
                   F#  pV P                  V\        \        V4      4       K%  	  VP                   FZ  w  r4V P                  V\        \        V4      4       T P                  VRJ ;'       g    \        V\        4      \        V4      4       K\  	  V P                  VP                  \        \        V4      4       R# )zT
The given L{URL}'s components should be L{unicode}.

@param u: The L{URL} to test.
N)
assertIsInstanceschemestrreprhostpathquery
assertTrue
isinstancefragment)r#   r0   segkvs   &&   r   assertUnicodedTestURL.assertUnicodedZ   s     	ahhT!W5affc47366C!!#sDG4 GGDA!!!S$q'2OOAI;;As);T!WE  	ajj#tAw7r   c               <    V ^8  d   QhRRRRRRRRRR	R
RRRRRRR/	# )r   r0   r   r5   r6   r8   r9   zIterable[str]r:   z Iterable[tuple[str, str | None]]r=   portz
int | Noneuserinfor   r1   r   )r   s   "r   r   r2   i   sd      +  + +  + 	 +
  + 0 +  +  +  + 
 +r   c	                   VP                   VP                  VP                  VP                  VP                  VP
                  VP                  3p	W#\        V4      \        V4      WgVP                  3p
V P                  W4       R# )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)	r5   r8   r9   r:   r=   rD   rE   tupleassertEqual)r#   r0   r5   r8   r9   r:   r=   rD   rE   actualexpecteds   &&&&&&&&&  r   	assertURLTestURL.assertURLi   s^    < ((AFFAFFAGGQZZT%+uU|XQZZX*r   c                   V ^8  d   QhRR/# r   r   r1   r   )r   s   "r   r   r2      s     + +4 +r   c           	        a  R V 3R llpV! \        RR4      4       V! \        RR. . 4      4       V! \        RR. . R4      4       R# )z0
L{URL} should have appropriate default values.
c                    V ^8  d   QhRRRR/# r/   r   )r   s   "r   r   /TestURL.test_initDefaults.<locals>.__annotate__   s     	> 	>S 	>T 	>r   c           
     Z   < SP                  V 4       SP                  V R R. . R^PR4       R# )httpr   N)rA   rK   )r0   r#   s   &r   check(TestURL.test_initDefaults.<locals>.check   s+    "NN1fb"b"b"=r   rS   r   Nr   )r#   rT   s   f r   test_initDefaultsTestURL.test_initDefaults   sE    
	> 	> 	c&"oc&"b"%&c&"b"b)*r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     
 
4 
r   c           	         \        RRR.R
R.R4      pV P                  V4       V P                  VRRR.R
R.RR4       V P                  \        RRR.R.R	4      RRR.R.R	^P4       R# )z-
L{URL} should accept L{unicode} parameters.
r   hpNfrS      à   éu   ⊥r?   r@   )r?   N)u   λu   πr   rA   rK   r#   r0   s   & r   	test_initTestURL.test_init   s     S3%*k!:C@Aq#sSEJ+Dc4P+?*@(KH!"	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     
 
$ 
r   c           	         \        RRR.RR.R4      pV P                  V4       V P                  VRRR.RR.RR4       R# )z>
L{URL} should accept (and not interpret) percent characters.
r   z%68z%70Nz%66)%6Bz%76)rf   Nr`   ra   s   & r   test_initPercentTestURL.test_initPercent   sM     UUGnm%DeLAsEE7^]$CUD	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     
 
4 
r   c                    V P                  \        \        RRR.R	R
.RR7      4      RP                  \        R4      4      4       R# )z
L{URL.__repr__} will display the canonical form of the URL, wrapped in
a L{URL.fromText} invocation, so that it is C{eval}-able but still easy
to read.
rS   foobarNfrob)r5   r8   r9   r:   r=   zURL.from_text({})zhttp://foo/bar?baz&k=v#frob)bazNr_   )rH   r7   r   r   r"   s   &r   	test_reprTestURL.test_repr   sN     	!(*5#  &&t,I'JK	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     3 3t 3r   c                    \         P                  ! \        4      pV P                  \        VP	                  4       4       R# )zJ
Round-tripping L{URL.fromText} with C{str} results in an equivalent
URL.
N)r   fromTexttheurlrH   asTextr#   urlpaths   & r   test_fromTextTestURL.test_fromText   s)    
 ,,v&!12r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     + + +r   c                    RpV F8  p\         P                  ! V4      P                  4       pV P                  W#4       K:  	  R# )z.
L{URL.asText} should invert L{URL.fromText}.
N)zhttp://localhosthttp://localhost/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))r   rs   ru   rH   )r#   teststestresults   &   r   test_roundtripTestURL.test_roundtrip   s:    
  D\\$'..0FT* r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     
 
t 
r   c                    \         P                  ! \        4      pV P                  V\         P                  ! \        4      4       V P	                  V\         P                  ! R4      4       R# )z
Two URLs decoded using L{URL.fromText} 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   rs   rt   rH   assertNotEqualrv   s   & r   test_equalityTestURL.test_equality   sK     ,,v&#,,v"67LLO	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     
 
t 
r   c                    V P                  \        RR7      \        4       4       V P                  \        P                  ! R4      \        P                  ! R4      4       R# )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)rH   r   rs   r"   s   &r   test_fragmentEqualityTestURL.test_fragmentEquality   sB    
 	b)351LL-.=P0Q	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2      s     
 
D 
r   c                   \         P                  ! \        4      pV P                  RVP	                  R4      P                  4       4       V P                  RVP	                  R4      P                  4       4       V P                  RVP	                  R4      P                  4       4       V P                  RVP	                  R4      P                  4       4       R	# )
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   rs   rt   rH   childru   rv   s   & r   
test_childTestURL.test_child   s    
 ,,v&<MM&!((*	
 	?MM'"))+	
 	EMM-(//1	
 	HMM.)002	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     
 
 
r   c                    V P                  \        P                  ! R4      P                  RRR4      P	                  4       R4       R# )zO
L{URL.child} receives multiple segments as C{*args} and appends each in
turn.
zhttp://example.com/a/br   dezhttp://example.com/a/b/c/d/eN)rH   r   rs   r   ru   r"   s   &r   test_multiChildTestURL.test_multiChild  s:    
 	LL1288c3GNNP*	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   !  s     D DD Dr   c                    \        RR7      P                  R4      pV P                  VP                  4       V P	                  RVP                  4       4       R# )zW
L{URL.child} of a L{URL} without a path produces a L{URL} with a single
path segment.
www.foo.comr8   r   zhttp://www.foo.com/cN)r   r   r;   rootedrH   ru   )r#   childURLs   & r   test_childInitRootTestURL.test_childInitRoot!  sA    
 M*005(/1BCr   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   *  s     
 
d 
r   c                &   \         P                  ! \        4      pV P                  RVP	                  R4      P                  4       4       Rp\         P                  ! V4      pV P                  RVP	                  R4      P                  4       4       R# )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   rs   rt   rH   siblingru   )r#   rw   theurl2s   &  r   test_siblingTestURL.test_sibling*  ss    
 ,,v&>OOH%,,.	

 >,,w'9OOH%,,.	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   <  s     &
 &
D &
r   c                $   \         P                  ! \        4      pV P                  RVP	                  R4      P                  4       4       V P                  RVP	                  R4      P                  4       4       V P                  RVP	                  R4      P                  4       4       V P                  RVP	                  R4      P                  4       4       V P                  R	VP	                  R
4      P                  4       4       \         P                  ! R4      pV P                  RVP	                  R4      P                  4       4       \         P                  ! R4      pV P                  VP	                  R4      P                  4       R4       R# )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.orgN)r   rs   rt   rH   r   ru   assertNotIn)r#   rw   r0   s   &  r   
test_clickTestURL.test_click<  s?   
 ,,v&8'--:K:R:R:T	
 	2GMM'4J4Q4Q4S	
 	3W]]85L5S5S5UV2GMM'4J4Q4Q4S	

 	&ABIIK	
 LL89/9J1K1R1R1T	
 LL78GG+,3357N	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   d  s     A A4 Ar   c                    \         P                  ! \        4      p\         F4  w  r#V P	                  VP                  V4      P                  4       V4       K6  	  R# )zA
L{URL.click} should correctly resolve the examples in RFC 3986.
N)r   rs   relativeLinkBaseForRFC3986relativeLinkTestsForRFC3986rH   r   ru   )r#   baserefrJ   s   &   r   test_clickRFC3986TestURL.test_clickRFC3986d  s@     ||678MCTZZ_335x@ 9r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   l  s     E E Er   c                    \         P                  ! \        4      pV P                  \        VP
                  R4       V P                  \        VP
                  R4       R# )z=
L{URL.click} should not accept schemes with relative paths.
zg:hzhttp:hN)r   rs   r   assertRaisesNotImplementedErrorr   )r#   r   s   & r   test_clickSchemeRelPathTestURL.test_clickSchemeRelPathl  sA     ||67-tzz5A-tzz8Dr   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   t  s     5 5T 5r   c           
     6   \         P                  ! R4      pV P                  VP                  VP                  VP
                  VP                  VP                  VP                  VP                  4      V4       V P                  VP                  4       V4       R# )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   rs   rH   replacer5   r8   r9   r:   r=   rD   rv   s   & r   test_cloneUnchangedTestURL.test_cloneUnchangedt  sw    
 ,,45OO   
	
 	*G4r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s      D r   c                4   . RO. RO. RO. RO. RO. R	O. R
O. RO. RO. RO. RO. RO. RO.pV Fh  w  r#p\         P                  ! V4      P                  V4      P                  4       pV P	                  VVRP                  V\        V4      VVR7      4       Kj  	  R# )zL
L{URL.click} collapses C{.} and C{..} according to RFC 3986 section
5.2.4.
z1{start}.click({click}) => {actual} not {expected})startr   rI   rJ   N)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//e)r   rs   r   ru   rH   r   r7   )r#   r}   r   r   rJ   rI   s   &     r   test_clickCollapseTestURL.test_clickCollapse  s     <<DCKJHIPHKUK
 ',"E(\\%(..u5<<>FCJJu+!%	 K 	 ',r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     "
 "
t "
r   c                p   V P                  R\        P                  ! R4      P                  RR4      P	                  4       4       V P                  R\        RR7      P                  RR4      P	                  4       4       \        P                  ! \
        4      pV P                  RVP                  R	4      P	                  4       4       V P                  R
VP                  R	R4      P	                  4       4       V P                  RVP                  R	R4      P                  R4      P	                  4       4       V P                  RVP                  R4      P                  R	R4      P	                  4       4       V P                  RVP                  R	R4      P                  RR4      P	                  4       4       R# )z#
L{URL.add} adds query parameters.
z'http://www.foo.com/a/nice/path/?foo=barzhttp://www.foo.com/a/nice/path/rk   rl   zhttp://www.foo.com/?foo=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)rH   r   rs   addru   rt   rv   s   & r   test_queryAddTestURL.test_queryAdd  sj    	5LL:;??uMTTV	
 	)]#''u5<<>	
 ,,v&=KK&&(	
 	AKK&--/	
 	FKK&**6299;	

 	FKK##FE299;	

 	HKK&**5$7>>@	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     
 
t 
r   c                   \         P                  ! \        4      pV P                  RVP	                  RR4      P                  4       4       V P                  RVP	                  R4      P	                  RR4      P                  4       4       V P                  RVP                  RR4      P	                  RR4      P                  4       4       R# )	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   rs   rt   rH   setru   r   rv   s   & r   test_querySetTestURL.test_querySet  s     ,,v&8KKt$++-	

 	>KK""5*5<<>	
 	8KKu%))%6==?	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     
 
$ 
r   c                    \         P                  ! R4      pV P                  VP                  R4      \         P                  ! R4      4       R# )z;
L{URL.remove} removes all instances of a query parameter.
z*https://example.com/a/b/?foo=1&bar=2&foo=3rk   zhttps://example.com/a/b/?bar=2N)r   rs   rH   remover#   urls   & r   test_queryRemoveTestURL.test_queryRemove  s9     llGHJJus||,LM	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     - -D -r   c                V    V P                  \        4       P                  4       R4       R# )z7
An empty L{URL} should serialize as the empty string.
r   N)rH   r   ru   r"   s   &r   
test_emptyTestURL.test_empty  s     	,r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     5 5D 5r   c                `    \        R.R7      pV P                  VP                  4       R4       R# )z@
An L{URL} with query text should serialize as just query text.
r:   z?hello=worldNhelloworld)r   rH   ru   ra   s   & r   test_justQueryTextTestURL.test_justQueryText  s(     )*+^4r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s      T r   c                T    \         P                  ! R4      pV P                  W4       R# )z"
L{URL} compares equal to itself.
r|   Nr   rs   rH   ra   s   & r   test_identicalEqualTestURL.test_identicalEqual  s!     LL,-r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     ! !4 !r   c                    \         P                  ! R4      p\         P                  ! R4      pV P                  W4       R# )z7
URLs with equivalent components should compare equal.
r|   Nr   r#   u1u2s   &  r   test_similarEqualTestURL.test_similarEqual  s0     \\-.\\-. r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     $ $ $r   c                    \         P                  ! R4      p\         P                  ! R4      pV P                  W8H  V: RV: 24       V P                  W4       R# )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   rs   assertFalser   r   s   &  r   test_differentNotEqualTestURL.test_differentNotEqual  sM    
 \\./\\./bV4v#67B#r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     ) ) )r   c                    \         P                  ! R4      pV P                  V^*8H  R4       V P                  V\        4       8H  R4       V P	                  V^*4       V P	                  V\        4       4       R# )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   rs   r   objectr   ra   s   & r   test_otherTypesNotEqualTestURL.test_otherTypesNotEqual  sa     LL,-b"@Afh(GHAr"Avx(r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     5 5$ 5r   c                h    \         P                  ! R4      pV P                  W8g  RV,          4       R# )z:
Identical L{URL}s are not unequal (C{!=}) to each other.
r|   z%r == itselfNr   rs   r   ra   s   & r   test_identicalNotUnequal TestURL.test_identicalNotUnequal  s*     LL,-!!34r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   !  s     8 8 8r   c                    \         P                  ! R4      p\         P                  ! R4      pV P                  W8g  V: RV: 24       R# )zE
Structurally similar L{URL}s are not unequal (C{!=}) to each other.
r|    == Nr	  r   s   &  r   test_similarNotUnequalTestURL.test_similarNotUnequal!  s?     \\-.\\-.bV4v#67r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   )  s     7 7t 7r   c                    \         P                  ! R4      p\         P                  ! R4      pV P                  W8g  V: RV: 24       R# )zC
Structurally different L{URL}s are unequal (C{!=}) to each other.
r   r   r  N)r   rs   r;   r   s   &  r   test_differentUnequalTestURL.test_differentUnequal)  s=     \\./\\./RF$rf"56r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   1  s     M M Mr   c                    \         P                  ! R4      pV P                  V^*8g  R4       V P                  V\        4       8g  R4       R# )z+
L{URL} is unequal (C{!=}) to other types.
r|   zURL must differ from a number.z"URL must be differ from an object.N)r   rs   r;   r  ra   s   & r   test_otherTypesUnequalTestURL.test_otherTypesUnequal1  s;     LL,-R!ABVX'KLr   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   9  s     V VD Vr   c                j   Rp\         P                  ! V4      pVP                  4       pV P                  VP                  R4       V P                  VP
                  ^ ,          R4       V P                  VP                  4       V4       RpVP                  4       pV P                  WTV: RV: 24       R# )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   é.comu   é.http://xn--9ca.com/%C3%A9?%C3%A1=%C3%AD#%C3%BAr   N)r   rs   asURIrH   r8   r9   ru   )r#   unicodeyiriuriexpectedURI	actualURIs   &     r   
test_asURITestURL.test_asURI9  s    B 	 ll8$iik#LMHHQKM	
 	x0FJJL	I=[O1TUr   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   P  s     V VD Vr   c                j   Rp\         P                  ! V4      pVP                  4       pV P                  VP                  R4       V P                  VP
                  ^ ,          R4       V P                  VP                  4       V4       RpVP                  4       pV P                  WTV: RV: 24       R# )z
L{URL.asIRI} decodes any percent-encoded text in the URI, making it
more suitable for reading by humans, and returns a new L{URL}.
r  zxn--9ca.comz%C3%A9u   http://é.com/é?á=í#úr   N)r   rs   asIRIrH   r8   r9   ru   )r#   asciiishr   r  expectedIRI	actualIRIs   &     r   
test_asIRITestURL.test_asIRIP  s    
 Dll8$iik=1!h/x03 	 JJL	I=[O1TUr   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   e  s     V V4 Vr   c                    Rp\         P                  ! V4      pVP                  4       pRpVP                  4       pV P	                  WTV: RV: 24       R# )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   rs   r'  ru   rH   )r#   urlWithBinaryr   r  r)  r*  s   &     r   test_badUTF8AsIRITestURL.test_badUTF8AsIRIe  sT    
 ;ll=)iik2 	
 JJL	I=[O1TUr   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2   u  s     5 5d 5r   c                    Rp\         P                  ! V4      pVP                  4       pV P                  VP	                  4       V4       R# )zD
A L{URL} composed of non-ASCII text will result in non-ASCII text.
r  N)r   rs   r'  rH   ru   )r#   r  r  alsoIRIs   &   r   test_alreadyIRIAsIRITestURL.test_alreadyIRIAsIRIu  s?    
B 	 ll8$))+)84r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     1 1d 1r   c                    Rp\         P                  ! V4      pVP                  4       P                  4       pV P	                  W14       R# )z8
A L{URL} composed of encoded text will remain encoded.
r  N)r   rs   r  ru   rH   )r#   r!  r   r"  s   &   r   test_alreadyURIAsURITestURL.test_alreadyURIAsURI  s:     Gll;'IIK&&(	0r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     
 
t 
r   c                   \         P                  ! R4      pV P                  VP                  R4      R4       V P                  VP                  R4      R4       V P                  VP                  R4       V P                  VP
                  R4       V P                  VP                  4       R4       V P                  VP                  RR	7      P                  4       R
4       R# )zb
L{URL.fromText} 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)rE   z/http://someuser@example.com/some-segment@ignoreN)r   rs   rH   	authorityrE   userru   r   r   s   & r   test_userinfoTestURL.test_userinfo  s    
 llJ
 	t,.QRu-/FG'>?:.JJLL	
 	KKK,335=	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     K Kt Kr   c                    \         P                  ! R4      pV P                  VP                  R4       V P                  VP	                  4       R4       R# )z9
L{URL.fromText} parses custom port numbers as integers.
zhttp://www.example.com:8080/i  N)r   rs   rH   rD   ru   )r#   portURLs   & r   test_portTextTestURL.test_portText  s?     ,,=>t,)+IJr   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     	
 	
T 	
r   c                n    V P                  \        P                  ! R4      P                  4       R4       R# )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.fromText}/L{URL.asText} round-trips cleanly for a C{mailto:} URL
representing an email address.
zmailto:user@example.comN)rH   r   rs   ru   r"   s   &r   test_mailtoTestURL.test_mailto  s+     	LL23::<>W	
r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     : :D :r   c                \    \        RR..R7      pV P                  VP                  R4       R# )zt
When a L{URL} is created with a C{query} argument, the C{query}
argument is converted into an N-tuple of 2-tuples.
alphabetar   N))rM  rN  )r   rH   r:   r   s   & r   test_queryIterableTestURL.test_queryIterable  s+     '6*+,$89r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     7 74 7r   c                Z    \        RR.R7      pV P                  VP                  R4       R# )zZ
When a L{URL} is created with a C{path} argument, the C{path} is
converted into a tuple.
r   r   r9   Nr   )r   rH   r9   r   s   & r   test_pathIterableTestURL.test_pathIterable  s(    
 )*#56r   c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     OA OAt OAr   c                  a aa  ! R R4      o\         \        J d   RMRpR V 3R lloV3R VVV 3R lllpV! R	4       V! R
4       V! R4       V! RR4       V! R4       V! RR4       S P                  \        4      ;_uu_ 4       p\	        S! 4       .R7       RRR4       S! XVR4       S P                  \        4      ;_uu_ 4       p\	        RS! 4       3.R7       RRR4       S! W1R,           R4       S P                  \        4      ;_uu_ 4       p\	        S! 4       R3.R7       RRR4       S! W1R4       S P                  \        4      ;_uu_ 4        \	        S! 4       .R7       RRR4       S P                  \
        4      ;_uu_ 4        \	        R.R7       RRR4       S P                  \
        4      ;_uu_ 4        \	        R.R7       RRR4       \        P                  ! R4      pS P                  \        4      ;_uu_ 4       pVP                  S! 4       4       RRR4       S! W1R4       S P                  \        4      ;_uu_ 4       pVP                  S! 4       4       RRR4       S! W1R4       S P                  \        4      ;_uu_ 4       pVP                  S! 4       4       RRR4       S! W1R4       R#   + '       g   i     EL-; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL{; i  + '       g   i     EL\; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     L; i)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                  .    ] tR tRtR R ltR R ltRtR# )1TestURL.test_invalidArguments.<locals>.Unexpectedi  c                   V ^8  d   QhRR/# r   r   r6   r   )r   s   "r   r   >TestURL.test_invalidArguments.<locals>.Unexpected.__annotate__  s       r   c                	    R # )wrongr   r"   s   &r   __str__9TestURL.test_invalidArguments.<locals>.Unexpected.__str__  s    r   c                   V ^8  d   QhRR/# r[  r   )r   s   "r   r   r\    s     & &# &r   c                	    R # )<unexpected>r   r"   s   &r   __repr__:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__  s    %r   r   N)r&   r'   r(   r)   r_  rd  r+   r   r   r   
UnexpectedrY    s    & &r   rf  unicoder6   c               (    V ^8  d   QhRRRRRRRR/# )r   raisedr   expectationr6   namer   r1   r   )r   s   "r   r   3TestURL.test_invalidArguments.<locals>.__annotate__  s)     	 	 	S 	 	PT 	r   c                r   < SP                  \        V P                  4      R P                  WR4      4       R# )zexpected {} for {}, got {}rc  N)rH   r6   r$   r   )ri  rj  rk  r#   s   &&&r   assertRaised3TestURL.test_invalidArguments.<locals>.assertRaised  s/    F$$%,33K~Vr   c               $    V ^8  d   QhRRRRRR/# )r   paramr6   rj  r   r1   r   )r   s   "r   r   rl    s!     	5 	5 	53 	5 	5r   c           	        < SP                  \        4      ;_uu_ 4       p\        R/ V S! 4       /B  R R R 4       S! XW4       R #   + '       g   i     L; i)Nr   )r   	TypeErrorr   )rq  rj  ri  rf  rn  r#   s   && r   rT   ,TestURL.test_invalidArguments.<locals>.check  s@    ""9--,ujl+, .4 .-s   AA	r5   r8   r=   r   boolrE   rD   zint or NoneTyperS  Nzpath segmentrk  r   z or NoneTypezquery parameter valuevaluezquery parameter namezhttps://valid.example.com/zrelative URL)r?   r@   vv)r?   )
bytesr6   r   rs  r   
ValueErrorrs   r   r   r   )r#   defaultExpectationrT   ri  r   rf  rn  s   f    @@r   test_invalidArgumentsTestURL.test_invalidArguments  s   	& 	& +03,YE	 	 2D 	5 	5
 	hfjhjf'(y))VL * 	V/@y))VZ\* * 	79P	
 y))V\7+ * 	V1GH y))z|n% *z**'() +z**vh + ll78y))VIIjl# *V@y))VKK
% *V@y))VIIjl# *V@S *)) *)) *)) *))****** *)) *) *)sl   J=KK%K9L L!	L5M	M=K	K"	%K6	9L
	L	!L2	5M		M	M,	c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r   r2     s     
 
4 
r   c                
   V P                  \        4      ;_uu_ 4       p\        RR7       RRR4       V P                  \	        XP
                  4      RP                  \        R4      4      4       R#   + '       g   i     LO; i)z
Technically, L{str} (or L{unicode}, as appropriate) is iterable, but
C{URL(path="foo")} resulting in C{URL.fromText("f/o/o")} is never what
you want.
rk   rS  Nz+expected iterable of text for path, not: {})r   rs  r   rH   r6   r$   r   r7   )r#   ri  s   & r   !test_technicallyTextIsIterableBut)TestURL.test_technicallyTextIsIterableBut  sZ     y))VUO *  !9@@eM	
 *)s   A22B	r   N)r   )2r&   r'   r(   r)   __doc__rA   rK   rV   rb   rg   ro   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r  r  r#  r+  r0  r5  r9  r@  rE  rI  rO  rT  r{  r  r+   r   r   r   r-   r-   U   s    8 +D+
$

&3+0


.
D
$&
PAE5&B"
H
*
-5!$)587MV.V*V 51
(K	
:7OAb
 
r   r-   c                  &    ] tR tRtRtR R ltRtR# )URLDeprecationTestsi$  z&
L{twisted.python.url} is deprecated.
c                   V ^8  d   QhRR/# rN   r   )r   s   "r   r    URLDeprecationTests.__annotate__)  s     
 
T 
r   c                    ^ RI Hp V V P                  V P                  .4      pV P	                  ^\        V4      4       V P	                  RV^ ,          R,          4       R# )z;
L{twisted.python.url} is deprecated since Twisted 17.5.0.
)r   z\twisted.python.url was deprecated in Twisted 17.5.0: Please use hyperlink from PyPI instead.messageN)twisted.pythonr   flushWarningstest_urlDeprecationrH   len)r#   r   warningsShowns   &  r   r  'URLDeprecationTests.test_urlDeprecation)  sZ     	'**D,D,D+EFC./; !Y'	
r   r   N)r&   r'   r(   r)   r  r  r+   r   r   r   r  r  $  s    
 
r   r  N)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	   )r   http://a/b/c/)z./r  )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)r  
__future__r   typingr   r   twisted.trial.unittestr   r   r   rt   r   r   _percentencr   r-   r  r   r   r   <module>r     s  
 #   6 	5 2 4 4 	4
 4 4 4 !4  4 #4  4 $4 4  4 (4  !4" #4$ %4& '4( )4* +4, -4. /40 146 !748 $94> ?4@ A4B C4D E4F  G4H  I4L M4N !O4P "Q4R !S4T *U4V %W4Z ([4\ *]4^ (_4` *a4 n >H L
! L
^
- 
r   