Ë
    ojå'  ã                   ó¸   — d Z ddlmZ ddlmZ  G d„ d«      Z G d„ deej                  «      Z G d„ d	eej                  «      Z G d
„ deej                  «      Z	y)z&
Tests for L{twisted.python.urlpath}.
é    )Úurlpath)Úunittestc                   ó\   — e Zd ZdZd„ Zd„ Zefd„Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zy)Ú_BaseURLPathTestsz5
    Tests for instantiated L{urlpath.URLPath}s.
    c                 ó¨  — | j                  | j                  j                  t        «       | j                  | j                  j                  t        «       | j                  | j                  j                  t        «       | j                  | j                  j
                  t        «       | j                  | j                  j                  t        «       y)zQ
        All of the attributes of L{urlpath.URLPath} should be L{bytes}.
        N©ÚassertIsInstanceÚpathÚschemeÚbytesÚnetlocÚqueryÚfragment©Úselfs    úB/usr/lib/python3/dist-packages/twisted/python/test/test_urlpath.pyÚtest_partsAreBytesz$_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   — | j                  t        | j                  j                  «       «      t        «       y)zQ
        Calling C{str()} with a L{URLPath} will always return a L{str}.
        N)ÚassertEqualÚtyper
   Ú__str__Ústrr   s    r   Útest_strReturnsStrz$_BaseURLPathTests.test_strReturnsStr   s&   € ð 	×Ñœ˜dŸi™i×/Ñ/Ó1Ó2´CÕ8r   c                 ó\  —  |d«      | j                   _        | j                  t        | j                   «      d«        |d«      | j                   _        | j                  t        | j                   «      d«        |d«      | j                   _         | j                  t        | j                   «      d«        |d«      | j                   _        | j                  t        | j                   «      d«        |d	«      | j                   _        | j                  t        | j                   «      d
«       y)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_mutabilityWithTextz)_BaseURLPathTests.test_mutabilityWithText"   sñ   € ñ & gÓ.ˆ�	‰	ÔØ×ÑÜ�—	‘	‹NÐNô	
ñ &Ð&?Ó@ˆ�	‰	ÔØ×ÑÜ�—	‘	‹NØJô	
ñ $ HÓ-ˆ�	‰	ŒØ×ÑÜ�—	‘	‹NÐXô	
ñ %Ð%AÓBˆ�	‰	ŒØ×ÑÜ�—	‘	‹Nðô	
ñ
 (¨Ó1ˆ�	‰	ÔØ×ÑÜ�—	‘	‹Nðõ	
r   c                 ó(   — | j                  d„ «       y)zC
        Same as L{test_mutabilityWithText} but for bytes.
        c                 ó$   — | j                  d«      S )NÚascii)Úencode)Úxs    r   ú<lambda>z<_BaseURLPathTests.test_mutabilityWithBytes.<locals>.<lambda>J   s   € ¨q¯x©x¸Ó/@€ r   N)r    r   s    r   Útest_mutabilityWithBytesz*_BaseURLPathTests.test_mutabilityWithBytesF   s   € ð 	×$Ñ$Ñ%@ÕAr   c                 ó¨  — | j                  | j                  j                  t        «       | j                  | j                  j                  t        «       | j                  | j                  j                  t        «       | j                  | j                  j
                  t        «       | j                  | j                  j                  t        «       y)z<
        A created L{URLPath} has bytes attributes.
        Nr   r   s    r   Útest_allAttributesAreBytesz,_BaseURLPathTests.test_allAttributesAreBytesL   r   r   c                 óN   — | j                  t        | j                  «      d«       y)zs
        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_stringConversionz'_BaseURLPathTests.test_stringConversionV   s    € ð
 	×ÑÜ�—	‘	‹NÐMõ	
r   c                 ó^  — | j                  t        | j                  j                  d«      «      d«       | j                  t        | j                  j                  d«      j                  d«      «      d«       | j                  t        | j                  j                  dd¬«      «      d«       y)	zŽ
        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_childStringz"_BaseURLPathTests.test_childString_   s‰   € ð
 	×ÑÜ�—	‘	—‘ Ó)Ó*Ð,Nô	
ð 	×ÑÜ�—	‘	—‘ Ó)×/Ñ/°Ó4Ó5Ø/ô	
ð 	×ÑÜ�—	‘	—‘ °D�Ó9Ó:Ø<õ	
r   c                 ó^  — | j                  t        | j                  j                  d«      «      d«       | j                  t        | j                  j                  dd¬«      «      d«       | j                  t        | j                  j	                  d«      j                  d«      «      d«       y)	z’
        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/bazTr.   z(http://example.com/foo/baz?yes=no&no=yesr   zhttp://example.com/foo/bar/bazN)r   r   r
   Úsiblingr0   r   s    r   Útest_siblingStringz$_BaseURLPathTests.test_siblingStringp   s‰   € ð
 	×Ñœ˜TŸY™Y×.Ñ.¨vÓ6Ó7Ð9UÔVØ×ÑÜ�—	‘	×!Ñ! &°DÐ!Ó9Ó:Ø6ô	
ð 	×ÑÜ�—	‘	—‘ Ó$×,Ñ,¨VÓ4Ó5Ð7Wõ	
r   c                 ó²  — | j                  t        | j                  j                  «       «      d«       | j                  t        | j                  j                  d¬«      «      d«       | j                  t        | j                  j	                  d«      j                  «       «      d«       | j                  t        | j                  j	                  d«      j                  «       «      d«       | j                  t        | j                  j                  «       j                  «       j                  «       j                  «       j                  «       «      d«       y)	z�
        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/Tr.   z!http://example.com/?yes=no&no=yesr   úhttp://example.com/foo/r3   N)r   r   r
   Úparentr0   r   s    r   Útest_parentStringz#_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                 óX  — | j                  t        | j                  j                  «       «      d«       | j                  t        | j                  j                  d¬«      «      d«       | j                  t        | j                  j	                  d«      j                  «       «      d«       y)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.
        r7   Tr.   z%http://example.com/foo/?yes=no&no=yesr   zhttp://example.com/foo/bar/N)r   r   r
   Úherer0   r   s    r   Útest_hereStringz!_BaseURLPathTests.test_hereString—   s~   € ð 	×Ñœ˜TŸY™YŸ^™^Ó-Ó.Ð0IÔJØ×ÑÜ�—	‘	—‘¨�Ó.Ó/Ð1Xô	
ð 	×ÑÜ�—	‘	—‘ Ó$×)Ñ)Ó+Ó,Ð.Kõ	
r   c                 óŠ   — | j                  t        | j                  j                  d«      «      j	                  d«      d«       y)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_doubleSlashz"_BaseURLPathTests.test_doubleSlash¦   s5   € ð 	×ÑÜ�—	‘	—‘ Ó0Ó1×8Ñ8¸ÓAØ-õ	
r   c                 ón  — | j                  | j                  j                  d«      j                  «       g d¢«       | j                  | j                  j                  d«      j                  d¬«      g d¢«       | j                  | j                  j                  d«      j                  d¬«      g d¢«       y)	zL
        L{urlpath.URLPath.pathList} returns a L{list} of L{bytes}.
        ó	   %00%01%02)r   ó   fooó   barrA   F)ÚcopyT)Úunquote)r   rB   rC   s    N)r   r
   r0   ÚpathListr   s    r   Útest_pathListz_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__Ú__doc__r   r   r   r    r'   r)   r,   r1   r5   r9   r<   r?   rG   © r   r   r   r      sJ   „ ñò9ò9ð 25ó "
òHBò9ò
ò
ò"
ò&
ò(
ò	
ó
r   r   c                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚBytesURLPathTestszL
    Tests for interacting with a L{URLPath} created with C{fromBytes}.
    c                 óL   — t         j                  j                  d«      | _        y )Ns/   http://example.com/foo/bar?yes=no&no=yes#footer)r   ÚURLPathÚ	fromBytesr
   r   s    r   ÚsetUpzBytesURLPathTests.setUpÍ   s   € Ü—O‘O×-Ñ-Ø>ó
ˆ�	r   c                 ó(  — | j                  t        «      5  t        j                  j	                  d«       ddd«       | j                  t        «      5  t        j                  j	                  d«       ddd«       y# 1 sw Y   ŒGxY w# 1 sw Y   yxY w)zE
        L{URLPath.fromBytes} must take a L{bytes} argument.
        NÚsomeurl)ÚassertRaisesÚ
ValueErrorr   rP   rQ   r   s    r   Útest_mustBeBytesz"BytesURLPathTests.test_mustBeBytesÒ   su   € ð ×ÑœzÓ*ñ 	,Ü�O‰O×%Ñ% dÔ+÷	,ð ×ÑœzÓ*ñ 	1Ü�O‰O×%Ñ% iÔ0÷	1ð 	1÷	,ð 	,ú÷	1ð 	1úó   – A<Á BÁ<BÂBc                 ób   — t        j                  «       }| j                  t        |«      d«       y)zp
        An instantiation with no arguments creates a usable L{URLPath} with
        default arguments.
        zhttp://localhost/N)r   rP   r   r   ©r   Úurls     r   Útest_withoutArgumentsz'BytesURLPathTests.test_withoutArgumentsÜ   s%   € ô
 �o‰oÓˆØ×Ñœ˜S›Ð#6Õ7r   c                 ó�  — t         j                  j                  d«      }| j                  |j                  d«       | j                  |j
                  d«       | j                  |j                  d«       | j                  |j                  d«       | j                  |j                  d«       | j                  t        |«      d«       y)z‰
        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   rP   rQ   r   r   r   r
   r   r   r   rZ   s     r   Útest_partialArgumentsz'BytesURLPathTests.test_partialArgumentsä   s’   € ô �o‰o×'Ñ'Ð(<Ó=ˆØ×Ñ˜Ÿ™ WÔ-Ø×Ñ˜Ÿ™ ]Ô3Ø×Ñ˜Ÿ™ 4Ô(Ø×Ñ˜Ÿ™ sÔ+Ø×Ñ˜Ÿ™ CÔ(Ø×Ñœ˜S›Ð#7Õ8r   c                 óx   — t         j                  j                  d«      }| j                  t	        |«      d«       y)zW
        L{URLPath.fromBytes} can interpret non-ASCII bytes as percent-encoded
        s   http://example.com/ÿ zhttp://example.com/%FF%00N)r   rP   rQ   r   r   rZ   s     r   Útest_nonASCIIBytesz$BytesURLPathTests.test_nonASCIIBytesó   s.   € ô �o‰o×'Ñ'Ð(FÓGˆØ×Ñœ˜S›Ð#>Õ?r   N)	rH   rI   rJ   rK   rR   rW   r\   r_   ra   rL   r   r   rN   rN   È   s!   „ ñò
ò
1ò8ò9ó@r   rN   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚStringURLPathTestsúg
    Tests for interacting with a L{URLPath} created with C{fromString} and a
    L{str} argument.
    c                 óL   — t         j                  j                  d«      | _        y ©Nr+   ©r   rP   Ú
fromStringr
   r   s    r   rR   zStringURLPathTests.setUp  ó   € Ü—O‘O×.Ñ.Ø=ó
ˆ�	r   c                 ó(  — | j                  t        «      5  t        j                  j	                  d«       ddd«       | j                  t        «      5  t        j                  j	                  d«       ddd«       y# 1 sw Y   ŒGxY w# 1 sw Y   yxY w)zN
        C{URLPath.fromString} must take a L{str} or L{str} argument.
        Ns   someurl)rU   rV   r   rP   rh   r   s    r   Útest_mustBeStrz!StringURLPathTests.test_mustBeStr  su   € ð ×ÑœzÓ*ñ 	-Ü�O‰O×&Ñ& tÔ,÷	-ð ×ÑœzÓ*ñ 	3Ü�O‰O×&Ñ& zÔ2÷	3ð 	3÷	-ð 	-ú÷	3ð 	3úrX   N)rH   rI   rJ   rK   rR   rk   rL   r   r   rc   rc   û   s   „ ñò

ó
3r   rc   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚUnicodeURLPathTestsrd   c                 óL   — t         j                  j                  d«      | _        y rf   rg   r   s    r   rR   zUnicodeURLPathTests.setUp  ri   r   c                 óx   — t         j                  j                  d«      }| j                  t	        |«      d«       y)zF
        L{URLPath.fromString} can load non-ASCII characters.
        u   http://example.com/Ã¿ zhttp://example.com/%C3%BF%00N)r   rP   rh   r   r   rZ   s     r   Útest_nonASCIICharactersz+UnicodeURLPathTests.test_nonASCIICharacters  s.   € ô �o‰o×(Ñ(Ð)FÓGˆØ×Ñœ˜S›Ð#AÕBr   N)rH   rI   rJ   rK   rR   rp   rL   r   r   rm   rm     s   „ ñò

ó
Cr   rm   N)
rK   Útwisted.pythonr   Útwisted.trialr   r   ÚTestCaserN   rc   rm   rL   r   r   ú<module>rt      sc   ðñ
õ #Ý "÷x
ñ x
ôv0@Ð)¨8×+<Ñ+<ô 0@ôf3Ð*¨H×,=Ñ,=ô 3ô,CÐ+¨X×->Ñ->õ Cr   