]> granicus.if.org Git - python/commitdiff
Added a warning filter to don't show the warning during
authorFacundo Batista <facundobatista@gmail.com>
Tue, 9 Sep 2008 02:43:19 +0000 (02:43 +0000)
committerFacundo Batista <facundobatista@gmail.com>
Tue, 9 Sep 2008 02:43:19 +0000 (02:43 +0000)
the tests. Also fixed the warning message in cgi.py

Lib/cgi.py
Lib/test/test_cgi.py

index d1ac4be70263ae29dd8093719c9f10ada4413ca0..e62fcf2c7fc20ce350b81c033ed7d7509b28dc34 100755 (executable)
@@ -168,7 +168,7 @@ def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
 
 def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
     """Parse a query given as a string argument."""
-    warn("cgi.parse_qsl is deprecated, use urllib.parse.parse_qs instead",
+    warn("cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead",
             DeprecationWarning)
     return urllib.parse.parse_qsl(qs, keep_blank_values, strict_parsing)
 
index 9491001bb47911c194c9ac4e6593a0c4b8233b37..0c53d8f0967b5de2e3d231898b54112f02531cee 100644 (file)
@@ -5,6 +5,7 @@ import sys
 import tempfile
 import unittest
 from io import StringIO
+from warnings import catch_warnings, filterwarnings
 
 class HackedSysModule:
     # The regression test will have real values in sys.argv, which
@@ -308,13 +309,21 @@ this is the content of the fake file
 
     def test_deprecated_parse_qs(self):
         # this func is moved to urlparse, this is just a sanity check
-        self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']},
-                         cgi.parse_qs('a=A1&b=B2&B=B3'))
+        with catch_warnings():
+            filterwarnings('ignore',
+                'cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead',
+                DeprecationWarning)
+            self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']},
+                             cgi.parse_qs('a=A1&b=B2&B=B3'))
 
     def test_deprecated_parse_qsl(self):
         # this func is moved to urlparse, this is just a sanity check
-        self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
-                         cgi.parse_qsl('a=A1&b=B2&B=B3'))
+        with catch_warnings():
+            filterwarnings('ignore',
+                'cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead',
+                DeprecationWarning)
+            self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
+                             cgi.parse_qsl('a=A1&b=B2&B=B3'))
 
 def test_main():
     run_unittest(CgiTests)