%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�fmu���dZddlmZddlmZddlmZddlmZddlm	Z	dZ
d	Zgd
�Zd�Z
Gd�d
e�ZGd�de�ZGd�de�Zy)z"
Tests for L{twisted.python.url}.
�)�annotations)�Iterable)�Protocol)�SynchronousTestCase���URL�*http://www.foo.com/a/nice/path/?zot=23&zut�http://a/b/c/d;p?q)()�g�http://a/b/c/g)z./gr
)zg/�http://a/b/c/g/)z/g�
http://a/g)z//gzhttp://g)z?yzhttp://a/b/c/d;p?y)zg?yzhttp://a/b/c/g?y)z#szhttp://a/b/c/d;p?q#s)zg#szhttp://a/b/c/g#s)zg?y#szhttp://a/b/c/g?y#s)z;xzhttp://a/b/c/;x)zg;xzhttp://a/b/c/g;x)zg;x?y#szhttp://a/b/c/g;x?y#s)�r)�.�
http://a/b/c/)z./r)�..�http://a/b/)z../r)z../g�http://a/b/g)z../..�	http://a/)z../../r)z../../gr)z
../../../gr)z
../../../../gr)z/./gr)z/../gr)zg.zhttp://a/b/c/g.)z.gzhttp://a/b/c/.g)zg..zhttp://a/b/c/g..)z..gzhttp://a/b/c/..g)z./../gr)z./g/.r)zg/./hzhttp://a/b/c/g/h)zg/../hzhttp://a/b/c/h)z	g;x=1/./yzhttp://a/b/c/g;x=1/y)z
g;x=1/../yzhttp://a/b/c/y)zg?y/./xzhttp://a/b/c/g?y/./x)zg?y/../xzhttp://a/b/c/g?y/../x)zg#s/./xzhttp://a/b/c/g#s/./x)zg#s/../xzhttp://a/b/c/g#s/../xc�2�djd�|D��S)Nrc3�8K�|]}dt|�z���y�w)z%%%02XN)�ord)�.0�cs  �>/usr/lib/python3/dist-packages/twisted/python/test/test_url.py�	<genexpr>z<lambda>.<locals>.<genexpr>Ls����=�a��3�q�6� 1�=�s�)�join)�ss r�<lambda>r Ls�����=�1�=�=��c��eZdZedd��Zy)�
_HasExceptionc��y)N���selfs r�	exceptionz_HasException.exceptionPs��r!N)�return�
BaseException)�__name__�
__module__�__qualname__�propertyr(r%r!rr#r#Os��
���r!r#c��eZdZdZd/d�Z	d0																	d1d�Zd2d�Zd2d�Zd2d�Zd2d�Z	d2d�Z
d2d	�Zd2d
�Zd2d�Z
d2d�Zd2d
�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Zd2d�Z d2d�Z!d2d �Z"d2d!�Z#d2d"�Z$d2d#�Z%d2d$�Z&d2d%�Z'd2d&�Z(d2d'�Z)d2d(�Z*d2d)�Z+d2d*�Z,d2d+�Z-d2d,�Z.d2d-�Z/y.)3�TestURLz
    Tests for L{URL}.
    c�(�|j|jtt|��|j|jtt|��|j
D]"}|j|tt|���$|jD]T\}}|j|tt|��|j|duxst|t�t|���V|j|jtt|��y)zl
        The given L{URL}'s components should be L{unicode}.

        @param u: The L{URL} to test.
        N)
�assertIsInstance�scheme�str�repr�host�path�query�
assertTrue�
isinstance�fragment)r'�u�seg�k�vs     r�assertUnicodedzTestURL.assertUnicodedZs���	
���a�h�h��T�!�W�5����a�f�f�c�4��7�3��6�6�	5�C��!�!�#�s�D��G�4�	5��G�G�	F�D�A�q��!�!�!�S�$�q�'�2��O�O�A��I�;��A�s�);�T�!�W�E�	F�	
���a�j�j�#�t�A�w�7r!c	��|j|j|j|j|j|j
|jf}	||t|�t|�|||jf}
|j|	|
�y)a�
        The given L{URL} should have the given components.

        @param u: The actual L{URL} to examine.

        @param scheme: The expected scheme.

        @param host: The expected host.

        @param path: The expected path.

        @param query: The expected query.

        @param fragment: The expected fragment.

        @param port: The expected port.

        @param userinfo: The expected userinfo.
        N)	r3r6r7r8r;�port�userinfo�tuple�assertEqual)r'r<r3r6r7r8r;rBrC�actual�expecteds           r�	assertURLzTestURL.assertURLisd��<�(�(�A�F�F�A�F�F�A�G�G�Q�Z�Z�������T���D�%��+�u�U�|�X�t�Q�Z�Z�X�������*r!c	���d�fd�}|tdd��|tddgg��|tddggd��y)z@
        L{URL} should have appropriate default values.
        c
�X���j|��j|ddggddd�y)N�httpr�P)r@rH)r<r's �r�checkz(TestURL.test_initDefaults.<locals>.check�s+�������"��N�N�1�f�b�"�b�"�b�"�=r!rKrN�r<r	r)�Noner)r'rMs` r�test_initDefaultszTestURL.test_initDefaults�s@���
	>�	�c�&�"�o��
�c�&�"�b�"�%�&�
�c�&�"�b�"�b�)�*r!c	���tdddgddgd�}|j|�|j|dddgddgdd�|jtdd	d
gdgd�dd	d
gdgdd
�y)z=
        L{URL} should accept L{unicode} parameters.
        r�h�p�r>r?)r>N�fNrK�à�é)uλuπu⊥rL�r	r@rH�r'r<s  r�	test_initzTestURL.test_init�s���
��S�3�%�*�k�!:�C�@�����A�����q�#�s�S�E�J��+D�c�4�P���������+?�*@�(�K���
�H�
!�"���	
r!c	�~�tdddgddgd�}|j|�|j|dddgddgdd�y)zN
        L{URL} should accept (and not interpret) percent characters.
        rz%68z%70)�%6Bz%76)r\Nz%66NrXrYs  r�test_initPercentzTestURL.test_initPercent�sM��
��U�U�G�n�m�%D�e�L�����A�����
�s�E�E�7�^�]�$C�U�D�	
r!c��|jttdddgddgd���djtd	���y
)z�
        L{URL.__repr__} will display the canonical form of the URL, wrapped in
        a L{URL.fromText} invocation, so that it is C{eval}-able but still easy
        to read.
        rK�foo�bar)�bazNrT�frob)r3r6r7r8r;zURL.from_text({})zhttp://foo/bar?baz&k=v#frobN)rEr5r	�formatr&s r�	test_reprzTestURL.test_repr�sN��	
�����!����(�*�5�#��
�
 �&�&�t�,I�'J�K�	
r!c�~�tjt�}|jt|j	��y)zb
        Round-tripping L{URL.fromText} with C{str} results in an equivalent
        URL.
        N)r	�fromText�theurlrE�asText�r'�urlpaths  r�
test_fromTextzTestURL.test_fromText�s)��
�,�,�v�&���������!1�2r!c��d}|D]7}tj|�j�}|j||��9y)z>
        L{URL.asText} should invert L{URL.fromText}.
        )zhttp://localhost�http://localhost/zhttp://localhost/foozhttp://localhost/foo/zhttp://localhost/foo!!bar/zhttp://localhost/foo%20bar/zhttp://localhost/foo%2Fbar/zhttp://localhost/foo?nzhttp://localhost/foo?n=vzhttp://localhost/foo?n=/a/bz%http://example.com/foo!@$bar?b!@z=123z$http://localhost/asd?a=asd%20sdf/345z6http://(%2525)/(%2525)?(%2525)&(%2525)=(%2525)#(%2525)z<http://(%C3%A9)/(%C3%A9)?(%C3%A9)&(%C3%A9)=(%C3%A9)#(%C3%A9)N)r	rfrhrE)r'�tests�test�results    r�test_roundtripzTestURL.test_roundtrip�sA��
�� �	+�D��\�\�$�'�.�.�0�F����T�6�*�	+r!c���tjt�}|j|tjt��|j	|tjd��y)z�
        Two URLs decoded using L{URL.fromText} will be equal (C{==}) if they
        decoded same URL string, and unequal (C{!=}) if they decoded different
        strings.
        z:ftp://www.anotherinvaliddomain.com/foo/bar/baz/?zot=21&zutN)r	rfrgrE�assertNotEqualris  r�
test_equalityzTestURL.test_equality�sK���,�,�v�&������#�,�,�v�"6�7������L�L�O�
�	
r!c��|jtd��t��|jtjd�tjd��y)z�
        An URL created with the empty string for a fragment compares equal
        to an URL created with an unspecified fragment.
        r)r;zhttp://localhost/#rmN)rEr	rfr&s r�test_fragmentEqualityzTestURL.test_fragmentEquality�sB��
	
����b�)�3�5�1�����L�L�-�.����=P�0Q�	
r!c��tjt�}|jd|j	d�j��|jd|j	d�j��|jd|j	d�j��|jd|j	d�j��y	)
zm
        L{URL.child} appends a new path segment, but does not affect the query
        or fragment.
        z.http://www.foo.com/a/nice/path/gong?zot=23&zut�gongz1http://www.foo.com/a/nice/path/gong%2F?zot=23&zutzgong/z7http://www.foo.com/a/nice/path/gong%2Fdouble?zot=23&zutzgong/doublez:http://www.foo.com/a/nice/path/gong%2Fdouble%2F?zot=23&zutzgong/double/N)r	rfrgrE�childrhris  r�
test_childzTestURL.test_childs���
�,�,�v�&�����<��M�M�&�!�(�(�*�	
�	
���?��M�M�'�"�)�)�+�	
�	
���E��M�M�-�(�/�/�1�	
�	
���H��M�M�.�)�0�0�2�	
r!c��|jtjd�jddd�j	�d�y)zg
        L{URL.child} receives multiple segments as C{*args} and appends each in
        turn.
        zhttp://example.com/a/br�d�ezhttp://example.com/a/b/c/d/eN)rEr	rfryrhr&s r�test_multiChildzTestURL.test_multiChilds:��
	
����L�L�1�2�8�8��c�3�G�N�N�P�*�	
r!c��td��jd�}|j|j�|j	d|j��y)zo
        L{URL.child} of a L{URL} without a path produces a L{URL} with a single
        path segment.
        �www.foo.com�r6rzhttp://www.foo.com/cN)r	ryr9�rootedrErh)r'�childURLs  r�test_childInitRootzTestURL.test_childInitRoot!sA��
�M�*�0�0��5��������(����/����1B�Cr!c� �tjt�}|jd|j	d�j��d}tj|�}|jd|j	d�j��y)z
        L{URL.sibling} of a L{URL} replaces the last path segment, but does not
        affect the query or fragment.
        z0http://www.foo.com/a/nice/path/sister?zot=23&zut�sisterz)http://www.foo.com/a/nice/path?zot=23&zutz+http://www.foo.com/a/nice/sister?zot=23&zutN)r	rfrgrE�siblingrh)r'rj�theurl2s   r�test_siblingzTestURL.test_sibling*ss��
�,�,�v�&�����>��O�O�H�%�,�,�.�	
�
>���,�,�w�'�����9��O�O�H�%�,�,�.�	
r!c��tjt�}|jd|j	d�j��|jd|j	d�j��|jd|j	d�j��|jd|j	d�j��|j
d	|j	d
�j��tjd�}|jd|j	d
�j��tjd�}|j|j	d�j�d�y)z�
        L{URL.click} interprets the given string as a relative URI-reference
        and returns a new L{URL} interpreting C{self} as the base absolute URI.
        r
rz$http://www.foo.com/a/nice/path/click�clickzhttp://www.foo.com/clickz/clickz$http://www.foo.com/a/nice/path/?burpz?burpz//foobarzhttp://www.foo.com/foobarzhttp://www.foo.com/me/noqueryz!http://www.foo.com/me/17?spam=158z/me/17?spam=158zhttp://localhost/foo?abc=defzhttp://www.python.orgN)r	rfrgrEr�rh�assertNotIn)r'rjr<s   r�
test_clickzTestURL.test_click<s?��
�,�,�v�&�����8�'�-�-��:K�:R�:R�:T�	
�	
���2�G�M�M�'�4J�4Q�4Q�4S�	
�	
���3�W�]�]�8�5L�5S�5S�5U�V����2�G�M�M�'�4J�4Q�4Q�4S�	
�
	
�����
�
�&A�B�I�I�K�	
�
�L�L�8�9�����/����9J�1K�1R�1R�1T�	
�
�L�L�7�8�����
�G�G�+�,�3�3�5�7N�	
r!c��tjt�}tD]4\}}|j	|j|�j
�|��6y)zQ
        L{URL.click} should correctly resolve the examples in RFC 3986.
        N)r	rf�relativeLinkBaseForRFC3986�relativeLinkTestsForRFC3986rEr�rh)r'�base�refrGs    r�test_clickRFC3986zTestURL.test_clickRFC3986dsI���|�|�6�7��8�	A�M�C�����T�Z�Z��_�3�3�5�x�@�	Ar!c��tjt�}|jt|j
d�|jt|j
d�y)zM
        L{URL.click} should not accept schemes with relative paths.
        zg:hzhttp:hN)r	rfr��assertRaises�NotImplementedErrorr�)r'r�s  r�test_clickSchemeRelPathzTestURL.test_clickSchemeRelPathlsA���|�|�6�7�����-�t�z�z�5�A����-�t�z�z�8�Dr!c
�2�tjd�}|j|j|j|j
|j|j|j|j�|�|j|j�|�y)zf
        Verify that L{URL.replace} doesn't change any of the arguments it
        is passed.
        zhttps://x:1/y?z=1#AN)
r	rfrE�replacer3r6r7r8r;rBris  r�test_cloneUnchangedzTestURL.test_cloneUnchangedtsw��
�,�,�4�5������O�O�����������
�
�� � ����

�
�
	
�	
������*�G�4r!c�.�gd�gd�gd�gd�gd�gd�gd�gd�gd	�gd
�gd�gd�gd
�g
}|D]g\}}}tj|�j|�j�}|j	||dj|t
|�||����iy)zd
        L{URL.click} collapses C{.} and C{..} according to RFC 3986 section
        5.2.4.
        )rmrrm)rmrrm)�http://localhost/a/b/crzhttp://localhost/a/b/)r�rzhttp://localhost/a/)r�z./d/ezhttp://localhost/a/b/d/e)r��../d/e�http://localhost/a/d/e)r�z/./d/e�http://localhost/d/e)r�z/../d/er�)zhttp://localhost/a/b/c/z
../../d/e/zhttp://localhost/a/d/e/)zhttp://localhost/a/./cr�r�)zhttp://localhost/a/./c/r�r�)zhttp://localhost/a/b/c/dz
./e/../f/../gzhttp://localhost/a/b/c/g)r�zd//ezhttp://localhost/a/b/d//ez1{start}.click({click}) => {actual} not {expected})�startr�rFrGN)r	rfr�rhrErcr5)r'rnr�r�rGrFs      r�test_clickCollapsezTestURL.test_clickCollapse�s���
<�<�D�C�K�J�H�I�P�H�K�U�K�
��',�	�"�E�5�(��\�\�%�(�.�.�u�5�<�<�>�F������C�J�J���u�+�!�%�	K��	
�	r!c�j�|jdtjd�jdd�j	��|jdtd��jdd�j	��tjt
�}|jd|jd	�j	��|jd
|jd	d�j	��|jd|jd	d�jd
�j	��|jd|jd
�jd	d�j	��|jd|jd	d�jdd�j	��y)z3
        L{URL.add} adds query parameters.
        z'http://www.foo.com/a/nice/path/?foo=barzhttp://www.foo.com/a/nice/path/r_r`zhttp://www.foo.com/?foo=barr�r�z/http://www.foo.com/a/nice/path/?zot=23&zut&burp�burpz3http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx�xxxz8http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx&zing�zingz8http://www.foo.com/a/nice/path/?zot=23&zut&zing&burp=xxxz:http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx&zot=32�zot�32N)rEr	rf�addrhrgris  r�
test_queryAddzTestURL.test_queryAdd�sj��	
���5��L�L�:�;�?�?��u�M�T�T�V�	
�	
���)��]�#�'�'��u�5�<�<�>�	
��,�,�v�&�����=��K�K���&�&�(�	
�	
���A��K�K���&�-�-�/�	
�	
���F��K�K���&�*�*�6�2�9�9�;�	
�
	
���F��K�K���#�#�F�E�2�9�9�;�	
�
	
���H��K�K���&�*�*�5�$�7�>�>�@�	
r!c��tjt�}|jd|j	dd�j��|jd|j	d�j	dd�j��|jd|j
dd�j	dd�j��y)	z?
        L{URL.set} replaces query parameters by name.
        z*http://www.foo.com/a/nice/path/?zot=32&zutr�r�z0http://www.foo.com/a/nice/path/?zot&zut=itworked�zut�itworkedr�N)r	rfrgrE�setrhr�ris  r�
test_querySetzTestURL.test_querySet�s����,�,�v�&�����8��K�K��t�$�+�+�-�	
�
	
���>��K�K���"�"�5�*�5�<�<�>�	
�	
���8��K�K��u�%�)�)�%��6�=�=�?�	
r!c��tjd�}|j|jd�tjd��y)zK
        L{URL.remove} removes all instances of a query parameter.
        z*https://example.com/a/b/?foo=1&bar=2&foo=3r_zhttps://example.com/a/b/?bar=2N)r	rfrE�remove�r'�urls  r�test_queryRemovezTestURL.test_queryRemove�s9���l�l�G�H������J�J�u��s�|�|�,L�M�	
r!c�T�|jt�j�d�y)zG
        An empty L{URL} should serialize as the empty string.
        rN)rEr	rhr&s r�
test_emptyzTestURL.test_empty�s��	
���������,r!c�^�tdg��}|j|j�d�y)zP
        An L{URL} with query text should serialize as just query text.
        ��hello�world�r8z?hello=worldN)r	rErhrYs  r�test_justQueryTextzTestURL.test_justQueryText�s(��
�)�*�+���������^�4r!c�R�tjd�}|j||�y)z2
        L{URL} compares equal to itself.
        rmN�r	rfrErYs  r�test_identicalEqualzTestURL.test_identicalEqual�s#��
�L�L�,�-������A�r!c�|�tjd�}tjd�}|j||�y)zG
        URLs with equivalent components should compare equal.
        rmNr��r'�u1�u2s   r�test_similarEqualzTestURL.test_similarEqual�s2���\�\�-�
.��
�\�\�-�
.������R� r!c��tjd�}tjd�}|j||k(|�d|���|j||�y)z|
        L{URL}s that refer to different resources are both unequal (C{!=}) and
        also not equal (not C{==}).
        �http://localhost/a�http://localhost/b� != N)r	rf�assertFalsersr�s   r�test_differentNotEqualzTestURL.test_differentNotEqualsQ��
�\�\�.�
/��
�\�\�.�
/������r��b�V�4��v�#6�7����B��#r!c���tjd�}|j|dk(d�|j|t�k(d�|j	|d�|j	|t��y)z=
        L{URL} is not equal (C{==}) to other types.
        rm�*zURL must not equal a number.zURL must not equal an object.N)r	rfr��objectrsrYs  r�test_otherTypesNotEqualzTestURL.test_otherTypesNotEqualsa��
�L�L�,�-������b��"@�A�����f�h��(G�H����A�r�"����A�v�x�(r!c�^�tjd�}|j||k7d|z�y)zJ
        Identical L{URL}s are not unequal (C{!=}) to each other.
        rmz%r == itselfN�r	rfr�rYs  r�test_identicalNotUnequalz TestURL.test_identicalNotUnequals,��
�L�L�,�-������a���!�!3�4r!c��tjd�}tjd�}|j||k7|�d|���y)zU
        Structurally similar L{URL}s are not unequal (C{!=}) to each other.
        rm� == Nr�r�s   r�test_similarNotUnequalzTestURL.test_similarNotUnequal!sA���\�\�-�
.��
�\�\�-�
.������r��b�V�4��v�#6�7r!c��tjd�}tjd�}|j||k7|�d|���y)zS
        Structurally different L{URL}s are unequal (C{!=}) to each other.
        r�r�r�N)r	rfr9r�s   r�test_differentUnequalzTestURL.test_differentUnequal)s?���\�\�.�
/��
�\�\�.�
/������b��R�F�$�r�f�"5�6r!c��tjd�}|j|dk7d�|j|t�k7d�y)z;
        L{URL} is unequal (C{!=}) to other types.
        rmr�zURL must differ from a number.z"URL must be differ from an object.N)r	rfr9r�rYs  r�test_otherTypesUnequalzTestURL.test_otherTypesUnequal1s;��
�L�L�,�-������R��!A�B�����V�X�
�'K�Lr!c�\�d}tj|�}|j�}|j|jd�|j|j
dd�|j|j
�|�d}|j
�}|j|||�d|���y)z�
        L{URL.asURI} produces an URI which converts any URI unicode encoding
        into pure US-ASCII and returns a new L{URL}.
        �http://é.com/é?á=í#úué.comrué�.http://xn--9ca.com/%C3%A9?%C3%A1=%C3%AD#%C3%BAr�N)r	rf�asURIrEr6r7rh)r'�unicodey�iri�uri�expectedURI�	actualURIs      r�
test_asURIzTestURL.test_asURI9s���
B�	��l�l�8�$���i�i�k��������#L�M�����H�H�Q�K�M�	
�	
�������x�0�F���J�J�L�	�����K�I�=��[�O�1T�Ur!c�\�d}tj|�}|j�}|j|jd�|j|j
dd�|j|j
�|�d}|j
�}|j|||�d|���y)z�
        L{URL.asIRI} decodes any percent-encoded text in the URI, making it
        more suitable for reading by humans, and returns a new L{URL}.
        r�zxn--9ca.comrz%C3%A9uhttp://é.com/é?á=í#úr�N)r	rf�asIRIrEr6r7rh)r'�asciiishr�r��expectedIRI�	actualIRIs      r�
test_asIRIzTestURL.test_asIRIPs���
D���l�l�8�$���i�i�k��������=�1�������!��h�/��������x�0�
3�	��J�J�L�	�����K�I�=��[�O�1T�Ur!c��d}tj|�}|j�}d}|j�}|j	|||�d|���y)z�
        Bad UTF-8 in a path segment, query parameter, or fragment results in
        that portion of the URI remaining percent-encoded in the IRI.
        z http://xn--9ca.com/%00%FF/%C3%A9uhttp://é.com/%00%FF/ér�N)r	rfr�rhrE)r'�
urlWithBinaryr�r�r�r�s      r�test_badUTF8AsIRIzTestURL.test_badUTF8AsIRIesV��
;�
��l�l�=�)���i�i�k��
2�	�
�J�J�L�	�����K�I�=��[�O�1T�Ur!c��d}tj|�}|j�}|j|j	�|�y)zT
        A L{URL} composed of non-ASCII text will result in non-ASCII text.
        r�N)r	rfr�rErh)r'r�r��alsoIRIs    r�test_alreadyIRIAsIRIzTestURL.test_alreadyIRIAsIRIus?��

B�	��l�l�8�$���)�)�+��������)�8�4r!c��d}tj|�}|j�j�}|j	||�y)zH
        A L{URL} composed of encoded text will remain encoded.
        r�N)r	rfr�rhrE)r'r�r�r�s    r�test_alreadyURIAsURIzTestURL.test_alreadyURIAsURI�s<��G���l�l�;�'���I�I�K�&�&�(�	�����K�0r!c���tjd�}|j|jd�d�|j|jd�d�|j|jd�|j|j
d�|j|j
�d�|j|jd�	�j
�d
�y)zz
        L{URL.fromText} will parse the C{userinfo} portion of the URI
        separately from the host and port.
        z<http://someuser:somepassword@example.com/some-segment@ignoreTz!someuser:somepassword@example.comFzsomeuser:@example.comzsomeuser:somepassword�someuserz0http://someuser:@example.com/some-segment@ignore)rCz/http://someuser@example.com/some-segment@ignoreN)r	rfrE�	authorityrC�userrhr�r�s  r�
test_userinfozTestURL.test_userinfo�s���
�l�l�J�
��	
������t�,�.Q�R�������u�-�/F�G�������'>�?�������:�.�����J�J�L�L�	
�	
����K�K��K�,�3�3�5�=�	
r!c��tjd�}|j|jd�|j|j	�d�y)zI
        L{URL.fromText} parses custom port numbers as integers.
        zhttp://www.example.com:8080/i�N)r	rfrErBrh)r'�portURLs  r�
test_portTextzTestURL.test_portText�s?���,�,�=�>��������t�,�������)�+I�Jr!c�j�|jtjd�j�d�y)a
        Although L{URL} instances are mainly for dealing with HTTP, other
        schemes (such as C{mailto:}) should work as well.  For example,
        L{URL.fromText}/L{URL.asText} round-trips cleanly for a C{mailto:} URL
        representing an email address.
        zmailto:user@example.comN)rEr	rfrhr&s r�test_mailtozTestURL.test_mailto�s+��	
����L�L�2�3�:�:�<�>W�	
r!c�Z�tddgg��}|j|jd�y)z�
        When a L{URL} is created with a C{query} argument, the C{query}
        argument is converted into an N-tuple of 2-tuples.
        �alpha�betar�))r�r�N)r	rEr8r�s  r�test_queryIterablezTestURL.test_queryIterable�s+���'�6�*�+�,��������$8�9r!c�X�tddg��}|j|jd�y)zr
        When a L{URL} is created with a C{path} argument, the C{path} is
        converted into a tuple.
        r�r��r7r�N)r	rEr7r�s  r�test_pathIterablezTestURL.test_pathIterable�s(��
���)�*��������#5�6r!c�����Gd�d��tturdnd}d�fd��|fd���fd�
}|d�|d	�|d
�|dd�|d
�|dd��jt�5}t	��g��ddd��|d��jt�5}t	d��fg��ddd��||dzd��jt�5}t	��dfg��ddd��||d��jt�5t	��g��ddd��jt
�5t	dg��ddd��jt
�5t	dg��ddd�t	jd�}�jt�5}|j���ddd��||d��jt�5}|j���ddd��||d��jt�5}|j���ddd��||d�y#1swY���xYw#1swY���xYw#1swY���xYw#1swY��WxYw#1swY��9xYw#1swY��xYw#1swY��xYw#1swY��xYw#1swY�zxYw)a�
        Passing an argument of the wrong type to any of the constructor
        arguments of L{URL} will raise a descriptive L{TypeError}.

        L{URL} typechecks very aggressively to ensure that its constitutent
        parts are all properly immutable and to prevent confusing errors when
        bad data crops up in a method call long after the code that called the
        constructor is off the stack.
        c��eZdZdd�Zdd�Zy)�1TestURL.test_invalidArguments.<locals>.Unexpectedc��y)N�wrongr%r&s r�__str__z9TestURL.test_invalidArguments.<locals>.Unexpected.__str__�s��r!c��y)N�<unexpected>r%r&s r�__repr__z:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__�s��%r!N)r)r4)r+r,r-rr	r%r!r�
Unexpectedr�s��
�
&r!r
�unicoder4�namec�r���jt|j�dj||d��y)Nzexpected {} for {}, got {}r)rEr4r(rc)�raised�expectationrr's   �r�assertRaisedz3TestURL.test_invalidArguments.<locals>.assertRaised�s1�������F�$�$�%�,�3�3�K��~�V�
r!c����jt�5}tdi|��i��ddd��||�y#1swY�xYw)Nr%)r��	TypeErrorr	)�paramrrr
rr's   ���rrMz,TestURL.test_invalidArguments.<locals>.check�sF����"�"�9�-�
-���,�u�j�l�+�,�
-����e�4�
-�
-�s	�=�Ar3r6r;r��boolrCrBzint or NoneTyper�Nzpath segmentr�z or NoneTypezquery parameter value�valuezquery parameter name)r>r?�vv)r>zhttps://valid.example.com/zrelative URL)rr#rr4rr4r)rO)rr4rr4r)rO)
�bytesr4r�rr	�
ValueErrorrfryr�r�)r'�defaultExpectationrMrr�r
rs`    @@r�test_invalidArgumentszTestURL.test_invalidArguments�s����	&�	&�+0�3�,�Y�E��	�2D�	5�	5�
	�h��
�f�
�
�j��
�h���
�j��
�f�'�(�
�
�
�y�
)�	�V���L��
�	�	�V�/��@�
�
�
�y�
)�	�V���Z�\�*��
�	�	��&��7�9P�	
��
�
�y�
)�	�V���\�7�+��
�	�	�V�/�1G�H��
�
�y�
)�	&��z�|�n�%�	&�
�
�
�z�
*�	*��'�(�)�	*�
�
�
�z�
*�	 ��v�h��	 ��l�l�7�8��
�
�
�y�
)�	$�V��I�I�j�l�#�	$��V�/��@�
�
�
�y�
)�	&�V��K�K�
��%�	&��V�/��@�
�
�
�y�
)�	$�V��I�I�j�l�#�	$��V�/��@�S	�	��	�	��	�	��	&�	&��	*�	*��	 �	 ��	$�	$��	&�	&��	$�	$�sl�5I+�/I8�.J�*J�J�J,�J9�K�K�+I5�8J�J�J�J)�,J6�9K�K�Kc���|jt�5}td��ddd�|jt	j
�dj
td���y#1swY�GxYw)z�
        Technically, L{str} (or L{unicode}, as appropriate) is iterable, but
        C{URL(path="foo")} resulting in C{URL.fromText("f/o/o")} is never what
        you want.
        r_r�Nz+expected iterable of text for path, not: {})r�rr	rEr4r(rcr5)r'rs  r�!test_technicallyTextIsIterableButz)TestURL.test_technicallyTextIsIterableButs^���
�
�y�
)�	�V��U�O�	������ � �!�9�@�@��e��M�	
�	�	�s�
A)�)A2NrN)r)r<r	r3r4r6r4r7z
Iterable[str]r8z Iterable[tuple[str, str | None]]r;r4rBz
int | NonerCr4r)rO�r)rO)0r+r,r-�__doc__r@rHrPrZr]rdrkrqrtrvrzr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr%r!rr0r0UsO���
8�0� +�� +�� +��	 +�
� +�0�
 +�� +�� +�� +�
� +�D+�
�$
�
�&3�+�0

�
�
�.
�D�
�$&
�PA�E�5�&�B"
�H
�*
�-�5��!�$�)�5�8�7�M�V�.V�*V� 
5�1�
�(K�	
�:�7�OA�b
r!r0c��eZdZdZdd�Zy)�URLDeprecationTestsz.
    L{twisted.python.url} is deprecated.
    c��ddlm}||j|jg�}|j	dt|��|j	d|dd�y)zK
        L{twisted.python.url} is deprecated since Twisted 17.5.0.
        r)r��z\twisted.python.url was deprecated in Twisted 17.5.0: Please use hyperlink from PyPI instead.�messageN)�twisted.pythonr��
flushWarnings�test_urlDeprecationrE�len)r'r��
warningsShowns   rr&z'URLDeprecationTests.test_urlDeprecation)sZ��	'���*�*�D�,D�,D�+E�F�
�����C�
�.�/����;�
�!��Y�'�	
r!Nr)r+r,r-rr&r%r!rr r $s���
r!r N)r�
__future__r�typingrr�twisted.trial.unittestrr�r	rgr�r��_percentencr#r0r r%r!r�<module>r-sa��
�#���6��	5��2��4��n>���H��L
�!�L
�^
�-�
r!

Zerion Mini Shell 1.0