HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/python/test/__pycache__/test_urlpath.cpython-38.pyc
U


W[X(�@sxdZddlmZddlmZddlmZGdd�de�ZGdd�deej	�Z
Gd	d
�d
eej	�ZGdd�deej	�Zd
S)z&
Tests for L{twisted.python.urlpath}.
�)�unittest)�urlpath)�_PY3c@sxeZdZdZdd�Zdd�Zed�fdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�_BaseURLPathTestsz5
    Tests for instantiated L{urlpath.URLPath}s.
    cCsT|�|jjt�|�|jjt�|�|jjt�|�|jjt�|�|jjt�dS)zQ
        All of the attributes of L{urlpath.URLPath} should be L{bytes}.
        N�ZassertIsInstance�path�scheme�bytes�netloc�query�fragment��self�r�B/usr/lib/python3/dist-packages/twisted/python/test/test_urlpath.py�test_partsAreBytess
z$_BaseURLPathTests.test_partsAreBytescCs|�t|j���t�dS)zQ
        Calling C{str()} with a L{URLPath} will always return a L{str}.
        N)�assertEqual�typer�__str__�strr
rrr�test_strReturnsStrsz$_BaseURLPathTests.test_strReturnsStr�cCs�|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
�dS)aC
        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{unicode} and returning
            L{str} or L{bytes}.
        Zhttpsz0https://example.com/foo/bar?yes=no&no=yes#footerzanother.example.invalidz<https://another.example.invalid/foo/bar?yes=no&no=yes#footerz/helloz:https://another.example.invalid/hello?yes=no&no=yes#footerzalpha=omega&opposites=samezGhttps://another.example.invalid/hello?alpha=omega&opposites=same#footer�headerzGhttps://another.example.invalid/hello?alpha=omega&opposites=same#headerN)rrrrr
rr)rZ
stringTyperrr�test_mutabilityWithText$s2
�����z)_BaseURLPathTests.test_mutabilityWithTextcCs|�dd��dS)zC
        Same as L{test_mutabilityWithText} but for bytes.
        cSs
|�d�S)N�ascii)�encode)�xrrr�<lambda>J�z<_BaseURLPathTests.test_mutabilityWithBytes.<locals>.<lambda>N)rr
rrr�test_mutabilityWithBytesFsz*_BaseURLPathTests.test_mutabilityWithBytescCsT|�|jjt�|�|jjt�|�|jjt�|�|jjt�|�|jjt�dS)z<
        A created L{URLPath} has bytes attributes.
        Nrr
rrr�test_allAttributesAreBytesMs
z,_BaseURLPathTests.test_allAttributesAreBytescCs|�t|j�d�dS)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)rrrr
rrr�test_stringConversionXs�z'_BaseURLPathTests.test_stringConversioncCsV|�t|j�d��d�|�t|j�d��d��d�|�t|jjddd��d�dS)	z�
        Calling C{str()} with a C{URLPath.child()} will return a URL which is
        the child of the URL it was instantiated with.
        shelloz http://example.com/foo/bar/hellorz!http://example.com/foo/bar/hello/T�Z	keepQueryz.http://example.com/foo/bar/hello?yes=no&no=yesN)rrr�childr
rrr�test_childStringas���z"_BaseURLPathTests.test_childStringcCsV|�t|j�d��d�|�t|jjddd��d�|�t|j�d��d��d�dS)	z�
        Calling C{str()} with a C{URLPath.sibling()} will return a URL which is
        the sibling of the URL it was instantiated with.
        �bazzhttp://example.com/foo/bazTr#z(http://example.com/foo/baz?yes=no&no=yesrzhttp://example.com/foo/bar/bazN)rrrZsiblingr$r
rrr�test_siblingStringns���z$_BaseURLPathTests.test_siblingStringcCs�|�t|j���d�|�t|jjdd��d�|�t|j�d����d�|�t|j�d����d�|�t|j�����������d�dS)	z�
        Calling C{str()} with a C{URLPath.parent()} will return a URL which is
        the parent of the URL it was instantiated with.
        zhttp://example.com/Tr#z!http://example.com/?yes=no&no=yesr�http://example.com/foo/r&N)rrr�parentr$r
rrr�test_parentString�s �����z#_BaseURLPathTests.test_parentStringcCsP|�t|j���d�|�t|jjdd��d�|�t|j�d����d�dS)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.
        r(Tr#z%http://example.com/foo/?yes=no&no=yesrzhttp://example.com/foo/bar/N)rrr�herer$r
rrr�test_hereString�s��z!_BaseURLPathTests.test_hereStringcCs"|�t|j�d���d�d�dS)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/worldrshttp://example.com/hello/worldN)rrrZclickrr
rrr�test_doubleSlash�s�z"_BaseURLPathTests.test_doubleSlashcCsl|�|j�d���ddddg�|�|j�d�jdd�ddddg�|�|j�d�jdd�dddd	g�d
S)zL
        L{urlpath.URLPath.pathList} returns a L{list} of L{bytes}.
        s	%00%01%02rsfoosbarF)�copyT)ZunquotesN)rrr$ZpathListr
rrr�
test_pathList�s
�	
�
�z_BaseURLPathTests.test_pathListN)�__name__�
__module__�__qualname__�__doc__rrrrrr r"r%r'r*r,r-r/rrrrrs"	
rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�BytesURLPathTestszL
    Tests for interacting with a L{URLPath} created with C{fromBytes}.
    cCstj�d�|_dS)Ns/http://example.com/foo/bar?yes=no&no=yes#footer)r�URLPath�	fromBytesrr
rrr�setUp�s�zBytesURLPathTests.setUpc	CsH|�t��tj�d�W5QRX|�t��tj�d�W5QRXdS)zE
        L{URLPath.fromBytes} must take a L{bytes} argument.
        NZsomeurl)�assertRaises�
ValueErrorrr5r6r
rrr�test_mustBeBytes�sz"BytesURLPathTests.test_mustBeBytescCst��}|�t|�d�dS)zp
        An instantiation with no arguments creates a usable L{URLPath} with
        default arguments.
        zhttp://localhost/N)rr5rr�rZurlrrr�test_withoutArguments�sz'BytesURLPathTests.test_withoutArgumentscCsftj�d�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�t	|�d�dS)z�
        Leaving some optional arguments unfilled makes a L{URLPath} with those
        optional arguments filled with defaults.
        shttp://google.comshttps
google.com�/rzhttp://google.com/N)
rr5r6rrr
rrrrr;rrr�test_partialArguments�sz'BytesURLPathTests.test_partialArgumentscCs tj�d�}|�t|�d�dS)zW
        L{URLPath.fromBytes} can interpret non-ASCII bytes as percent-encoded
        shttp://example.com/�zhttp://example.com/%FF%00N)rr5r6rrr;rrr�test_nonASCIIBytes�sz$BytesURLPathTests.test_nonASCIIBytesN)	r0r1r2r3r7r:r<r>r?rrrrr4�s	r4c@s eZdZdZdd�Zdd�ZdS)�StringURLPathTestszg
    Tests for interacting with a L{URLPath} created with C{fromString} and a
    L{str} argument.
    cCstj�d�|_dS�Nr!�rr5�
fromStringrr
rrrr7s�zStringURLPathTests.setUpc	CsL|�t��tj�d�W5QRXtrH|�t��tj�d�W5QRXdS)zR
        C{URLPath.fromString} must take a L{str} or L{unicode} argument.
        Nssomeurl)r8r9rr5rCrr
rrr�test_mustBeStrs
z!StringURLPathTests.test_mustBeStrN)r0r1r2r3r7rDrrrrr@�sr@c@s eZdZdZdd�Zdd�ZdS)�UnicodeURLPathTestszk
    Tests for interacting with a L{URLPath} created with C{fromString} and a
    L{unicode} argument.
    cCstj�d�|_dSrArBr
rrrr7s�zUnicodeURLPathTests.setUpcCs tj�d�}|�t|�d�dS)zF
        L{URLPath.fromString} can load non-ASCII characters.
        uhttp://example.com/ÿzhttp://example.com/%C3%BF%00N)rr5rCrrr;rrr�test_nonASCIICharacterssz+UnicodeURLPathTests.test_nonASCIICharactersN)r0r1r2r3r7rFrrrrrEsrEN)
r3Z
twisted.trialrZtwisted.pythonrZtwisted.python.compatr�objectrZTestCaser4r@rErrrr�<module>s96