Commit 78c1871d authored by Florent Xicluna's avatar Florent Xicluna

Fix and check cgi module deprecation warnings. Revert an unwanted rename in test_import.

parent 945a8ba6
...@@ -45,10 +45,10 @@ from warnings import filterwarnings, catch_warnings, warn ...@@ -45,10 +45,10 @@ from warnings import filterwarnings, catch_warnings, warn
with catch_warnings(): with catch_warnings():
if sys.py3kwarning: if sys.py3kwarning:
filterwarnings("ignore", ".*mimetools has been removed", filterwarnings("ignore", ".*mimetools has been removed",
DeprecationWarning) DeprecationWarning)
filterwarnings("ignore", ".*rfc822 has been removed",
DeprecationWarning)
import mimetools import mimetools
if sys.py3kwarning:
filterwarnings("ignore", ".*rfc822 has been removed", DeprecationWarning)
import rfc822 import rfc822
try: try:
...@@ -180,8 +180,8 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0): ...@@ -180,8 +180,8 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
def parse_qs(qs, keep_blank_values=0, strict_parsing=0): def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
"""Parse a query given as a string argument.""" """Parse a query given as a string argument."""
warn("cgi.parse_qs is deprecated, use urlparse.parse_qs \ warn("cgi.parse_qs is deprecated, use urlparse.parse_qs instead",
instead", PendingDeprecationWarning, 2) PendingDeprecationWarning, 2)
return urlparse.parse_qs(qs, keep_blank_values, strict_parsing) return urlparse.parse_qs(qs, keep_blank_values, strict_parsing)
......
...@@ -4,7 +4,6 @@ import os ...@@ -4,7 +4,6 @@ import os
import sys import sys
import tempfile import tempfile
import unittest import unittest
from StringIO import StringIO
class HackedSysModule: class HackedSysModule:
# The regression test will have real values in sys.argv, which # The regression test will have real values in sys.argv, which
...@@ -340,14 +339,16 @@ this is the content of the fake file ...@@ -340,14 +339,16 @@ this is the content of the fake file
self.assertEqual(result, v) self.assertEqual(result, v)
def test_deprecated_parse_qs(self): 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']}, self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']},
cgi.parse_qs('a=A1&b=B2&B=B3')) cgi.parse_qs('a=A1&b=B2&B=B3'))
def test_deprecated_parse_qsl(self): 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')], self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
cgi.parse_qsl('a=A1&b=B2&B=B3')) cgi.parse_qsl('a=A1&b=B2&B=B3'))
......
...@@ -162,7 +162,7 @@ class ImportTests(unittest.TestCase): ...@@ -162,7 +162,7 @@ class ImportTests(unittest.TestCase):
unlink(filename + 'c') unlink(filename + 'c')
unlink(filename + 'o') unlink(filename + 'o')
def test_0Bfailing_import_sticks(self): def test_failing_import_sticks(self):
source = TESTFN + os.extsep + "py" source = TESTFN + os.extsep + "py"
with open(source, "w") as f: with open(source, "w") as f:
print >> f, "a = 1 // 0" print >> f, "a = 1 // 0"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment