Merged revisions 76719,81270-81272,83294,83319,84038-84039 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r76719 | antoine.pitrou | 2009-12-08 20:38:17 +0100 (mar., 08 déc. 2009) | 9 lines
Merged revisions 76718 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76718 | antoine.pitrou | 2009-12-08 20:35:12 +0100 (mar., 08 déc. 2009) | 3 lines
Fix transient refleaks in test_urllib. Thanks to Florent Xicluna.
........
................
r81270 | florent.xicluna | 2010-05-17 19:24:07 +0200 (lun., 17 mai 2010) | 9 lines
Merged revision 81259 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81259 | florent.xicluna | 2010-05-17 12:39:07 +0200 (lun, 17 mai 2010) | 2 lines
Slight style cleanup.
........
................
r81271 | florent.xicluna | 2010-05-17 19:33:07 +0200 (lun., 17 mai 2010) | 11 lines
Issue #1285086: Speed up urllib.parse functions: quote, quote_from_bytes, unquote, unquote_to_bytes.
Recorded merge of revisions 81265 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81265 | florent.xicluna | 2010-05-17 15:35:09 +0200 (lun, 17 mai 2010) | 2 lines
Issue #1285086: Speed up urllib.quote and urllib.unquote for simple cases.
........
................
r81272 | florent.xicluna | 2010-05-17 20:01:22 +0200 (lun., 17 mai 2010) | 2 lines
Inadvertently removed part of the comment in r81271.
................
r83294 | senthil.kumaran | 2010-07-30 21:34:36 +0200 (ven., 30 juil. 2010) | 2 lines
Fix issue9301 - handle unquote({}) kind of case.
................
r83319 | florent.xicluna | 2010-07-31 10:56:55 +0200 (sam., 31 juil. 2010) | 2 lines
Fix an oversight in r83294. unquote() should reject bytes. Issue #9301.
................
r84038 | florent.xicluna | 2010-08-14 20:30:35 +0200 (sam., 14 août 2010) | 1 line
Silence the BytesWarning, due to patch r83294 for #9301
................
r84039 | florent.xicluna | 2010-08-14 22:51:58 +0200 (sam., 14 août 2010) | 1 line
Silence BytesWarning while testing exception
................
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 80cd8ef..775d810 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -261,8 +261,8 @@
result = urllib.request.urlretrieve("file:%s" % support.TESTFN)
self.assertEqual(result[0], support.TESTFN)
self.assertTrue(isinstance(result[1], email.message.Message),
- "did not get a email.message.Message instance as second "
- "returned value")
+ "did not get a email.message.Message instance "
+ "as second returned value")
def test_copy(self):
# Test that setting the filename argument works.
@@ -539,6 +539,7 @@
self.assertEqual(expect, result,
"using quote_plus(): %r != %r" % (expect, result))
+
class UnquotingTests(unittest.TestCase):
"""Tests for unquote() and unquote_plus()
@@ -566,6 +567,10 @@
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():
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, b'')
def test_unquoting_badpercent(self):
# Test unquoting on bad percent-escapes
@@ -600,6 +605,8 @@
result = urllib.parse.unquote_to_bytes(given)
self.assertEqual(expect, result, "using unquote_to_bytes(): %r != %r"
% (expect, result))
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote_to_bytes, None)
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote_to_bytes, ())
def test_unquoting_mixed_case(self):
# Test unquoting on mixed-case hex digits in the percent-escapes
@@ -741,7 +748,7 @@
expect_somewhere = ["1st=1", "2nd=2", "3rd=3"]
result = urllib.parse.urlencode(given)
for expected in expect_somewhere:
- self.assertTrue(expected in result,
+ self.assertIn(expected, result,
"testing %s: %s not found in %s" %
(test_type, expected, result))
self.assertEqual(result.count('&'), 2,
@@ -788,8 +795,7 @@
result = urllib.parse.urlencode(given, True)
for value in given["sequence"]:
expect = "sequence=%s" % value
- self.assertTrue(expect in result,
- "%s not found in %s" % (expect, result))
+ self.assertIn(expect, result)
self.assertEqual(result.count('&'), 2,
"Expected 2 '&'s, got %s" % result.count('&'))