§
    Ètºfå'  ã                   ó´   — 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	dS )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dS )Ú_BaseURLPathTestsz5
    Tests for instantiated L{urlpath.URLPath}s.
    c                 óx  — |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         dS )zQ
        All of the attributes of L{urlpath.URLPath} should be L{bytes}.
        N©ÚassertIsInstanceÚpathÚschemeÚbytesÚnetlocÚqueryÚfragment©Úselfs    ú_/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/python/test/test_urlpath.pyÚtest_partsAreBytesz$_BaseURLPathTests.test_partsAreBytes   ó�   € ð 	×Ò˜dœiÔ.µÑ6Ô6Ð6Ø×Ò˜dœiÔ.µÑ6Ô6Ð6Ø×Ò˜dœiœn­eÑ4Ô4Ð4Ø×Ò˜dœiœo­uÑ5Ô5Ð5Ø×Ò˜dœiÔ0µ%Ñ8Ô8Ð8Ð8Ð8ó    c                 ó„   — |                       t          | j                             ¦   «         ¦  «        t          ¦  «         dS )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   s6   € ð 	×Ò�˜dœi×/Ò/Ñ1Ô1Ñ2Ô2µCÑ8Ô8Ð8Ð8Ð8r   c                 óh  —  |d¦  «        | j         _        |                      t          | j         ¦  «        d¦  «          |d¦  «        | j         _        |                      t          | j         ¦  «        d¦  «          |d¦  «        | j         _         |                      t          | j         ¦  «        d¦  «          |d¦  «        | j         _        |                      t          | j         ¦  «        d¦  «          |d	¦  «        | j         _        |                      t          | j         ¦  «        d
¦  «         dS )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ñ	
ô 	
ð 	
ð &˜:Ð&?Ñ@Ô@ˆŒ	ÔØ×ÒÝ�”	‰NŒNØJñ	
ô 	
ð 	
ð $˜ HÑ-Ô-ˆŒ	ŒØ×ÒÝ�”	‰NŒNÐXñ	
ô 	
ð 	
ð %˜*Ð%AÑBÔBˆŒ	ŒØ×ÒÝ�”	‰NŒNðñ	
ô 	
ð 	
ð
 (˜Z¨Ñ1Ô1ˆŒ	ÔØ×ÒÝ�”	‰NŒNðñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó2   — |                       d„ ¦  «         dS )zC
        Same as L{test_mutabilityWithText} but for bytes.
        c                 ó,   — |                       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"   € ð 	×$Ò$Ð%@Ð%@ÑAÔAÐAÐAÐAr   c                 óx  — |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         |                       | j        j        t          ¦  «         dS )z<
        A created L{URLPath} has bytes attributes.
        Nr   r   s    r   Útest_allAttributesAreBytesz,_BaseURLPathTests.test_allAttributesAreBytesL   r   r   c                 óV   — |                       t          | j        ¦  «        d¦  «         dS )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   s4   € ð
 	×ÒÝ�”	‰NŒNÐMñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó’  — |                       t          | j                             d¦  «        ¦  «        d¦  «         |                       t          | j                             d¦  «                             d¦  «        ¦  «        d¦  «         |                       t          | j                             dd¬¦  «        ¦  «        d¦  «         dS )	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Ô4Ñ5Ô5Ø/ñ	
ô 	
ð 	
ð 	×ÒÝ�”	—’ °D�Ñ9Ô9Ñ:Ô:Ø<ñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó’  — |                       t          | j                             d¦  «        ¦  «        d¦  «         |                       t          | j                             dd¬¦  «        ¦  «        d¦  «         |                       t          | j                             d¦  «                             d¦  «        ¦  «        d¦  «         dS )	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×.Ò.¨vÑ6Ô6Ñ7Ô7Ð9UÑVÔVÐVØ×ÒÝ�”	×!Ò! &°DÐ!Ñ9Ô9Ñ:Ô:Ø6ñ	
ô 	
ð 	
ð 	×ÒÝ�”	—’ Ñ$Ô$×,Ò,¨VÑ4Ô4Ñ5Ô5Ð7Wñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó*  — |                       t          | j                             ¦   «         ¦  «        d¦  «         |                       t          | j                             d¬¦  «        ¦  «        d¦  «         |                       t          | j                             d¦  «                             ¦   «         ¦  «        d¦  «         |                       t          | j                             d¦  «                             ¦   «         ¦  «        d¦  «         |                       t          | j                             ¦   «                              ¦   «                              ¦   «                              ¦   «                              ¦   «         ¦  «        d¦  «         dS )	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ƒ   sU  € ð 	×Ò�˜TœY×-Ò-Ñ/Ô/Ñ0Ô0Ð2GÑHÔHÐHØ×ÒÝ�”	× Ò ¨4Ð Ñ0Ô0Ñ1Ô1Ð3Vñ	
ô 	
ð 	
ð 	×Ò�˜TœYŸ_š_¨SÑ1Ô1×8Ò8Ñ:Ô:Ñ;Ô;Ð=VÑWÔWÐWØ×ÒÝ�”	—’ Ñ'Ô'×.Ò.Ñ0Ô0Ñ1Ô1Ð3Lñ	
ô 	
ð 	
ð 	×ÒÝ�”	× Ò Ñ"Ô"×)Ò)Ñ+Ô+×2Ò2Ñ4Ô4×;Ò;Ñ=Ô=×DÒDÑFÔFÑGÔGØ!ñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óŒ  — |                       t          | j                             ¦   «         ¦  «        d¦  «         |                       t          | j                             d¬¦  «        ¦  «        d¦  «         |                       t          | j                             d¦  «                             ¦   «         ¦  «        d¦  «         dS )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Ÿ^š^Ñ-Ô-Ñ.Ô.Ð0IÑJÔJÐJØ×ÒÝ�”	—’¨�Ñ.Ô.Ñ/Ô/Ð1Xñ	
ô 	
ð 	
ð 	×ÒÝ�”	—’ Ñ$Ô$×)Ò)Ñ+Ô+Ñ,Ô,Ð.Kñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó¢   — |                       t          | j                             d¦  «        ¦  «                             d¦  «        d¦  «         dS )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¦   sP   € ð 	×ÒÝ�”	—’ Ñ0Ô0Ñ1Ô1×8Ò8¸ÑAÔAØ-ñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óš  — |                       | j                             d¦  «                             ¦   «         g d¢¦  «         |                       | j                             d¦  «                             d¬¦  «        g d¢¦  «         |                       | j                             d¦  «                             d¬¦  «        g d¢¦  «         dS )	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�OŠO˜LÑ)Ô)×2Ò2Ñ4Ô4Ø/Ð/Ð/ñ	
ô 	
ð 	
ð 	×ÒØŒI�OŠO˜LÑ)Ô)×2Ò2¸Ð2Ñ>Ô>Ø/Ð/Ð/ñ	
ô 	
ð 	
ð 	×ÒØŒI�OŠO˜LÑ)Ô)×2Ò2¸4Ð2Ñ@Ô@Ø2Ð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      sà   € € € € € ðð ð9ð 9ð 9ð9ð 9ð 9ð 25ð "
ð "
ð "
ð "
ðHBð Bð Bð9ð 9ð 9ð
ð 
ð 
ð
ð 
ð 
ð"
ð 
ð 
ð&
ð 
ð 
ð(
ð 
ð 
ð	
ð 	
ð 	
ð
ð 
ð 
ð 
ð 
r   r   c                   ó0   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚBytesURLPathTestszL
    Tests for interacting with a L{URLPath} created with C{fromBytes}.
    c                 óN   — t           j                             d¦  «        | _        d S )Ns/   http://example.com/foo/bar?yes=no&no=yes#footer)r   ÚURLPathÚ	fromBytesr
   r   s    r   ÚsetUpzBytesURLPathTests.setUpÍ   s"   € Ý”O×-Ò-Ø>ñ
ô 
ˆŒ	ˆ	ˆ	r   c                 óL  — |                       t          ¦  «        5  t          j                             d¦  «         ddd¦  «         n# 1 swxY w Y   |                       t          ¦  «        5  t          j                             d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zE
        L{URLPath.fromBytes} must take a L{bytes} argument.
        NÚsomeurl)ÚassertRaisesÚ
ValueErrorr   rP   rQ   r   s    r   Útest_mustBeBytesz"BytesURLPathTests.test_mustBeBytesÒ   s  € ð ×Ò�zÑ*Ô*ð 	,ð 	,ÝŒO×%Ò% dÑ+Ô+Ð+ð	,ð 	,ð 	,ñ 	,ô 	,ð 	,ð 	,ð 	,ð 	,ð 	,ð 	,øøøð 	,ð 	,ð 	,ð 	,ð ×Ò�zÑ*Ô*ð 	1ð 	1ÝŒO×%Ò% iÑ0Ô0Ð0ð	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1ð 	1ð 	1ó#   › AÁAÁAÁ, BÂBÂ Bc                 ór   — t          j        ¦   «         }|                      t          |¦  «        d¦  «         dS )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Ü   s4   € õ
 ŒoÑÔˆØ×Ò�˜S™œÐ#6Ñ7Ô7Ð7Ð7Ð7r   c                 ó˜  — t           j                             d¦  «        }|                      |j        d¦  «         |                      |j        d¦  «         |                      |j        d¦  «         |                      |j        d¦  «         |                      |j        d¦  «         |                      t          |¦  «        d¦  «         dS )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×'Ò'Ð(<Ñ=Ô=ˆØ×Ò˜œ WÑ-Ô-Ð-Ø×Ò˜œ ]Ñ3Ô3Ð3Ø×Ò˜œ 4Ñ(Ô(Ð(Ø×Ò˜œ sÑ+Ô+Ð+Ø×Ò˜œ CÑ(Ô(Ð(Ø×Ò�˜S™œÐ#7Ñ8Ô8Ð8Ð8Ð8r   c                 óŠ   — t           j                             d¦  «        }|                      t	          |¦  «        d¦  «         dS )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×'Ò'Ð(FÑGÔGˆØ×Ò�˜S™œÐ#>Ñ?Ô?Ð?Ð?Ð?r   N)	rH   rI   rJ   rK   rR   rW   r\   r_   ra   rL   r   r   rN   rN   È   sn   € € € € € ðð ð
ð 
ð 
ð
1ð 1ð 1ð8ð 8ð 8ð9ð 9ð 9ð@ð @ð @ð @ð @r   rN   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚStringURLPathTestsúg
    Tests for interacting with a L{URLPath} created with C{fromString} and a
    L{str} argument.
    c                 óN   — t           j                             d¦  «        | _        d S ©Nr+   ©r   rP   Ú
fromStringr
   r   s    r   rR   zStringURLPathTests.setUp  ó"   € Ý”O×.Ò.Ø=ñ
ô 
ˆŒ	ˆ	ˆ	r   c                 óL  — |                       t          ¦  «        5  t          j                             d¦  «         ddd¦  «         n# 1 swxY w Y   |                       t          ¦  «        5  t          j                             d¦  «         ddd¦  «         dS # 1 swxY w Y   dS )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  s  € ð ×Ò�zÑ*Ô*ð 	-ð 	-ÝŒO×&Ò& tÑ,Ô,Ð,ð	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-ð ×Ò�zÑ*Ô*ð 	3ð 	3ÝŒO×&Ò& zÑ2Ô2Ð2ð	3ð 	3ð 	3ñ 	3ô 	3ð 	3ð 	3ð 	3ð 	3ð 	3ð 	3ð 	3øøøð 	3ð 	3ð 	3ð 	3ð 	3ð 	3rX   N)rH   rI   rJ   rK   rR   rk   rL   r   r   rc   rc   û   s<   € € € € € ðð ð

ð 
ð 
ð
3ð 3ð 3ð 3ð 3r   rc   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚUnicodeURLPathTestsrd   c                 óN   — t           j                             d¦  «        | _        d S rf   rg   r   s    r   rR   zUnicodeURLPathTests.setUp  ri   r   c                 óŠ   — t           j                             d¦  «        }|                      t	          |¦  «        d¦  «         dS )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×(Ò(Ð)FÑGÔGˆØ×Ò�˜S™œÐ#AÑBÔBÐBÐBÐBr   N)rH   rI   rJ   rK   rR   rp   rL   r   r   rm   rm     sA   € € € € € ðð ð

ð 
ð 
ð
Cð Cð Cð Cð Cr   rm   N)
rK   Útwisted.pythonr   Útwisted.trialr   r   ÚTestCaserN   rc   rm   rL   r   r   ú<module>rt      s  ðð
ð ð #Ð "Ð "Ð "Ð "Ð "Ø "Ð "Ð "Ð "Ð "Ð "ðx
ð x
ð x
ð x
ð x
ñ x
ô x
ð x
ðv0@ð 0@ð 0@ð 0@ð 0@Ð)¨8Ô+<ñ 0@ô 0@ð 0@ðf3ð 3ð 3ð 3ð 3Ð*¨HÔ,=ñ 3ô 3ð 3ð,Cð Cð Cð Cð CÐ+¨XÔ->ñ Cô Cð Cð Cð Cr   