ó
    Ö›‘hxu  ã                  óœ   • S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SrS	r/ S
QrS r " S S\5      r " S S\5      r " S S\5      rg)z"
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?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   )Ú.ú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/../xc                ó2   • SR                  S U  5       5      $ )Nr   c              3  ó>   #   • U  H  nS [        U5      -  v •  M     g7f)z%%%02XN)Úord)Ú.0Úcs     Ú`C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/python/test/test_url.pyÚ	<genexpr>Ú<lambda>.<locals>.<genexpr>L   s   é € Ð=º1°a ¬3¨q«6Ö 1º1ùs   ‚)Újoin)Úss    r   Ú<lambda>r!   L   s   € ˜Ÿ™Ñ=¹1Ó=Ô=ó    c                  ó(   • \ rS rSr\SS j5       rSrg)Ú_HasExceptionéO   c                ó   • g )N© ©Úselfs    r   Ú	exceptionÚ_HasException.exceptionP   s   € àr"   r'   N)ÚreturnÚBaseException)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Úpropertyr*   Ú__static_attributes__r'   r"   r   r$   r$   O   s   † Øóó ór"   r$   c                  óø  • \ rS rSrSrS1S jr S2                 S3S jjrS4S jrS4S jrS4S jr	S4S jr
S4S	 jrS4S
 jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jrS4S jr S4S jr!S4S  jr"S4S! jr#S4S" jr$S4S# jr%S4S$ jr&S4S% jr'S4S& jr(S4S' jr)S4S( jr*S4S) jr+S4S* jr,S4S+ jr-S4S, jr.S4S- jr/S4S. jr0S/r1g0)5ÚTestURLéU   z
Tests for L{URL}.
c                ó8  • U R                  UR                  [        [        U5      5        U R                  UR                  [        [        U5      5        UR
                   H#  nU R                  U[        [        U5      5        M%     UR                   HY  u  p4U R                  U[        [        U5      5        U R                  USL =(       d    [        U[        5      [        U5      5        M[     U R                  UR                  [        [        U5      5        g)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)   ÚuÚsegÚkÚvs        r   ÚassertUnicodedÚTestURL.assertUnicodedZ   sÀ   € ð 	×Ñ˜aŸh™h¬¬T°!«WÔ5Ø×Ñ˜aŸf™f¤c¬4°«7Ô3Ø—6”6ˆCØ×!Ñ! #¤s¬D°«GÖ4ñ à—G”G‰DˆAØ×!Ñ! !¤S¬$¨q«'Ô2Ø�O‰O˜A ˜I×;¬°A´sÓ);¼TÀ!»WÖEñ ð 	×Ñ˜aŸj™j¬#¬t°A«wÕ7r"   c	                ó
  • UR                   UR                  UR                  UR                  UR                  UR
                  UR                  4n	X#[        U5      [        U5      XgUR                  4n
U R                  Xš5        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)	r9   r<   r=   r>   rA   ÚportÚuserinfoÚtupleÚassertEqual)r)   rB   r9   r<   r=   r>   rA   rI   rJ   ÚactualÚexpecteds              r   Ú	assertURLÚTestURL.assertURLi   s^   € ð< —(‘(˜AŸF™F A§F¡F¨A¯G©G°Q·Z±ZÀÇÁÈÏÉÐTˆØ¤%¨£+¬u°U«|¸XÈQÏZÉZÐXˆØ×Ñ˜Õ*r"   c           	     óŒ   ^ • SU 4S j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   )rF   rO   )rB   r)   s    €r   ÚcheckÚ(TestURL.test_initDefaults.<locals>.check�   s+   ø€ Ø×Ñ Ô"Ø�N‰N˜1˜f b¨"¨b°"°b¸"Õ=r"   rS   r   N©rB   r	   r,   ÚNoner   )r)   rU   s   ` r   Útest_initDefaultsÚTestURL.test_initDefaults‹   s@   ø€ ÷
	>ñ 	Œc�&˜"‹oÔÙŒc�&˜"˜b "Ó%Ô&ÙŒc�&˜"˜b " bÓ)Õ*r"   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.
r    ÚhÚp©rD   rE   )rD   NÚfNrS   ô   Ã ô   Ã©)u   Î»u   Ï€u   âŠ¥rT   ©r	   rF   rO   ©r)   rB   s     r   Ú	test_initÚTestURL.test_init˜   sƒ   € ô ��S˜3˜% *¨kÐ!:¸CÓ@ˆØ×Ñ˜AÔØ�‰�q˜#˜s S E¨J¸Ð+DÀcÈ4ÔPà�‰Ü�˜  Ð+?Ð*@À(ÓKØØØˆHØ!Ð"ØØõ	
r"   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.
r    z%68z%70)ú%6Bz%76)rg   Nz%66Nrb   rc   s     r   Útest_initPercentÚTestURL.test_initPercentª   sM   € ô ��U˜U˜G n°mÐ%DÀeÓLˆØ×Ñ˜AÔØ�‰Øˆs�E˜E˜7 ^°]Ð$CÀUÈDõ	
r"   c                ó†   • U R                  [        [        SSS/SS/SS95      SR                  [        S	5      5      5        g
)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Úbar)ÚbazNr^   Úfrob)r9   r<   r=   r>   rA   zURL.from_text({})zhttp://foo/bar?baz&k=v#frobN)rL   r;   r	   Úformatr(   s    r   Ú	test_reprÚTestURL.test_repr´   sN   € ð 	×ÑÜÜØ!ØØ˜Ø(¨*Ð5Ø#ñóð  ×&Ñ&¤tÐ,IÓ'JÓKõ	
r"   c                ó€   • [         R                  " [        5      nU R                  [        UR	                  5       5        g)zJ
Round-tripping L{URL.fromText} with C{str} results in an equivalent
URL.
N)r	   ÚfromTextÚtheurlrL   ÚasText©r)   Úurlpaths     r   Útest_fromTextÚTestURL.test_fromTextÇ   s)   € ô
 —,’,œvÓ&ˆØ×Ñœ §¡Ó!1Õ2r"   c                ó„   • SnU H8  n[         R                  " U5      R                  5       nU R                  X#5        M:     g)z.
L{URL.asText} should invert L{URL.fromText}.
)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)N)r	   rs   ru   rL   )r)   ÚtestsÚtestÚresults       r   Útest_roundtripÚTestURL.test_roundtripÏ   s:   € ð
ˆó  ˆDÜ—\’\ $Ó'×.Ñ.Ó0ˆFØ×Ñ˜TÖ*ò r"   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.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   rL   ÚassertNotEqualrv   s     r   Útest_equalityÚTestURL.test_equalityç   sK   € ô —,’,œvÓ&ˆØ×Ñ˜¤#§,¢,¬vÓ"6Ô7Ø×ÑØÜ�LŠLØOóõ	
r"   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   )rA   zhttp://localhost/#r{   N)rL   r	   rs   r(   s    r   Útest_fragmentEqualityÚTestURL.test_fragmentEqualityö   sB   € ð
 	×Ñœ bÑ)¬3«5Ô1Ø×ÑÜ�LŠLÐ-Ó.´·²Ð=PÓ0Qõ	
r"   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	   rs   rt   rL   Úchildru   rv   s     r   Ú
test_childÚTestURL.test_child   s°   € ô
 —,’,œvÓ&ˆØ×ÑØ<Ø�M‰M˜&Ó!×(Ñ(Ó*ô	
ð 	×ÑØ?Ø�M‰M˜'Ó"×)Ñ)Ó+ô	
ð 	×ÑØEØ�M‰M˜-Ó(×/Ñ/Ó1ô	
ð 	×ÑØHØ�M‰M˜.Ó)×0Ñ0Ó2õ	
r"   c                óŽ   • U R                  [        R                  " S5      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/br   ÚdÚezhttp://example.com/a/b/c/d/eN)rL   r	   rs   rŠ   ru   r(   s    r   Útest_multiChildÚTestURL.test_multiChild  s:   € ð
 	×ÑÜ�LŠLÐ1Ó2×8Ñ8¸¸cÀ3ÓG×NÑNÓPØ*õ	
r"   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?   ÚrootedrL   ru   )r)   ÚchildURLs     r   Útest_childInitRootÚTestURL.test_childInitRoot!  sA   € ô
 ˜MÑ*×0Ñ0°Ó5ˆØ�‰˜Ÿ™Ô(Ø×ÑÐ/°·±Ó1BÕCr"   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	   rs   rt   rL   Úsiblingru   )r)   rw   Útheurl2s      r   Útest_siblingÚTestURL.test_sibling*  ss   € ô
 —,’,œvÓ&ˆØ×ÑØ>Ø�O‰O˜HÓ%×,Ñ,Ó.ô	
ð
 >ˆÜ—,’,˜wÓ'ˆØ×ÑØ9Ø�O‰O˜HÓ%×,Ñ,Ó.õ	
r"   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        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.orgN)r	   rs   rt   rL   r    ru   ÚassertNotIn)r)   rw   rB   s      r   Ú
test_clickÚTestURL.test_click<  s?  € ô
 —,’,œvÓ&ˆà×ÑØ8¸'¿-¹-ÈÓ:K×:RÑ:RÓ:Tô	
ð 	×ÑØ2°G·M±MÀ'Ó4J×4QÑ4QÓ4Sô	
ð 	×ÑÐ3°W·]±]À8Ó5L×5SÑ5SÓ5UÔVà×ÑØ2°G·M±MÀ'Ó4J×4QÑ4QÓ4Sô	
ð
 	×ÑØ˜Ÿ™Ð&AÓB×IÑIÓKô	
ô �LŠLÐ8Ó9ˆØ×ÑØ/°·±Ð9JÓ1K×1RÑ1RÓ1Tô	
ô �LŠLÐ7Ó8ˆØ×ÑØ�G‰GÐ+Ó,×3Ñ3Ó5Ð7Nõ	
r"   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	   rs   ÚrelativeLinkBaseForRFC3986ÚrelativeLinkTestsForRFC3986rL   r    ru   )r)   ÚbaseÚrefrN   s       r   Útest_clickRFC3986ÚTestURL.test_clickRFC3986d  s@   € ô �|Š|Ô6Ó7ˆß8‰MˆCØ×Ñ˜TŸZ™Z¨›_×3Ñ3Ó5°xÖ@ò 9r"   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	   rs   r¥   ÚassertRaisesÚNotImplementedErrorr    )r)   r§   s     r   Útest_clickSchemeRelPathÚTestURL.test_clickSchemeRelPathl  sA   € ô �|Š|Ô6Ó7ˆØ×ÑÔ-¨t¯z©z¸5ÔAØ×ÑÔ-¨t¯z©z¸8ÕDr"   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	   rs   rL   Úreplacer9   r<   r=   r>   rA   rI   rv   s     r   Útest_cloneUnchangedÚTestURL.test_cloneUnchangedt  sw   € ô
 —,’,Ð4Ó5ˆØ×ÑØ�O‰OØ—‘Ø—‘Ø—‘Ø—‘Ø× Ñ Ø—‘óð ô
	
ð 	×Ñ˜Ÿ™Ó*¨GÕ4r"   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    rM   rN   N)r	   rs   r    ru   rL   ro   r;   )r)   r|   r¹   r    rN   rM   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                ó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/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)rL   r	   rs   Úaddru   rt   rv   s     r   Útest_queryAddÚTestURL.test_queryAdd¨  sj  € ð 	×ÑØ5Ü�LŠLÐ:Ó;×?Ñ?ÀÀuÓM×TÑTÓVô	
ð 	×ÑØ)Ü�]Ñ#×'Ñ'¨¨uÓ5×<Ñ<Ó>ô	
ô —,’,œvÓ&ˆØ×ÑØ=Ø�K‰K˜Ó×&Ñ&Ó(ô	
ð 	×ÑØAØ�K‰K˜ Ó&×-Ñ-Ó/ô	
ð 	×ÑØFØ�K‰K˜ Ó&×*Ñ*¨6Ó2×9Ñ9Ó;ô	
ð
 	×ÑØFØ�K‰K˜Ó×#Ñ# F¨EÓ2×9Ñ9Ó;ô	
ð
 	×ÑØHØ�K‰K˜ Ó&×*Ñ*¨5°$Ó7×>Ñ>Ó@õ	
r"   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	   rs   rt   rL   Úsetru   rÂ   rv   s     r   Útest_querySetÚTestURL.test_querySetÌ  s¦   € ô —,’,œvÓ&ˆØ×ÑØ8Ø�K‰K˜˜tÓ$×+Ñ+Ó-ô	
ð
 	×ÑØ>Ø�K‰K˜Ó×"Ñ" 5¨*Ó5×<Ñ<Ó>ô	
ð 	×ÑØ8Ø�K‰K˜˜uÓ%×)Ñ)¨%°Ó6×=Ñ=Ó?õ	
r"   c                óš   • [         R                  " S5      nU R                  UR                  S5      [         R                  " S5      5        g)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   rL   Úremove©r)   Úurls     r   Útest_queryRemoveÚTestURL.test_queryRemoveá  s9   € ô �lŠlÐGÓHˆØ×ÑØ�J‰J�uÓœsŸ|š|Ð,LÓMõ	
r"   c                óT   • U R                  [        5       R                  5       S5        g)z7
An empty L{URL} should serialize as the empty string.
r   N)rL   r	   ru   r(   s    r   Ú
test_emptyÚTestURL.test_emptyê  s   € ð 	×Ñœ›Ÿ™›¨Õ,r"   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	   rL   ru   rc   s     r   Útest_justQueryTextÚTestURL.test_justQueryTextð  s(   € ô Ð)Ð*Ñ+ˆØ×Ñ˜Ÿ™› ^Õ4r"   c                óR   • [         R                  " S5      nU R                  X5        g)z"
L{URL} compares equal to itself.
r{   N©r	   rs   rL   rc   s     r   Útest_identicalEqualÚTestURL.test_identicalEqual÷  s!   € ô �LŠLÐ,Ó-ˆØ×Ñ˜Õr"   c                ó~   • [         R                  " S5      n[         R                  " S5      nU R                  X5        g)z7
URLs with equivalent components should compare equal.
r{   NrÜ   ©r)   Úu1Úu2s      r   Útest_similarEqualÚTestURL.test_similarEqualþ  s0   € ô �\Š\Ð-Ó.ˆÜ�\Š\Ð-Ó.ˆØ×Ñ˜Õ r"   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	   rs   ÚassertFalser‚   rà   s      r   Útest_differentNotEqualÚTestURL.test_differentNotEqual  sM   € ô
 �\Š\Ð.Ó/ˆÜ�\Š\Ð.Ó/ˆØ×Ñ˜™ b¡V¨4°©vÐ#6Ô7Ø×Ñ˜BÕ#r"   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	   rs   ré   Úobjectr‚   rc   s     r   Útest_otherTypesNotEqualÚTestURL.test_otherTypesNotEqual  sa   € ô �LŠLÐ,Ó-ˆØ×Ñ˜˜b™Ð"@ÔAØ×Ñ˜œf›h™Ð(GÔHØ×Ñ˜A˜rÔ"Ø×Ñ˜Aœv›xÕ(r"   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	   rs   ré   rc   s     r   Útest_identicalNotUnequalÚ TestURL.test_identicalNotUnequal  s*   € ô �LŠLÐ,Ó-ˆØ×Ñ˜™ °!Ñ!3Õ4r"   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      r   Útest_similarNotUnequalÚTestURL.test_similarNotUnequal!  s?   € ô �\Š\Ð-Ó.ˆÜ�\Š\Ð-Ó.ˆØ×Ñ˜™ b¡V¨4°©vÐ#6Õ7r"   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	   rs   r?   rà   s      r   Útest_differentUnequalÚTestURL.test_differentUnequal)  s=   € ô �\Š\Ð.Ó/ˆÜ�\Š\Ð.Ó/ˆØ�‰˜™ R¡F¨$¨r©fÐ"5Õ6r"   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	   rs   r?   rî   rc   s     r   Útest_otherTypesUnequalÚTestURL.test_otherTypesUnequal1  s;   € ô �LŠLÐ,Ó-ˆØ�‰˜˜R™Ð!AÔBØ�‰˜œV›X™Ð'KÕLr"   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	   rs   ÚasURIrL   r<   r=   ru   )r)   ÚunicodeyÚiriÚuriÚexpectedURIÚ	actualURIs         r   Ú
test_asURIÚTestURL.test_asURI9  sœ   € ðBð 	ô �lŠl˜8Ó$ˆØ�i‰i‹kˆØ×Ñ˜Ÿ™Ð#LÔMØ×ÑØ�H‰H�Q‰KÐMô	
ð 	×Ñ˜Ÿ™› xÔ0ØFˆØ—J‘J“Lˆ	Ø×Ñ˜°I±=ÀÀ[ÁOÐ1TÕUr"   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	   rs   ÚasIRIrL   r<   r=   ru   )r)   Úasciiishr  r  ÚexpectedIRIÚ	actualIRIs         r   Ú
test_asIRIÚTestURL.test_asIRIP  s—   € ð
 DˆÜ�lŠl˜8Ó$ˆØ�i‰i‹kˆØ×Ñ˜Ÿ™ =Ô1Ø×Ñ˜Ÿ™ !™ hÔ/Ø×Ñ˜Ÿ™› xÔ0ð3ð 	ð —J‘J“Lˆ	Ø×Ñ˜°I±=ÀÀ[ÁOÐ1TÕUr"   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	   rs   r  ru   rL   )r)   ÚurlWithBinaryr  r  r  r  s         r   Útest_badUTF8AsIRIÚTestURL.test_badUTF8AsIRIe  sT   € ð
 ;ˆÜ�lŠl˜=Ó)ˆØ�i‰i‹kˆð2ð 	ð
 —J‘J“Lˆ	Ø×Ñ˜°I±=ÀÀ[ÁOÐ1TÕUr"   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	   rs   r  rL   ru   )r)   r  r  ÚalsoIRIs       r   Útest_alreadyIRIAsIRIÚTestURL.test_alreadyIRIAsIRIu  s?   € ð
Bð 	ô �lŠl˜8Ó$ˆØ—)‘)“+ˆØ×Ñ˜Ÿ™Ó)¨8Õ4r"   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	   rs   r  ru   rL   )r)   r  r  r  s       r   Útest_alreadyURIAsURIÚTestURL.test_alreadyURIAsURI„  s:   € ð GˆÜ�lŠl˜;Ó'ˆØ—I‘I“K×&Ñ&Ó(ˆ	Ø×Ñ˜Õ0r"   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)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)rJ   z/http://someuser@example.com/some-segment@ignoreN)r	   rs   rL   Ú	authorityrJ   Úuserru   r±   rÍ   s     r   Útest_userinfoÚTestURL.test_userinfo�  s¸   € ô
 �lŠlØJó
ˆð 	×Ñ˜Ÿ™ tÓ,Ð.QÔRØ×Ñ˜Ÿ™ uÓ-Ð/FÔGØ×Ñ˜Ÿ™Ð'>Ô?Ø×Ñ˜Ÿ™ :Ô.Ø×ÑØ�J‰J‹LÐLô	
ð 	×ÑØ�K‰K ˆKÐ,×3Ñ3Ó5Ø=õ	
r"   c                ó¨   • [         R                  " S5      nU R                  UR                  S5        U R                  UR	                  5       S5        g)z9
L{URL.fromText} parses custom port numbers as integers.
zhttp://www.example.com:8080/i�  N)r	   rs   rL   rI   ru   )r)   ÚportURLs     r   Útest_portTextÚTestURL.test_portText¡  s?   € ô —,’,Ð=Ó>ˆØ×Ñ˜Ÿ™ tÔ,Ø×Ñ˜Ÿ™Ó)Ð+IÕJr"   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.fromText}/L{URL.asText} round-trips cleanly for a C{mailto:} URL
representing an email address.
zmailto:user@example.comN)rL   r	   rs   ru   r(   s    r   Útest_mailtoÚTestURL.test_mailto©  s+   € ð 	×ÑÜ�LŠLÐ2Ó3×:Ñ:Ó<Ð>Wõ	
r"   c                óT   • [        SS//S9nU R                  UR                  S5        g)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Ø   ))r*  r+  N)r	   rL   r>   rÍ   s     r   Útest_queryIterableÚTestURL.test_queryIterable´  s+   € ô ˜' 6Ð*Ð+Ñ,ˆØ×Ñ˜Ÿ™Ð$8Õ9r"   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	   rL   r=   rÍ   s     r   Útest_pathIterableÚTestURL.test_pathIterable½  s(   € ô
 ˜ Ð)Ñ*ˆØ×Ñ˜Ÿ™Ð#5Õ6r"   c                óô  ^ ^^•  " S S5      m[         [        L a  SOSnSU 4S jjmU4SUUU 4S j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       /S9  SSS5        T" WUS5        T R                  [        5       n[	        ST" 5       4/S9  SSS5        T" X1S-   S5        T R                  [        5       n[	        T" 5       S4/S9  SSS5        T" X1S5        T R                  [        5         [	        T" 5       /S9  SSS5        T R                  [
        5         [	        S/S9  SSS5        T R                  [
        5         [	        S/S9  SSS5        [        R                  " S5      nT R                  [        5       nUR                  T" 5       5        SSS5        T" X1S5        T R                  [        5       nUR                  T" 5       5        SSS5        T" X1S5        T R                  [        5       nUR                  T" 5       5        SSS5        T" X1S5        g! , (       d  f       GN×= f! , (       d  f       GN°= f! , (       d  f       GN‡= f! , (       d  f       GNc= f! , (       d  f       GNM= f! , (       d  f       GN7= f! , (       d  f       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S jrSS jrSrg)Ú1TestURL.test_invalidArguments.<locals>.UnexpectediÐ  c                ó   • g)NÚwrongr'   r(   s    r   Ú__str__Ú9TestURL.test_invalidArguments.<locals>.Unexpected.__str__Ñ  s   € Ør"   c                ó   • g)Nú<unexpected>r'   r(   s    r   Ú__repr__Ú:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__Ô  s   € Ø%r"   r'   N)r,   r:   )r.   r/   r0   r1   r7  r;  r3   r'   r"   r   Ú
Unexpectedr4  Ð  s   † ô÷&r"   r=  Úunicoder:   Únamec                óp   >• TR                  [        U R                  5      SR                  XS5      5        g )Nzexpected {} for {}, got {}r:  )rL   r:   r*   ro   )ÚraisedÚexpectationr?  r)   s      €r   ÚassertRaisedÚ3TestURL.test_invalidArguments.<locals>.assertRaisedÙ  s/   ø€ Ø×ÑÜ�F×$Ñ$Ó%Ø,×3Ñ3°KÀ~ÓVõr"   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)Nr'   )r¬   Ú	TypeErrorr	   )ÚparamrB  rA  r=  rC  r)   s      €€€r   rU   Ú,TestURL.test_invalidArguments.<locals>.checkß  s=   ø€ Ø×"Ñ"¤9Ô-°ÜÑ,�u™j›lÐ+Ò,÷ .á˜ Õ4÷ .Õ-ús	   —<¼
A
r9   r<   rA   r•   ÚboolrJ   rI   zint or NoneTyper/  Nzpath segmentrØ   z or NoneTypezquery parameter valueÚvaluezquery parameter name)rD   rE   Úvv)rD   zhttps://valid.example.com/zrelative URL)rA  r$   rB  r:   r?  r:   r,   rX   )rG  r:   rB  r:   r,   rX   )
Úbytesr:   r¬   rF  r	   Ú
ValueErrorrs   rŠ   r›   r    )r)   ÚdefaultExpectationrU   rA  rÎ   r=  rC  s   `    @@r   Útest_invalidArgumentsÚTestURL.test_invalidArgumentsÅ  s\  ú€ ÷	&ñ 	&ô +0´3ª,™Y¸EÐ÷	ð 2D÷ 	5ó 	5ñ
 	ˆhŒÙˆfŒÙˆjÔÙˆh˜ÔÙˆjÔÙˆfÐ'Ô(à×ÑœyÔ)¨VÜá“Lðò÷ *ñ 	�VÐ/°Ô@Ø×ÑœyÔ)¨VÜà™Z›\Ð*ðò÷ *ñ 	Ø¨Ñ7Ð9Pô	
ð ×ÑœyÔ)¨VÜá“\ 7Ð+ðò÷ *ñ 	�VÐ1GÔHð ×ÑœyÕ)Ü‘z“|�nÒ%÷ *à×ÑœzÕ*ÜÐ'Ð(Ò)÷ +à×ÑœzÕ*Ü�v�hÒ÷ +ô �lŠlÐ7Ó8ˆØ×ÑœyÔ)¨VØ�I‰I‘j“lÔ#÷ *á�V°Ô@Ø×ÑœyÔ)¨VØ�K‰K™
›Ô%÷ *á�V°Ô@Ø×ÑœyÔ)¨VØ�I‰I‘j“lÔ#÷ *á�V°Õ@÷S *Ö)ú÷ *Ö)ú÷ *Ö)ú÷ *Ö)úç*Ö*úç*Ö*ú÷ *Õ)ú÷ *Õ)ú÷ *Õ)úsl   Á;IÂ2I-Ã-I?Ä%JÅJ#Å:J5Æ8KÇ5KÈ2K)É
I*É-
I<É?
JÊ
J Ê#
J2Ê5
KË
KË
K&Ë)
K7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.fromText("f/o/o")} is never what
you want.
rk   r/  Nz+expected iterable of text for path, not: {})r¬   rF  r	   rL   r:   r*   ro   r;   )r)   rA  s     r   Ú!test_technicallyTextIsIterableButÚ)TestURL.test_technicallyTextIsIterableBut  sW   € ð ×ÑœyÔ)¨VÜ�UŠO÷ *à×ÑÜ�× Ñ Ó!Ø9×@Ñ@ÄÀeÃÓMõ	
÷ *Õ)ús   –
A&Á&
A4r'   NrW   )r   )rB   r	   r9   r:   r<   r:   r=   zIterable[str]r>   z Iterable[tuple[str, str | None]]rA   r:   rI   z
int | NonerJ   r:   r,   rX   ©r,   rX   )2r.   r/   r0   r1   Ú__doc__rF   rO   rY   rd   rh   rp   rx   r   rƒ   r†   r‹   r�   r—   r�   r¢   r©   r®   r²   rº   rÃ   rÉ   rÏ   rÒ   rÙ   rÝ   rã   rê   rï   ró   r÷   rú   rý   r  r  r  r  r  r   r$  r'  r,  r0  rO  rR  r3   r'   r"   r   r5   r5   U   sO  † ñô8ð0 ð +àð +ð ð +ð ð	 +ð
 ð +ð 0ð +ð ð +ð ð +ð ð +ð 
õ +ô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"   r5   c                  ó"   • \ rS rSrSrSS jrSrg)ÚURLDeprecationTestsi$  z&
L{twisted.python.url} is deprecated.
c                ó²   • SSK Jn  U  U R                  U R                  /5      nU R	                  S[        U5      5        U R	                  SUS   S   5        g)z;
L{twisted.python.url} is deprecated since Twisted 17.5.0.
r   )rÎ   é   z\twisted.python.url was deprecated in Twisted 17.5.0: Please use hyperlink from PyPI instead.ÚmessageN)Útwisted.pythonrÎ   ÚflushWarningsÚtest_urlDeprecationrL   Úlen)r)   rÎ   ÚwarningsShowns      r   r]  Ú'URLDeprecationTests.test_urlDeprecation)  sZ   € õ 	'áà×*Ñ*¨D×,DÑ,DÐ+EÓFˆØ×Ñ˜œC Ó.Ô/Ø×Ñð;ð ˜!Ñ˜YÑ'õ	
r"   r'   NrT  )r.   r/   r0   r1   rU  r]  r3   r'   r"   r   rW  rW  $  s   † ñ÷
r"   rW  N)rU  Ú
__future__r   Útypingr   Útyping_extensionsr   Útwisted.trial.unittestr   rÎ   r	   rt   r¥   r¦   Ú_percentencr$   r5   rW  r'   r"   r   Ú<module>rf     sa   ðñ
õ #å å &å 6Ý à	5€ð 2Ð ò4Ð ñn >€ô�Hô ôL
Ð!ô L
ô^
Ð-õ 
r"   