diff Lib/test/test_cgi.py @ 49101:c46bcccf2af2

Added a warning filter to don't show the warning during the tests. Also fixed the warning message in cgi.py
author Facundo Batista <facundobatista@gmail.com>
date Tue, 09 Sep 2008 02:43:19 +0000
parents f085f39a6f4d
children 89e738c792c0
line wrap: on
line diff
--- a/Lib/test/test_cgi.py	Tue Sep 09 01:52:27 2008 +0000
+++ b/Lib/test/test_cgi.py	Tue Sep 09 02:43:19 2008 +0000
@@ -5,6 +5,7 @@
 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 @@
 
     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)