summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/cgi.py2
-rw-r--r--Lib/test/test_cgi.py43
-rw-r--r--Lib/test/test_coercion.py17
-rw-r--r--Lib/test/test_distutils.py7
-rwxr-xr-xLib/test/test_userstring.py5
5 files changed, 41 insertions, 33 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index fd30383..db10a62 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -172,7 +172,7 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
else:
qs = ""
environ['QUERY_STRING'] = qs # XXX Shouldn't, really
- return parse_qs(qs, keep_blank_values, strict_parsing)
+ return urlparse.parse_qs(qs, keep_blank_values, strict_parsing)
# parse query string function called from urlparse,
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index aa26bb6..5b53291 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -1,4 +1,4 @@
-from test.test_support import run_unittest
+from test.test_support import run_unittest, check_warnings
import cgi
import os
import sys
@@ -102,11 +102,6 @@ parse_strict_test_cases = [
})
]
-def norm(list):
- if type(list) == type([]):
- list.sort()
- return list
-
def first_elts(list):
return map(lambda x:x[0], list)
@@ -141,18 +136,18 @@ class CgiTests(unittest.TestCase):
if type(expect) == type({}):
# test dict interface
self.assertEqual(len(expect), len(fcd))
- self.assertEqual(norm(expect.keys()), norm(fcd.keys()))
- self.assertEqual(norm(expect.values()), norm(fcd.values()))
- self.assertEqual(norm(expect.items()), norm(fcd.items()))
+ self.assertSameElements(expect.keys(), fcd.keys())
+ self.assertSameElements(expect.values(), fcd.values())
+ self.assertSameElements(expect.items(), fcd.items())
self.assertEqual(fcd.get("nonexistent field", "default"), "default")
self.assertEqual(len(sd), len(fs))
- self.assertEqual(norm(sd.keys()), norm(fs.keys()))
+ self.assertSameElements(sd.keys(), fs.keys())
self.assertEqual(fs.getvalue("nonexistent field", "default"), "default")
# test individual fields
for key in expect.keys():
expect_val = expect[key]
self.assertTrue(fcd.has_key(key))
- self.assertEqual(norm(fcd[key]), norm(expect[key]))
+ self.assertSameElements(fcd[key], expect[key])
self.assertEqual(fcd.get(key, "default"), fcd[key])
self.assertTrue(fs.has_key(key))
if len(expect_val) > 1:
@@ -168,12 +163,12 @@ class CgiTests(unittest.TestCase):
self.assertTrue(single_value)
self.assertEqual(val, expect_val[0])
self.assertEqual(fs.getvalue(key), expect_val[0])
- self.assertEqual(norm(sd.getlist(key)), norm(expect_val))
+ self.assertSameElements(sd.getlist(key), expect_val)
if single_value:
- self.assertEqual(norm(sd.values()),
- first_elts(norm(expect.values())))
- self.assertEqual(norm(sd.items()),
- first_second_elts(norm(expect.items())))
+ self.assertSameElements(sd.values(),
+ first_elts(expect.values()))
+ self.assertSameElements(sd.items(),
+ first_second_elts(expect.items()))
def test_weird_formcontentdict(self):
# Test the weird FormContentDict classes
@@ -184,7 +179,7 @@ class CgiTests(unittest.TestCase):
self.assertEqual(d[k], v)
for k, v in d.items():
self.assertEqual(expect[k], v)
- self.assertEqual(norm(expect.values()), norm(d.values()))
+ self.assertSameElements(expect.values(), d.values())
def test_log(self):
cgi.log("Testing")
@@ -345,14 +340,16 @@ this is the content of the fake file
self.assertEqual(result, v)
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 check_warnings():
+ # 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'))
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 check_warnings():
+ # 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'))
def test_parse_header(self):
self.assertEqual(
diff --git a/Lib/test/test_coercion.py b/Lib/test/test_coercion.py
index 67d19a6..34eb19e 100644
--- a/Lib/test/test_coercion.py
+++ b/Lib/test/test_coercion.py
@@ -223,8 +223,10 @@ def process_infix_results():
infix_results[key] = res
-
-process_infix_results()
+with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", "classic int division",
+ DeprecationWarning)
+ process_infix_results()
# now infix_results has two lists of results for every pairing.
prefix_binops = [ 'divmod' ]
@@ -337,11 +339,12 @@ class CoercionTest(unittest.TestCase):
raise exc
def test_main():
- warnings.filterwarnings("ignore",
- r'complex divmod\(\), // and % are deprecated',
- DeprecationWarning,
- r'test.test_coercion$')
- run_unittest(CoercionTest)
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", "complex divmod.., // and % "
+ "are deprecated", DeprecationWarning)
+ warnings.filterwarnings("ignore", "classic (int|long) division",
+ DeprecationWarning)
+ run_unittest(CoercionTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_distutils.py b/Lib/test/test_distutils.py
index 2d871d3..0a54c57 100644
--- a/Lib/test/test_distutils.py
+++ b/Lib/test/test_distutils.py
@@ -7,10 +7,15 @@ be run.
import distutils.tests
import test.test_support
+import warnings
def test_main():
- test.test_support.run_unittest(distutils.tests.test_suite())
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore",
+ "distutils.sysconfig.\w+ is deprecated",
+ DeprecationWarning)
+ test.test_support.run_unittest(distutils.tests.test_suite())
test.test_support.reap_children()
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index b2d2e67..7e5df78 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -136,7 +136,10 @@ class MutableStringTest(UserStringTest):
def test_main():
with warnings.catch_warnings():
- warnings.filterwarnings("ignore", ".*MutableString",
+ warnings.filterwarnings("ignore", ".*MutableString has been removed",
+ DeprecationWarning)
+ warnings.filterwarnings("ignore",
+ ".*__(get|set|del)slice__ has been removed",
DeprecationWarning)
test_support.run_unittest(UserStringTest, MutableStringTest)