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: //usr/lib/python3/dist-packages/hyperlink/test/__pycache__/test_url.cpython-38.pyc
U

��\:��(@s�ddlmZddlZddlZddlmZddlmZmZddlm	Z	ddl	m
Z
mZmZej
ddkZed	�Zd
ZdZdd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3g(Zd4ZGd5d6�d6e�ZdS)7�)�unicode_literalsN�)�HyperlinkTestCase�)�URL�
URLParseError)�_url)�	inet_pton�SCHEME_PORT_MAP�
parse_host��*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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/../x)4zhttp://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=%3DzChttp://(%2525):(%2525)@example.com/(%2525)/?(%2525)=(%2525)#(%2525)z8first_seg_rel_path__colon%3Anotok/second_seg__colon%3Aokc@sJeZdZdZdd�Zd�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�S)��TestURLz
    Tests for L{URL}.
    cCs�|�t|jt�p|jdkt|��|�t|jt�p:|jdkt|��|jD]}|�t|�tt|��qJ|j	D]<\}}|�t|�tt|��|�|dkp�t|t�t|��ql|�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�uZseg�k�v�r+�9/usr/lib/python3/dist-packages/hyperlink/test/test_url.py�assertUnicoded�s��
 zTestURL.assertUnicodedrc	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)	rr!r"r%r&�port�userinfo�tupler#)r'r(rr!r"r%r&r.r/�actual�expectedr+r+r,�	assertURL�s��zTestURL.assertURLcsD�fdd�}|tdd��|tddgg��|tddggd��dS)z@
        L{URL} should have appropriate default values.
        c
s&��|���|ddggddd�dS)N�httpr�P)r-r3)r(�r'r+r,�check�s
z(TestURL.test_initDefaults.<locals>.checkr4rN)r)r'r7r+r6r,�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�r)r*)r)N�fNr4�à�é)uλuπu⊥r5�rr-r3�r'r(r+r+r,�	test_init�s"
���zTestURL.test_initc	Cs@tdddgddgd�}|�|�|�|dddgddgdd�dS)zN
        L{URL} should accept (and not interpret) percent characters.
        r9z%68z%70)�%6Bz%76)rCNz%66Nr@rAr+r+r,�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.
        r4�foo�bar)ZbazNr<Zfrob�rr!r"r%r&zURL.from_text(%s)zhttp://foo/bar?baz&k=v#frobN)r#r rr6r+r+r,�	test_repr�s��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'�urlpathr+r+r,�test_from_text�s
zTestURL.test_from_textcCs,tD]"}t�|�jdd�}|�||�qdS)z@
        L{URL.to_text} should invert L{URL.from_text}.
        T�Z
with_passwordN)�ROUNDTRIP_TESTSrrIrKr#)r'�test�resultr+r+r,�test_roundtripszTestURL.test_roundtripcCsXtD]N}t�|�}|��}|��}||ks.t�|jdd�}|jdd�}||kst�qdS)NTrO)rPrrI�to_iri�AssertionErrorrK)r'rQ�url�iriZ
double_iriZiri_textZdouble_iri_textr+r+r,�test_roundtrip_double_iris
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)rrIrJr#�assertNotEqualrLr+r+r,�
test_equalitys
�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#rrIr6r+r+r,�test_fragmentEquality"s�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&zutZgongz1http://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)rrIrJr#�childrKrLr+r+r,�
test_child+s
����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)rrIr#r\rK�r'rVr+r+r,�test_multiChild>s
�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!r^zhttp://www.foo.com/cN)rr\r�rootedr#rK)r'ZchildURLr+r+r,�test_childInitRootGszTestURL.test_childInitRootcCstdd�}|�|��|�dS)zT
        L{URL.child} without any new segments returns the original L{URL}.
        rcrdN)rr#r\rar+r+r,�test_emptyChildPs
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&zutZsisterz)http://www.foo.com/a/nice/path?zot=23&zutz+http://www.foo.com/a/nice/sister?zot=23&zutN)rrIrJr#�siblingrK)r'rM�url_textr+r+r,�test_siblingWs
�
�zTestURL.test_siblingcCs$t�t�}|�d|�d����|�d|�d����|�d|�d����|�d|�d����|�d	|�d
���k�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.
        r
rz$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=defrFzhttp://localhost/foo/barN)rrIrJr#rkrKr�fromText)r'rMr(�res�u2�u3r+r+r,�
test_clickis@
�����
�
�



zTestURL.test_clickcCs2t�t�}tD]\}}|�|�|���|�qdS)zQ
        L{URL.click} should correctly resolve the examples in RFC 3986.
        N)rrI�relativeLinkBaseForRFC3986�relativeLinkTestsForRFC3986r#rkrK)r'�base�refr2r+r+r,�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)rrIrq�assertRaises�NotImplementedErrorrk)r'rsr+r+r,�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)
rrIr#�replacerr!r"r%r&r.rLr+r+r,�test_cloneUnchanged�s
��zTestURL.test_cloneUnchangedcCs�dddgdddgdddgdddgdddgdd	d
gdddgdd
dgdddgdd	dgdd	d
gdddgdddgg
}|D]>\}}}t�|��|���}|�||dj|t|�||d��qpdS)zd
        L{URL.click} collapses C{.} and C{..} according to RFC 3986 section
        5.2.4.
        rrrzhttp://localhost/a/b/czhttp://localhost/a/b/zhttp://localhost/a/z./d/ezhttp://localhost/a/b/d/ez../d/ezhttp://localhost/a/d/ez/./d/ezhttp://localhost/d/ez/../d/ezhttp://localhost/a/b/c/z
../../d/e/zhttp://localhost/a/d/e/zhttp://localhost/a/./czhttp://localhost/a/./c/zhttp://localhost/a/b/c/dz
./e/../f/../gzhttp://localhost/a/b/c/gzd//ezhttp://localhost/a/b/d//ez1{start}.click({click}) => {actual} not {expected})�startrkr1r2N)rrIrkrKr#�formatr )r'Ztestsr{rkr2r1r+r+r,�test_clickCollapse�s<�����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/rErFzhttp://www.foo.com/?foo=barrcrdz/http://www.foo.com/a/nice/path/?zot=23&zut&burpZburpz3http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx�xxxz8http://www.foo.com/a/nice/path/?zot=23&zut&burp=xxx&zingZzingz8http://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#rrI�addrKrJrLr+r+r,�
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&zutrr�z0http://www.foo.com/a/nice/path/?zot&zut=itworkedZzutZitworkedr~N)rrIrJr#�setrKr�rLr+r+r,�
test_querySet�s
���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=3rEzhttps://example.com/a/b/?bar=2�1)�name�valuez$https://example.com/a/b/?bar=2&foo=3r)r��limitr)r�r�r�N)rrIr#�removerar+r+r,�test_queryRemoves"
����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))rEr�)rF�yz7https://example.com/?argument=3&argument=4&operator=%3D�operator�=N)rrIr#�getrKr%rT�to_uri)r'r(rWr+r+r,�test_parseEqualSignInParamValue)s


z'TestURL.test_parseEqualSignInParamValuecCs|�t���d�dS)zG
        An empty L{URL} should serialize as the empty string.
        rN)r#rrKr6r+r+r,�
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)rr#rKrAr+r+r,�test_justQueryTextAszTestURL.test_justQueryTextcCst�d�}|�||�dS)z2
        L{URL} compares equal to itself.
        rN�rrIr#rAr+r+r,�test_identicalEqualHs
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'�u1rnr+r+r,�test_similarEqualOs

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)rrI�assertFalserYr�r+r+r,�test_differentNotEqualWs

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)rrIr��objectrYrAr+r+r,�test_otherTypesNotEqualas

zTestURL.test_otherTypesNotEqualcCs"t�d�}|�||kd|�dS)zJ
        Identical L{URL}s are not unequal (C{!=}) to each other.
        r�z%r == itselfN�rrIr�rAr+r+r,�test_identicalNotUnequalks
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�r+r+r,�test_similarNotUnequalrs

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)rrIrr�r+r+r,�test_differentUnequalzs

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)rrIrr�rAr+r+r,�test_otherTypesUnequal�s
zTestURL.test_otherTypesUnequalcCsld}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)rrI�asURIr#r!r"rK)r'�unicodeyrW�uri�expectedURI�	actualURIr+r+r,�
test_asURI�s
�
�zTestURL.test_asURIcCsld}t�|�}|��}|�|jd�|�|jdd�|�|��|�d}|��}|�||d||f�dS)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)rrI�asIRIr#r!r"rK)r'Zasciiishr�rW�expectedIRI�	actualIRIr+r+r,�
test_asIRI�s

�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)rrIr�rKr#)r'Z
urlWithBinaryr�rWr�r�r+r+r,�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)rrIr�r#rK)r'r�rWZalsoIRIr+r+r,�test_alreadyIRIAsIRI�s
zTestURL.test_alreadyIRIAsIRIcCs*d}t�|�}|����}|�||�dS)zH
        A L{URL} composed of encoded text will remain encoded.
        r�N)rrIr�rKr#)r'r�r�r�r+r+r,�test_alreadyURIAsURI�s
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:somepasswordZsomeuserz0http://someuser:@example.com/some-segment@ignore�r/z/http://someuser@example.com/some-segment@ignoreN)rrIr#Z	authorityr/�userrKryrar+r+r,�
test_userinfo�s ��
��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)rrIr#r.rK)r'ZportURLr+r+r,�
test_portText�s
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#rrIrKr6r+r+r,�test_mailto�s�zTestURL.test_mailtocCsBd}tddggd�}|�|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�N)rr#r%)r'r2rVr+r+r,�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)rr#r"rar+r+r,�test_pathIterable
szTestURL.test_pathIterablec	sGdd�dt��ttkrdnd}�fdd��|f���fdd�	}|d	�|d
�|d�|dd
�|d�|dd���t��}t��gd�W5QRX�||d���t��}td��fgd�W5QRX�||dd���t��}t��dfgd�W5QRX�||d���t��t��gd�W5QRX��t��tdgd�W5QRX��t��tdgd�W5QRXt�d�}��t��}|����W5QRX�||d���t��}|�	���W5QRX�||d���t��}|�
���W5QRX�||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>.UnexpectedcSsdS)NZwrongr+r6r+r+r,�__str__sz9TestURL.test_invalidArguments.<locals>.Unexpected.__str__cSsdS)N�<unexpected>r+r6r+r+r,�__repr__ sz:TestURL.test_invalidArguments.<locals>.Unexpected.__repr__N)�__name__�
__module__�__qualname__r�r�r+r+r+r,�
Unexpectedsr�r�strcs ��t|j�d�||d��dS)Nzexpected {0} for {1}, got {2}r�)r#r��	exceptionr|)�raised�expectationr�r6r+r,�assertRaised%s��z3TestURL.test_invalidArguments.<locals>.assertRaisedc	s6��t��}tf|��i�W5QRX�|||�dS)N)rv�	TypeErrorr)Zparamr�r��r�r�r'r+r,r7+sz,TestURL.test_invalidArguments.<locals>.checkrr!r&re�boolr/r.zint or NoneTyper�zpath segmentr�r�z or NoneTypezquery parameter valuer�zquery parameter name)r)r*Zvv)r)zhttps://valid.example.com/zrelative URLN)r��bytesr�rvr�r�
ValueErrorrIr\rhrk)r'ZdefaultExpectationr7r�rVr+r�r,�test_invalidArgumentssJ



�
zTestURL.test_invalidArgumentsc	Cs@|�t��}tdd�W5QRX|�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.
        rEr�z,expected iterable of text for path, not: {0}N)rvr�rr#r�r�r|r )r'r�r+r+r,�!test_technicallyTextIsIterableBut^s��z)TestURL.test_technicallyTextIsIterableButcCs�tdd�}|�|jd�tdd�}|�|jd�tdd�}|�|jd�tdd�}|�|jd�t�d�}|�|jd�t�d	�}|�|jd�dS)
N�https�rTz	git+https�mailtoF�ztpzztp://test.comzztp:test:com)rr#�uses_netlocrIrar+r+r,�test_netlocls





zTestURL.test_netloccCsBd}t�|�}|jdkst�|jdks*t�t|j|jks>t�dS)Nz5https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:80/z'2001:0db8:85a3:0000:0000:8a2e:0370:7334r5)rrIr!rUr.r
r)r'�trVr+r+r,�test_ipv6_with_ports

zTestURL.test_ipv6_with_portcCs�d}t�|�}|jdkst�|jdks*t�|jdks8t�|jdksFt�|jdksTt�d}t�|�}|jdkspt�|jdks~t�|jdks�t�|jdks�t�d	}t�|�}|jdks�t�|jdks�t�|jd
ks�t�|jdks�t�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)rrIrrUr/r!r"r&�r'�textrVr+r+r,�
test_basic�s&


zTestURL.test_basiccCs|�ttjd�dS)Nz#

�rvrrrIr6r+r+r,�test_invalid_url�szTestURL.test_invalid_urlcCs|�ttjd�dS)Nzhttp://abc:

/#r�r6r+r+r,�test_invalid_authority_url�sz"TestURL.test_invalid_authority_urlcCsLdddddg}|D]4}d|d}|�tjttj|�|�ttj|�qdS)Nz2001::0234:C1ab::A0:aabc:003Fz2001::1::3F�:z::::z::256.0.0.1zhttp://[�])rv�socket�errorr	ZAF_INET6rrrI)r'Zinvalid_ipv6_ipsZiprir+r+r,�test_invalid_ipv6�s�
�zTestURL.test_invalid_ipv6cCs$|�ttjd�|�ttjd�dS)Nzftp://portmouth:smashz+http://reader.googlewebsite.com:neverforget)rvrrrIr�r6r+r+r,�test_invalid_port�s
�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)rrI�assertEqualsr!rKr�rTr�r+r+r,�	test_idna�s

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.comr�zhttp://hatnote.comr4znewscheme:a:b:cZ	newschemeznewerscheme://a/b/cZnewerschemez%git+ftp://gitstub.biz/glyph/lefkowitzzgit+ftpz'what+mailto:freerealestate@enotuniq.orgzwhat+mailtor�)�xr��zT)rr"rez
ztp:/x/y/z)r�r�r�r)rr"rer�zgit+ftp:///x/y/z/zfile:///path/to/heckr�zmailto:/path/to/heckzunregisteredscheme:///a/b/cF)r�zunregisteredscheme:/a/b/c)rrIr�rrKry)r'rV�url2riZ
no_netloc_urlZ
netloc_urlr+r+r,�test_netloc_slashes�sN





�

��

zTestURL.test_netloc_slashesc	Cs@|�t��tt�W5QRX|�t��td�W5QRXdS)NZHTTP_____more_like_imHoTTeP)rvr�rrJr6r+r+r,�test_wrong_constructor�szTestURL.test_wrong_constructorcCspt�d�}|jdkst�|jdd�}|��}|jdd�dks@t�|jdd�d	ksTt�|��jdd�d
kslt�dS)Nzhttp://user:pass@example.comr�z
us%20her:passr�TrOzhttp://us her:pass@example.comFzhttp://us her:@example.comz http://us%20her:pass@example.com)rrIr/rUryrTrKr��r'rVrWr+r+r,�test_encoded_userinfo�s
zTestURL.test_encoded_userinfocCs�i}t�d�}t|�t|�ks"t�d||<t�d�}|�dd�}d||<t|�dksXt�t|���dgksnt�tt��tt��ks�t�dS)Nz.http://blog.hatnote.com/ask?utm_source=geocityrzhttp://blog.hatnote.com/askZ
utm_sourceZgeocityr)rrI�hashrUr��len�list�values)r'Zurl_mapZurl1r�r+r+r,�	test_hashs

zTestURL.test_hashcCsRt�}t|�}t|�dkst�d|ks*t�d|ks6t�d|ksBt�d|ksNt�dS)N�rl�asTextr�r�)r�dirr�rU)r'rVrmr+r+r,�test_dirszTestURL.test_dircCs2t�d�}|��dkst�|����dks.t�dS)Nu"http://example.com/a%20té%C3%A9stz&http://example.com/a%20t%C3%A9%C3%A9st)rrlrrUr�rar+r+r,�test_twisted_compat!s
zTestURL.test_twisted_compatcCs6t�d�}|�dd�}|�dd�}|��dks2t�dS)Nzhttp://example.com/?a=b&cr�r�z!http://example.com/?a=b&x=x&c&x=y)rrIr�r�rKrUrar+r+r,�test_set_ordering's
zTestURL.test_set_orderingcCs�t�d�}t�|���}||ks$t�t�|�����}||ksBt�||ksNt�t�d�}|��}|��dkspt�t�|�����}||ks�t�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)rrIrKrUrTr�)r'r�rnroZu4Zu5Zu6r+r+r,�test_schemeless_path0s

zTestURL.test_schemeless_pathcCst�d�}|��}|��dS)z4See issue #7, affecting only narrow builds (2.6-3.3)zhttps://xn--vi8hiv.wsN)rrIrTrKr�r+r+r,�test_emoji_domainBs
zTestURL.test_emoji_domaincCsF|jttddd�|jttdd�|jttdd�|jttdd�d	S)
zPer issue #6 and #8r4za/c)rr!)�?r�)�#)�&rQr�N)rvr�rr6r+r+r,�test_delim_in_paramIszTestURL.test_delim_in_paramcCs�t�d�}t�d�}||ks t�t�d�}t�d�}||ks@t�t�d�}t�d�}||ks`t�t�d�}t�d�}||ks�t�dS)Nzhttp://example.com/zhttp://example.com)rrIrUr�r+r+r,�test_empty_paths_eqPs







zTestURL.test_empty_paths_eqcCs:t�d�jdkst�|�ttjd�|�ttjt��dS)Nz#ok�oks
bytes://x.y.z)rrIr&rUrvr�r�r6r+r+r,�test_from_text_typeeszTestURL.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::80r�r6r+r+r,�test_from_text_bad_authorityjsz$TestURL.test_from_text_bad_authorityc	Cs�t�d�}|�d�gkst�|�d�dgks0t�t|j�dksBt�|��}|jdksXt�|jdksft�|jdkstt�|�d�d	gks�t�|j	d
ks�t�|�
�dks�t�|jdddddd
�}||ks�t�t�d�}|��}|�
�dks�t�t�d�}|��}|�
�dk�st�tdd�jdd��
�dk�s,t�tdd����
�dk�sHt�tdddgdgddd�}|j
dd�d k�svt�|��j
dd�d!k�s�t�dS)"Nz0HTTP://Example.com/A%61/./../A%61?B%62=C%63#D%64ZBbzB%62zC%63�r4r�)ZAaZCcZDdzhttp://example.com/Aa?Bb=Cc#DdFrGzhttp://example.iozhttp://example.io/z/a%2fb/cd%3f?k%3d=v%23#testz/a%2Fb/cd%3F?k%3D=v%23#test)rz%te%stsr�)Zpercentsz/%te%stsz/%25te%25stsZftpz%%%z%a%b)�%z%%rz%:%)rr"r%r&r/TrOzftp://%:%@/%%%/%a%b?%=%%#%z0ftp://%25:%25@/%25%25%25/%25a%25b?%25=%25%25#%25)rrIr�rUr�r"�	normalizerr!r&rK)	r'rVZnorm_urlZ
noop_norm_urlZ
slashless_urlZslashful_urlZ
delimited_urlZnorm_delimited_urlZpercenty_urlr+r+r,�test_normalizexs8
�

 zTestURL.test_normalizecCs�d}t�|�}t|�|kst�t|�dks.t�trXtt|�t�sDt�tt|�t�s|t�n$tt|�t�sjt�tt|�t�s|t�dS)Nu&http://example.com/á/y%20a%20y/?b=%25s*http://example.com/%C3%A1/y%20a%20y/?b=%25)rrIrrUr��PY2rr�r�r+r+r,�test_str�s
zTestURL.test_strcCs�d}t�|�}|��jdks t�|��jdks2t�t�d�}|��jdksNt�|��jdks`t�|����jdksvt�t�d�����jdks�t�dS)	Nuhttp://abé.com/uabé.comzxn--ab-cja.comu(http://ドメイン.テスト.co.jp#testuドメイン.テスト.co.jpzxn--eckwd4c7c.xn--zckzah.co.jpzhttp://Example.comr�)rrIrTr!rUr�Zget_decoded_urlr�r+r+r,�test_idna_corners�s

zTestURL.test_idna_cornersN)r)Kr�r�r��__doc__r-r3r8rBrDrHrNrSrXrZr[r]rbrfrgrjrprurxrzr}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�r�r�r�r�r�r�r�r�rrrrrr
rr
rrrrr+r+r+r,r�s��

			1# 


	
L5		(r)Z
__future__r�sysr��commonrrrrrr	r
r�version_inforr$rrJrqrrrPrr+r+r+r,�<module>sj�6D