Kaydet (Commit) 79b99dba authored tarafından Ezio Melotti's avatar Ezio Melotti

Silence DeprecationWarnings in test_urllib.

üst 6f43a909
...@@ -30,7 +30,10 @@ def urlopen(url, data=None, proxies=None): ...@@ -30,7 +30,10 @@ def urlopen(url, data=None, proxies=None):
if proxies is not None: if proxies is not None:
opener = urllib.request.FancyURLopener(proxies=proxies) opener = urllib.request.FancyURLopener(proxies=proxies)
elif not _urlopener: elif not _urlopener:
opener = urllib.request.FancyURLopener() with support.check_warnings(
('FancyURLopener style of invoking requests is deprecated.',
DeprecationWarning)):
opener = urllib.request.FancyURLopener()
_urlopener = opener _urlopener = opener
else: else:
opener = _urlopener opener = _urlopener
...@@ -1196,14 +1199,16 @@ class URLopener_Tests(unittest.TestCase): ...@@ -1196,14 +1199,16 @@ class URLopener_Tests(unittest.TestCase):
class DummyURLopener(urllib.request.URLopener): class DummyURLopener(urllib.request.URLopener):
def open_spam(self, url): def open_spam(self, url):
return url return url
with support.check_warnings(
self.assertEqual(DummyURLopener().open( ('DummyURLopener style of invoking requests is deprecated.',
'spam://example/ /'),'//example/%20/') DeprecationWarning)):
self.assertEqual(DummyURLopener().open(
# test the safe characters are not quoted by urlopen 'spam://example/ /'),'//example/%20/')
self.assertEqual(DummyURLopener().open(
"spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"), # test the safe characters are not quoted by urlopen
"//c:|windows%/:=&?~#+!$,;'@()*[]|/path/") self.assertEqual(DummyURLopener().open(
"spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
"//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
# Just commented them out. # Just commented them out.
# Can't really tell why keep failing in windows and sparc. # Can't really tell why keep failing in windows and sparc.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment