ó
    Ö›‘hå'  ã                   ó¸   • S r SSKJr  SSKJr   " S S5      r " S S\\R                  5      r " S S	\\R                  5      r " S
 S\\R                  5      r	g)z&
Tests for L{twisted.python.urlpath}.
é    )Úurlpath)Úunittestc                   óf   • \ rS rSrSrS rS r\4S jrS r	S r
S rS	 rS
 rS rS rS rS rSrg)Ú_BaseURLPathTestsé   z-
Tests for instantiated L{urlpath.URLPath}s.
c                 ó¨  • U R                  U R                  R                  [        5        U R                  U R                  R                  [        5        U R                  U R                  R                  [        5        U R                  U R                  R
                  [        5        U R                  U R                  R                  [        5        g)zA
All of the attributes of L{urlpath.URLPath} should be L{bytes}.
N©ÚassertIsInstanceÚpathÚschemeÚbytesÚnetlocÚqueryÚfragment©Úselfs    ÚdC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/python/test/test_urlpath.pyÚtest_partsAreBytesÚ$_BaseURLPathTests.test_partsAreBytes   ó‚   € ð 	×Ñ˜dŸi™i×.Ñ.´Ô6Ø×Ñ˜dŸi™i×.Ñ.´Ô6Ø×Ñ˜dŸi™iŸn™n¬eÔ4Ø×Ñ˜dŸi™iŸo™o¬uÔ5Ø×Ñ˜dŸi™i×0Ñ0´%Õ8ó    c                 ór   • U R                  [        U R                  R                  5       5      [        5        g)zA
Calling C{str()} with a L{URLPath} will always return a L{str}.
N)ÚassertEqualÚtyper   Ú__str__Ústrr   s    r   Útest_strReturnsStrÚ$_BaseURLPathTests.test_strReturnsStr   s&   € ð 	×Ñœ˜dŸi™i×/Ñ/Ó1Ó2´CÕ8r   c                 ó\  • U" S5      U R                   l        U R                  [        U R                   5      S5        U" S5      U R                   l        U R                  [        U R                   5      S5        U" S5      U R                   l         U R                  [        U R                   5      S5        U" S5      U R                   l        U R                  [        U R                   5      S5        U" S	5      U R                   l        U R                  [        U R                   5      S
5        g)a  
Setting attributes on L{urlpath.URLPath} should change the value
returned by L{str}.

@param stringType: a callable to parameterize this test for different
    text types.
@type stringType: 1-argument callable taking L{str} and returning
    L{str} or L{bytes}.
Úhttpsz0https://example.com/foo/bar?yes=no&no=yes#footerzanother.example.invalidz<https://another.example.invalid/foo/bar?yes=no&no=yes#footerz/helloz:https://another.example.invalid/hello?yes=no&no=yes#footerzalpha=omega&opposites=samezGhttps://another.example.invalid/hello?alpha=omega&opposites=same#footerÚheaderzGhttps://another.example.invalid/hello?alpha=omega&opposites=same#headerN)r   r   r   r   r   r   r   )r   Ú
stringTypes     r   Útest_mutabilityWithTextÚ)_BaseURLPathTests.test_mutabilityWithText"   sñ   € ñ & gÓ.ˆ�	‰	ÔØ×ÑÜ�—	‘	‹NÐNô	
ñ &Ð&?Ó@ˆ�	‰	ÔØ×ÑÜ�—	‘	‹NØJô	
ñ $ HÓ-ˆ�	‰	ŒØ×ÑÜ�—	‘	‹NÐXô	
ñ %Ð%AÓBˆ�	‰	ŒØ×ÑÜ�—	‘	‹Nðô	
ñ
 (¨Ó1ˆ�	‰	ÔØ×ÑÜ�—	‘	‹Nðõ	
r   c                 ó(   • U R                  S 5        g)z3
Same as L{test_mutabilityWithText} but for bytes.
c                 ó$   • U R                  S5      $ )NÚascii)Úencode)Úxs    r   Ú<lambda>Ú<_BaseURLPathTests.test_mutabilityWithBytes.<locals>.<lambda>J   s   € ¨q¯x©x¸Ô/@r   N)r#   r   s    r   Útest_mutabilityWithBytesÚ*_BaseURLPathTests.test_mutabilityWithBytesF   s   € ð 	×$Ñ$Ñ%@ÕAr   c                 ó¨  • U R                  U R                  R                  [        5        U R                  U R                  R                  [        5        U R                  U R                  R                  [        5        U R                  U R                  R
                  [        5        U R                  U R                  R                  [        5        g)z,
A created L{URLPath} has bytes attributes.
Nr	   r   s    r   Útest_allAttributesAreBytesÚ,_BaseURLPathTests.test_allAttributesAreBytesL   r   r   c                 óN   • U R                  [        U R                  5      S5        g)z[
Calling C{str()} with a L{URLPath} will return the same URL that it was
constructed with.
ú/http://example.com/foo/bar?yes=no&no=yes#footerN)r   r   r   r   s    r   Útest_stringConversionÚ'_BaseURLPathTests.test_stringConversionV   s    € ð
 	×ÑÜ�—	‘	‹NÐMõ	
r   c           	      óX  • U R                  [        U R                  R                  S5      5      S5        U R                  [        U R                  R                  S5      R                  S5      5      S5        U R                  [        U R                  R                  SSS95      S5        g)	zv
Calling C{str()} with a C{URLPath.child()} will return a URL which is
the child of the URL it was instantiated with.
s   helloz http://example.com/foo/bar/hellor   z!http://example.com/foo/bar/hello/T©Ú	keepQueryz.http://example.com/foo/bar/hello?yes=no&no=yesN)r   r   r   Úchildr   s    r   Útest_childStringÚ"_BaseURLPathTests.test_childString_   s‰   € ð
 	×ÑÜ�—	‘	—‘ Ó)Ó*Ð,Nô	
ð 	×ÑÜ�—	‘	—‘ Ó)×/Ñ/°Ó4Ó5Ø/ô	
ð 	×ÑÜ�—	‘	—‘ °D�Ð9Ó:Ø<õ	
r   c           	      óX  • U R                  [        U R                  R                  S5      5      S5        U R                  [        U R                  R                  SSS95      S5        U R                  [        U R                  R	                  S5      R                  S5      5      S5        g)	zz
Calling C{str()} with a C{URLPath.sibling()} will return a URL which is
the sibling of the URL it was instantiated with.
ó   bazzhttp://example.com/foo/bazTr6   z(http://example.com/foo/baz?yes=no&no=yesr   zhttp://example.com/foo/bar/bazN)r   r   r   Úsiblingr8   r   s    r   Útest_siblingStringÚ$_BaseURLPathTests.test_siblingStringp   s‰   € ð
 	×Ñœ˜TŸY™Y×.Ñ.¨vÓ6Ó7Ð9UÔVØ×ÑÜ�—	‘	×!Ñ! &°DÐ!Ð9Ó:Ø6ô	
ð 	×ÑÜ�—	‘	—‘ Ó$×,Ñ,¨VÓ4Ó5Ð7Wõ	
r   c                 ó¬  • U R                  [        U R                  R                  5       5      S5        U R                  [        U R                  R                  SS95      S5        U R                  [        U R                  R	                  S5      R                  5       5      S5        U R                  [        U R                  R	                  S5      R                  5       5      S5        U R                  [        U R                  R                  5       R                  5       R                  5       R                  5       R                  5       5      S5        g)	zx
Calling C{str()} with a C{URLPath.parent()} will return a URL which is
the parent of the URL it was instantiated with.
zhttp://example.com/Tr6   z!http://example.com/?yes=no&no=yesr   úhttp://example.com/foo/r<   N)r   r   r   Úparentr8   r   s    r   Útest_parentStringÚ#_BaseURLPathTests.test_parentStringƒ   sû   € ð 	×Ñœ˜TŸY™Y×-Ñ-Ó/Ó0Ð2GÔHØ×ÑÜ�—	‘	× Ñ ¨4Ð Ð0Ó1Ð3Vô	
ð 	×Ñœ˜TŸY™YŸ_™_¨SÓ1×8Ñ8Ó:Ó;Ð=VÔWØ×ÑÜ�—	‘	—‘ Ó'×.Ñ.Ó0Ó1Ð3Lô	
ð 	×ÑÜ�—	‘	× Ñ Ó"×)Ñ)Ó+×2Ñ2Ó4×;Ñ;Ó=×DÑDÓFÓGØ!õ	
r   c                 óR  • U R                  [        U R                  R                  5       5      S5        U R                  [        U R                  R                  SS95      S5        U R                  [        U R                  R	                  S5      R                  5       5      S5        g)z“
Calling C{str()} with a C{URLPath.here()} will return a URL which is
the URL that it was instantiated with, without any file, query, or
fragment.
rA   Tr6   z%http://example.com/foo/?yes=no&no=yesr   zhttp://example.com/foo/bar/N)r   r   r   Úherer8   r   s    r   Útest_hereStringÚ!_BaseURLPathTests.test_hereString—   s~   € ð 	×Ñœ˜TŸY™YŸ^™^Ó-Ó.Ð0IÔJØ×ÑÜ�—	‘	—‘¨�Ð.Ó/Ð1Xô	
ð 	×ÑÜ�—	‘	—‘ Ó$×)Ñ)Ó+Ó,Ð.Kõ	
r   c                 óŠ   • U R                  [        U R                  R                  S5      5      R	                  S5      S5        g)zÊ
Calling L{urlpath.URLPath.click} on a L{urlpath.URLPath} with a
trailing slash with a relative URL containing a leading slash will
result in a URL with a single slash at the start of the path portion.
s   /hello/worldr'   s   http://example.com/hello/worldN)r   r   r   Úclickr(   r   s    r   Útest_doubleSlashÚ"_BaseURLPathTests.test_doubleSlash¦   s5   € ð 	×ÑÜ�—	‘	—‘ Ó0Ó1×8Ñ8¸ÓAØ-õ	
r   c                 ób  • U R                  U R                  R                  S5      R                  5       / SQ5        U R                  U R                  R                  S5      R                  SS9/ SQ5        U R                  U R                  R                  S5      R                  SS9/ SQ5        g)	z<
L{urlpath.URLPath.pathList} returns a L{list} of L{bytes}.
ó	   %00%01%02)r   ó   fooó   barrN   F)ÚcopyT)Úunquote)r   rO   rP   s    N)r   r   r8   ÚpathListr   s    r   Útest_pathListÚ_BaseURLPathTests.test_pathList±   s�   € ð 	×ÑØ�I‰I�O‰O˜LÓ)×2Ñ2Ó4Ú/ô	
ð 	×ÑØ�I‰I�O‰O˜LÓ)×2Ñ2¸Ð2Ð>Ú/ô	
ð 	×ÑØ�I‰I�O‰O˜LÓ)×2Ñ2¸4Ð2Ð@Ú2õ	
r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r#   r,   r/   r3   r9   r>   rC   rG   rK   rT   Ú__static_attributes__rV   r   r   r   r      sJ   † ñò9ò9ð 25ô "
òHBò9ò
ò
ò"
ò&
ò(
ò	
õ
r   r   c                   ó6   • \ rS rSrSrS rS rS rS rS r	Sr
g	)
ÚBytesURLPathTestséÈ   zD
Tests for interacting with a L{URLPath} created with C{fromBytes}.
c                 óL   • [         R                  R                  S5      U l        g )Ns/   http://example.com/foo/bar?yes=no&no=yes#footer)r   ÚURLPathÚ	fromBytesr   r   s    r   ÚsetUpÚBytesURLPathTests.setUpÍ   s   € Ü—O‘O×-Ñ-Ø>ó
ˆ�	r   c                 ó<  • U R                  [        5         [        R                  R	                  S5        SSS5        U R                  [        5         [        R                  R	                  S5        SSS5        g! , (       d  f       NL= f! , (       d  f       g= f)z5
L{URLPath.fromBytes} must take a L{bytes} argument.
NÚsomeurl)ÚassertRaisesÚ
ValueErrorr   ra   rb   r   s    r   Útest_mustBeBytesÚ"BytesURLPathTests.test_mustBeBytesÒ   se   € ð ×ÑœzÕ*Ü�O‰O×%Ñ% dÔ+÷ +ð ×ÑœzÕ*Ü�O‰O×%Ñ% iÔ0÷ +Ð*÷ +Õ*ú÷ +Õ*úó   – A<Á BÁ<
B
Â
Bc                 ód   • [         R                  " 5       nU R                  [        U5      S5        g)zX
An instantiation with no arguments creates a usable L{URLPath} with
default arguments.
zhttp://localhost/N)r   ra   r   r   ©r   Úurls     r   Útest_withoutArgumentsÚ'BytesURLPathTests.test_withoutArgumentsÜ   s%   € ô
 �oŠoÓˆØ×Ñœ˜S›Ð#6Õ7r   c                 ó�  • [         R                  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                  S5        U R                  UR                  S5        U R                  [        U5      S5        g)zq
Leaving some optional arguments unfilled makes a L{URLPath} with those
optional arguments filled with defaults.
s   http://google.coms   https
   google.comó   /r   zhttp://google.com/N)
r   ra   rb   r   r   r   r   r   r   r   rm   s     r   Útest_partialArgumentsÚ'BytesURLPathTests.test_partialArgumentsä   s’   € ô �o‰o×'Ñ'Ð(<Ó=ˆØ×Ñ˜Ÿ™ WÔ-Ø×Ñ˜Ÿ™ ]Ô3Ø×Ñ˜Ÿ™ 4Ô(Ø×Ñ˜Ÿ™ sÔ+Ø×Ñ˜Ÿ™ CÔ(Ø×Ñœ˜S›Ð#7Õ8r   c                 óx   • [         R                  R                  S5      nU R                  [	        U5      S5        g)zG
L{URLPath.fromBytes} can interpret non-ASCII bytes as percent-encoded
s   http://example.com/ÿ zhttp://example.com/%FF%00N)r   ra   rb   r   r   rm   s     r   Útest_nonASCIIBytesÚ$BytesURLPathTests.test_nonASCIIBytesó   s.   € ô �o‰o×'Ñ'Ð(FÓGˆØ×Ñœ˜S›Ð#>Õ?r   ©r   N)rW   rX   rY   rZ   r[   rc   ri   ro   rs   rv   r\   rV   r   r   r^   r^   È   s!   † ñò
ò
1ò8ò9õ@r   r^   c                   ó$   • \ rS rSrSrS rS rSrg)ÚStringURLPathTestséû   ú[
Tests for interacting with a L{URLPath} created with C{fromString} and a
L{str} argument.
c                 óL   • [         R                  R                  S5      U l        g ©Nr2   ©r   ra   Ú
fromStringr   r   s    r   rc   ÚStringURLPathTests.setUp  ó   € Ü—O‘O×.Ñ.Ø=ó
ˆ�	r   c                 ó<  • U R                  [        5         [        R                  R	                  S5        SSS5        U R                  [        5         [        R                  R	                  S5        SSS5        g! , (       d  f       NL= f! , (       d  f       g= f)z>
C{URLPath.fromString} must take a L{str} or L{str} argument.
Ns   someurl)rg   rh   r   ra   r€   r   s    r   Útest_mustBeStrÚ!StringURLPathTests.test_mustBeStr  se   € ð ×ÑœzÕ*Ü�O‰O×&Ñ& tÔ,÷ +ð ×ÑœzÕ*Ü�O‰O×&Ñ& zÔ2÷ +Ð*÷ +Õ*ú÷ +Õ*úrk   rx   N)rW   rX   rY   rZ   r[   rc   r„   r\   rV   r   r   rz   rz   û   s   † ñò

õ
3r   rz   c                   ó$   • \ rS rSrSrS rS rSrg)ÚUnicodeURLPathTestsi  r|   c                 óL   • [         R                  R                  S5      U l        g r~   r   r   s    r   rc   ÚUnicodeURLPathTests.setUp  r‚   r   c                 óx   • [         R                  R                  S5      nU R                  [	        U5      S5        g)z6
L{URLPath.fromString} can load non-ASCII characters.
u   http://example.com/Ã¿ zhttp://example.com/%C3%BF%00N)r   ra   r€   r   r   rm   s     r   Útest_nonASCIICharactersÚ+UnicodeURLPathTests.test_nonASCIICharacters  s.   € ô �o‰o×(Ñ(Ð)FÓGˆØ×Ñœ˜S›Ð#AÕBr   rx   N)rW   rX   rY   rZ   r[   rc   r‹   r\   rV   r   r   r‡   r‡     s   † ñò

õ
Cr   r‡   N)
r[   Útwisted.pythonr   Útwisted.trialr   r   ÚTestCaser^   rz   r‡   rV   r   r   Ú<module>r�      sc   ðñ
õ #Ý "÷x
ñ x
ôv0@Ð)¨8×+<Ñ+<ô 0@ôf3Ð*¨H×,=Ñ,=ô 3ô,CÐ+¨X×->Ñ->õ Cr   