with catch_warnings():
if sys.py3kwarning:
filterwarnings("ignore", ".*mimetools has been removed",
- DeprecationWarning)
+ DeprecationWarning)
+ filterwarnings("ignore", ".*rfc822 has been removed",
+ DeprecationWarning)
import mimetools
- if sys.py3kwarning:
- filterwarnings("ignore", ".*rfc822 has been removed", DeprecationWarning)
import rfc822
try:
def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
"""Parse a query given as a string argument."""
- warn("cgi.parse_qs is deprecated, use urlparse.parse_qs \
- instead", PendingDeprecationWarning, 2)
+ warn("cgi.parse_qs is deprecated, use urlparse.parse_qs instead",
+ PendingDeprecationWarning, 2)
return urlparse.parse_qs(qs, keep_blank_values, strict_parsing)
import sys
import tempfile
import unittest
-from StringIO import StringIO
class HackedSysModule:
# The regression test will have real values in sys.argv, which
self.assertEqual(result, v)
def test_deprecated_parse_qs(self):
- with check_warnings(quiet=False):
- # this func is moved to urlparse, this is just a sanity check
+ # this func is moved to urlparse, this is just a sanity check
+ with check_warnings(('cgi.parse_qs is deprecated, use urlparse.'
+ 'parse_qs instead', PendingDeprecationWarning)):
self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']},
cgi.parse_qs('a=A1&b=B2&B=B3'))
def test_deprecated_parse_qsl(self):
- with check_warnings(quiet=False):
- # this func is moved to urlparse, this is just a sanity check
+ # this func is moved to urlparse, this is just a sanity check
+ with check_warnings(('cgi.parse_qsl is deprecated, use urlparse.'
+ 'parse_qsl instead', PendingDeprecationWarning)):
self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
cgi.parse_qsl('a=A1&b=B2&B=B3'))