Closed
Description
________________________ UnquotingTests.test_unquoting _________________________
self = <test_future.test_urllib_toplevel.UnquotingTests testMethod=test_unquoting>
def test_unquoting(self):
# Make sure unquoting of all ASCII values works
escape_list = []
for num in range(128):
given = hexescape(chr(num))
expect = chr(num)
result = urllib_parse.unquote(given)
self.assertEqual(expect, result,
"using unquote(): %r != %r" % (expect, result))
result = urllib_parse.unquote_plus(given)
self.assertEqual(expect, result,
"using unquote_plus(): %r != %r" %
(expect, result))
escape_list.append(given)
escape_string = ''.join(escape_list)
del escape_list
result = urllib_parse.unquote(escape_string)
self.assertEqual(result.count('%'), 1,
"using unquote(): not all characters escaped: "
"%s" % result)
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, None)
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, ())
with support.check_warnings(('', BytesWarning), quiet=True):
> self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, bytes(b''))
E AssertionError: (<class 'TypeError'>, <class 'AttributeError'>) not raised by unquote
tests/test_future/test_urllib_toplevel.py:785: AssertionError
python3.8:
>>> import urllib.parse
>>> urllib.parse.unquote(b'')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.7/urllib/parse.py", line 609, in unquote
if '%' not in string:
TypeError: a bytes-like object is required, not 'str'
python3.9:
>>> import urllib.parse
>>> urllib.parse.unquote(b'')
''
Metadata
Metadata
Assignees
Labels
No labels