]> granicus.if.org Git - python/commitdiff
Silence DeprecationWarnings in test_urllib.
authorEzio Melotti <ezio.melotti@gmail.com>
Thu, 21 Feb 2013 00:41:42 +0000 (02:41 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Thu, 21 Feb 2013 00:41:42 +0000 (02:41 +0200)
Lib/test/test_urllib.py

index 52e7749d8935bde7253fd4bb498ce94b8ef15bda..4f71b24a0877dfcaffc71cc30ea2f48020ffb189 100644 (file)
@@ -30,7 +30,10 @@ def urlopen(url, data=None, proxies=None):
     if proxies is not None:
         opener = urllib.request.FancyURLopener(proxies=proxies)
     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
     else:
         opener = _urlopener
@@ -1196,14 +1199,16 @@ class URLopener_Tests(unittest.TestCase):
         class DummyURLopener(urllib.request.URLopener):
             def open_spam(self, url):
                 return url
-
-        self.assertEqual(DummyURLopener().open(
-            'spam://example/ /'),'//example/%20/')
-
-        # test the safe characters are not quoted by urlopen
-        self.assertEqual(DummyURLopener().open(
-            "spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
-            "//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
+        with support.check_warnings(
+                ('DummyURLopener style of invoking requests is deprecated.',
+                DeprecationWarning)):
+            self.assertEqual(DummyURLopener().open(
+                'spam://example/ /'),'//example/%20/')
+
+            # test the safe characters are not quoted by urlopen
+            self.assertEqual(DummyURLopener().open(
+                "spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
+                "//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
 
 # Just commented them out.
 # Can't really tell why keep failing in windows and sparc.