Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79b99db

Browse files
committed
Silence DeprecationWarnings in test_urllib.
1 parent 6f43a90 commit 79b99db

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

Lib/test/test_urllib.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def urlopen(url, data=None, proxies=None):
3030
if proxies is not None:
3131
opener = urllib.request.FancyURLopener(proxies=proxies)
3232
elif not _urlopener:
33-
opener = urllib.request.FancyURLopener()
33+
with support.check_warnings(
34+
('FancyURLopener style of invoking requests is deprecated.',
35+
DeprecationWarning)):
36+
opener = urllib.request.FancyURLopener()
3437
_urlopener = opener
3538
else:
3639
opener = _urlopener
@@ -1196,14 +1199,16 @@ def test_quoted_open(self):
11961199
class DummyURLopener(urllib.request.URLopener):
11971200
def open_spam(self, url):
11981201
return url
1199-
1200-
self.assertEqual(DummyURLopener().open(
1201-
'spam://example/ /'),'//example/%20/')
1202-
1203-
# test the safe characters are not quoted by urlopen
1204-
self.assertEqual(DummyURLopener().open(
1205-
"spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
1206-
"//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
1202+
with support.check_warnings(
1203+
('DummyURLopener style of invoking requests is deprecated.',
1204+
DeprecationWarning)):
1205+
self.assertEqual(DummyURLopener().open(
1206+
'spam://example/ /'),'//example/%20/')
1207+
1208+
# test the safe characters are not quoted by urlopen
1209+
self.assertEqual(DummyURLopener().open(
1210+
"spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
1211+
"//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
12071212

12081213
# Just commented them out.
12091214
# Can't really tell why keep failing in windows and sparc.

0 commit comments

Comments
 (0)