%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_webclient.cpython-312.pyc

�

Ϫ�f.����dZddlmZddlmZddlmZGd�dej�ZGd�d�Z	Gd	�d
e	ej�Z
Gd�de	ej�ZGd
�de	ej�Zy)z)
Tests L{twisted.web.client} helper APIs
�)�urlparse)�unittest)�clientc��eZdZdZd�Zd�Zy)�URLJoinTestsz'
    Tests for L{client._urljoin}.
    c���|jtjdd�d�|jtjdd�d�|jtjdd�d�y)z�
        L{client._urljoin} does not include a fragment identifier in the
        resulting URL if neither the base nor the new path include a fragment
        identifier.
        �http://foo.com/bar�/quuxshttp://foo.com/quuxshttp://foo.com/bar#s/quux#N��assertEqualr�_urljoin��selfs �A/usr/lib/python3/dist-packages/twisted/web/test/test_webclient.py�test_noFragmentszURLJoinTests.test_noFragmentssh��	
����O�O�1�8�<�>T�	
�	
����O�O�2�H�=�?U�	
�	
����O�O�1�9�=�?U�	
�c���|jtjdd�d�|jtjdd�d�|jtjdd�d�y)a
        L{client._urljoin} preserves the fragment identifier from either the
        new path or the base URL respectively, as specified in the HTTP 1.1 bis
        draft.

        @see: U{https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-22#section-7.1.2}
        shttp://foo.com/bar#fragr
shttp://foo.com/quux#fragr	s/quux#frag2shttp://foo.com/quux#frag2Nrrs r�test_preserveFragmentsz#URLJoinTests.test_preserveFragments$sh��	
����O�O�6��A�'�	
�	
����O�O�1�>�B�(�	
�	
����O�O�6��G�(�	
rN)�__name__�
__module__�__qualname__�__doc__rr�rrrrs���
� 
rrc�t�eZdZdZd�Z	dd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zy)�URITestsa
    Abstract tests for L{twisted.web.client.URI}.

    Subclass this and L{unittest.TestCase}. Then provide a value for
    C{host} and C{uriHost}.

    @ivar host: A host specification for use in tests, must be L{bytes}.

    @ivar uriHost: The host specification in URI form, must be a L{bytes}. In
        most cases this is identical with C{host}. IPv6 address literals are an
        exception, according to RFC 3986 section 3.2.2, as they need to be
        enclosed in brackets. In this case this variable is different.
    c�
�|j|jt�|j|jt�|j|t�|j	d|�|jd|j�S)a�
        Replace the string "HOST" in C{template} with this test's host.

        Byte strings Python between (and including) versions 3.0 and 3.4
        cannot be formatted using C{%} or C{format} so this does a simple
        replace.

        @type template: L{bytes}
        @param template: A string containing "HOST".

        @rtype: L{bytes}
        @return: A string where "HOST" has been replaced by C{self.host}.
        sHOST)�assertIsInstance�host�bytes�uriHost�assertIn�replace)r�templates  r�
makeURIStringzURITests.makeURIStringIsa��	
���d�i�i��/����d�l�l�E�2����h��.��
�
�g�x�(��������6�6rc
���|j||||||||	f|j|j|j|j|j
|j|j|jf�y)aU
        Assert that all of a L{client.URI}'s components match the expected
        values.

        @param uri: U{client.URI} instance whose attributes will be checked
            for equality.

        @type scheme: L{bytes}
        @param scheme: URI scheme specifier.

        @type netloc: L{bytes}
        @param netloc: Network location component.

        @type host: L{bytes}
        @param host: Host name.

        @type port: L{int}
        @param port: Port number.

        @type path: L{bytes}
        @param path: Hierarchical path.

        @type params: L{bytes}
        @param params: Parameters for last path segment, defaults to C{b''}.

        @type query: L{bytes}
        @param query: Query string, defaults to C{b''}.

        @type fragment: L{bytes}
        @param fragment: Fragment identifier, defaults to C{b''}.
        N)	r�scheme�netlocr�port�path�params�query�fragment)
r�urir&r'rr(r)r*r+r,s
          r�assertURIEqualszURITests.assertURIEquals]sd��D	
���
�V�T�4��v�u�h�G��
�
��
�
�����������
�
��	�	����	
�	
rc��tjj|jd��}|j	d|j
�tjj|jd��}|j	d|j
�tjj|jd��}|j	d|j
�y)z�
        L{client.URI.fromBytes} by default assumes port 80 for the I{http}
        scheme and 443 for the I{https} scheme.
        �http://HOST�Pshttp://HOST:�https://HOSTi�N�r�URI�	fromBytesr$rr(�rr-s  r�test_parseDefaultPortzURITests.test_parseDefaultPort�s���
�j�j�"�"�4�#5�#5�n�#E�F������S�X�X�&��j�j�"�"�4�#5�#5�o�#F�G������S�X�X�&��j�j�"�"�4�#5�#5�o�#F�G������c�h�h�'rc�4�tjj|jd�d��}|j	d|j
�tjj|jd�d��}|j	d|j
�y)z�
        L{client.URI.fromBytes} accepts a C{defaultPort} parameter that
        overrides the normal default port logic.
        r0�)�defaultPortr2Nr3r6s  r�test_parseCustomDefaultPortz$URITests.test_parseCustomDefaultPort�s|��
�j�j�"�"�4�#5�#5�n�#E�SW�"�X������s�x�x�(��j�j�"�"�����/�T�#�
��	
����s�x�x�(rc���tjj|jd��}|j	d|j
�|j	|j|j�|j	|jdz|j�tjj|jd��}|j	|j|j�y)zj
        Parsing a I{URI} splits the network location component into I{host} and
        I{port}.
        shttp://HOST:5144r9s:5144shttp://HOST N)	rr4r5r$rr(rr r'r6s  r�test_netlocHostPortzURITests.test_netlocHostPort�s���
�j�j�"�"�4�#5�#5�6I�#J�K������s�x�x�(�������C�H�H�-��������0�#�*�*�=��j�j�"�"�4�#5�#5�o�#F�G��������s�z�z�2rc��|jd�}tjj|�}|j	|d|j
|jdd��|j||j��y)z/
        Parse the path from a I{URI}.
        shttp://HOST/foo/bar�httpr1�/foo/bar�r&r'rr(r)N�	r$rr4r5r.r rr�toBytes�rr-�parseds   r�	test_pathzURITests.test_path�so��� � �!7�8�����%�%�c�*��������<�<������
	�	
�	
����f�n�n�.�/rc��|jd�}tjj|�}|j	|d|j
|jdd��|j||j��y)zL
        The path of a I{URI} that has no path is the empty string.
        r0r?r1rrANrBrDs   r�test_noPathzURITests.test_noPath�sn��� � ��0�����%�%�c�*��������<�<������
	�	
�	
����f�n�n�.�/rc��|jd�}|jtjj	|�d|j
|jdd��y)zE
        The path of a I{URI} with an empty path is C{b'/'}.
        �http://HOST/r?r1�/rAN)r$r.rr4r5r rr6s  r�test_emptyPathzURITests.test_emptyPath�sP��� � ��1������J�J� � ��%���<�<������
	�	
rc	��|jd�}tjj|�}|j	|d|j
|jddd��|j||j��y)z8
        Parse I{URI} parameters from a I{URI}.
        shttp://HOST/foo/bar;paramr?r1r@�param)r&r'rr(r)r*NrBrDs   r�
test_paramzURITests.test_param�sr��� � �!=�>�����%�%�c�*��������<�<�������	�	
�	
����f�n�n�.�/rc
��|jd�}tjj|�}|j	|d|j
|jdddd��|j||j��y)	z7
        Parse the query string from a I{URI}.
        s!http://HOST/foo/bar;param?a=1&b=2r?r1r@rN�a=1&b=2)r&r'rr(r)r*r+NrBrDs   r�
test_queryzURITests.test_query�su��� � �!E�F�����%�%�c�*��������<�<��������	�		
�	
����f�n�n�.�/rc��|jd�}tjj|�}|j	|d|j
|jddddd��	|j||j��y	)
z>
        Parse the fragment identifier from a I{URI}.
        s&http://HOST/foo/bar;param?a=1&b=2#fragr?r1r@rNrQsfrag)r&r'rr(r)r*r+r,NrBrDs   r�
test_fragmentzURITests.test_fragmentsx��� � �!J�K�����%�%�c�*��������<�<���������	�
	
�	
����f�n�n�.�/rc��tjj|jd��}|j	d|j
�y)zn
        L{client.URI.originForm} produces an absolute I{URI} path including
        the I{URI} path.
        shttp://HOST/foos/fooN�rr4r5r$r�
originFormr6s  r�test_originFormzURITests.test_originForms8��
�j�j�"�"�4�#5�#5�6H�#I�J������#�.�.�1rc��tjj|jd��}|j	d|j
�y)z�
        L{client.URI.originForm} produces an absolute I{URI} path including
        the I{URI} path, parameters and query string but excludes the fragment
        identifier.
        shttp://HOST/foo;param?a=1#frags/foo;param?a=1NrVr6s  r�test_originFormComplexzURITests.test_originFormComplex s>���j�j�"�"����@�A�
��	
���*�C�N�N�;rc��tjj|jd��}|j	d|j
�y)zp
        L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
        specifies no path.
        r0rKNrVr6s  r�test_originFormNoPathzURITests.test_originFormNoPath+s7��
�j�j�"�"�4�#5�#5�n�#E�F������s�~�~�.rc��tjj|jd��}|j	d|j
�y)zv
        L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
        specifies an empty path.
        rJrKNrVr6s  r�test_originFormEmptyPathz!URITests.test_originFormEmptyPath3s7��
�j�j�"�"�4�#5�#5�o�#F�G������s�~�~�.rc�\�|jd�}|jd�}t|�tjj|�}|j
|jt�|j
|jt�|j
|jt�y)z�
        L{client.URI.fromBytes} parses the scheme, host, and path elements
        into L{bytes}, even when passed an URL which has previously been passed
        to L{urlparse} as a L{unicode} string.
        shttp://HOST/path�asciiN)r$�decoderrr4r5rr&rrr))r�	goodInput�badInputr-s    r� test_externalUnicodeInterferencez)URITests.test_externalUnicodeInterference;s}���&�&�':�;�	��#�#�G�,������j�j�"�"�9�-�����c�j�j�%�0����c�h�h��.����c�h�h��.rN)rrr)rrrrr$r.r7r;r=rFrHrLrOrRrTrXrZr\r^rdrrrrr:s_���7�*VY�.
�`(�
)�3�0� 0� 
�0�"0�$0�&2�	<�/�/�/rrc��eZdZdZdxZZy)�URITestsForHostnamez>
    Tests for L{twisted.web.client.URI} with host names.
    sexample.comN�rrrrr rrrrrfrfJs���$�#�G�drrfc��eZdZdZdxZZy)�URITestsForIPv4zG
    Tests for L{twisted.web.client.URI} with IPv4 host addresses.
    s192.168.1.67NrgrrrririRs���%�$�G�drric��eZdZdZdZdZd�Zy)�URITestsForIPv6z�
    Tests for L{twisted.web.client.URI} with IPv6 host addresses.

    IPv6 addresses must always be surrounded by square braces in URIs. No
    attempt is made to test without.
    sfe80::20c:29ff:fea4:c60s[fe80::20c:29ff:fea4:c60]c���tjjd�}|j|jd�|j|j
d�|j|j
�d�y)z�
        Brackets around IPv6 addresses are stripped in the host field. The host
        field is then exported with brackets in the output of
        L{client.URI.toBytes}.
        shttp://[::1]:80/index.htmls::1s[::1]:80N)rr4r5rrr'rCr6s  r�"test_hostBracketIPv6AddressLiteralz2URITestsForIPv6.test_hostBracketIPv6AddressLiteralesX���j�j�"�"�#@�A��������6�*�������[�1��������(E�FrN)rrrrrr rmrrrrkrkZs���&�D�*�G�
GrrkN)
r�urllib.parser�
twisted.trialr�twisted.webr�TestCaserrrfrirkrrr�<module>rrss���
"�"��(
�8�$�$�(
�VM/�M/�`$�(�H�$5�$5�$�%�h�� 1� 1�%�G�h�� 1� 1�Gr

Zerion Mini Shell 1.0