Skip to content

Commit e8616fa

Browse files
committed
add a few more DecodedURL/parse tests and a couple comments
1 parent 6dd3272 commit e8616fa

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

hyperlink/_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ class DecodedURL(object):
15171517
handled automatically.
15181518
15191519
Where applicable, a UTF-8 encoding is presumed. Be advised that
1520-
some interactions, can raise :exc:`UnicodeEncodeErrors` and
1520+
some interactions can raise :exc:`UnicodeEncodeErrors` and
15211521
:exc:`UnicodeDecodeErrors`, just like when working with
15221522
bytestrings. Examples of such interactions include handling query
15231523
strings encoding binary data, and paths containing segments with

hyperlink/test/test_decoded_url.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ def test_passthroughs(self):
6060
durl2 = DecodedURL.from_text(TOTAL_URL, lazy=True)
6161
assert durl2 == durl2.encoded_url.get_decoded_url(lazy=True)
6262

63-
# TODO change this to the actual value when str() changes get merged
64-
assert '%20' in str(DecodedURL.from_text(BASIC_URL).child(' '))
63+
assert str(DecodedURL.from_text(BASIC_URL).child(' ')) == 'http://example.com/%20'
6564

6665
assert not (durl == 1)
6766
assert durl != 1
@@ -89,10 +88,11 @@ def test_query_manipulation(self):
8988

9089
assert durl.set('arg', 'd').get('arg') == ['d']
9190

92-
def test_equivalences(self):
91+
def test_equality_and_hashability(self):
9392
durl = DecodedURL.from_text(TOTAL_URL)
9493
durl2 = DecodedURL.from_text(TOTAL_URL)
9594
burl = DecodedURL.from_text(BASIC_URL)
95+
durl_uri = durl.to_uri()
9696

9797
assert durl == durl
9898
assert durl == durl2
@@ -106,6 +106,14 @@ def test_equivalences(self):
106106

107107
assert len(durl_map) == 1
108108

109+
durl_map[burl] = burl
110+
111+
assert len(durl_map) == 2
112+
113+
durl_map[durl_uri] = durl_uri
114+
115+
assert len(durl_map) == 3
116+
109117
def test_replace_roundtrip(self):
110118
durl = DecodedURL.from_text(TOTAL_URL)
111119

hyperlink/test/test_parse.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
BASIC_URL = 'http://example.com/#'
99
TOTAL_URL = "https://%75%73%65%72:%00%00%00%[email protected]:8080/a/nice%20nice/./path/?zot=23%25&zut#frég"
1010
UNDECODABLE_FRAG_URL = TOTAL_URL + '%C3'
11+
# the %C3 above percent-decodes to an unpaired \xc3 byte which makes this
12+
# invalid utf8
1113

1214

1315
class TestURL(HyperlinkTestCase):

0 commit comments

Comments
 (0)