#7092: silence more -3 and -Wd warnings

This commit is contained in:
Ezio Melotti 2010-01-31 11:46:54 +00:00
parent 46bff79d1f
commit ef4909643d
5 changed files with 41 additions and 33 deletions

View File

@ -172,7 +172,7 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
else: else:
qs = "" qs = ""
environ['QUERY_STRING'] = qs # XXX Shouldn't, really 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, # parse query string function called from urlparse,

View File

@ -1,4 +1,4 @@
from test.test_support import run_unittest from test.test_support import run_unittest, check_warnings
import cgi import cgi
import os import os
import sys 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): def first_elts(list):
return map(lambda x:x[0], list) return map(lambda x:x[0], list)
@ -141,18 +136,18 @@ class CgiTests(unittest.TestCase):
if type(expect) == type({}): if type(expect) == type({}):
# test dict interface # test dict interface
self.assertEqual(len(expect), len(fcd)) self.assertEqual(len(expect), len(fcd))
self.assertEqual(norm(expect.keys()), norm(fcd.keys())) self.assertSameElements(expect.keys(), fcd.keys())
self.assertEqual(norm(expect.values()), norm(fcd.values())) self.assertSameElements(expect.values(), fcd.values())
self.assertEqual(norm(expect.items()), norm(fcd.items())) self.assertSameElements(expect.items(), fcd.items())
self.assertEqual(fcd.get("nonexistent field", "default"), "default") self.assertEqual(fcd.get("nonexistent field", "default"), "default")
self.assertEqual(len(sd), len(fs)) 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") self.assertEqual(fs.getvalue("nonexistent field", "default"), "default")
# test individual fields # test individual fields
for key in expect.keys(): for key in expect.keys():
expect_val = expect[key] expect_val = expect[key]
self.assertTrue(fcd.has_key(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.assertEqual(fcd.get(key, "default"), fcd[key])
self.assertTrue(fs.has_key(key)) self.assertTrue(fs.has_key(key))
if len(expect_val) > 1: if len(expect_val) > 1:
@ -168,12 +163,12 @@ class CgiTests(unittest.TestCase):
self.assertTrue(single_value) self.assertTrue(single_value)
self.assertEqual(val, expect_val[0]) self.assertEqual(val, expect_val[0])
self.assertEqual(fs.getvalue(key), 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: if single_value:
self.assertEqual(norm(sd.values()), self.assertSameElements(sd.values(),
first_elts(norm(expect.values()))) first_elts(expect.values()))
self.assertEqual(norm(sd.items()), self.assertSameElements(sd.items(),
first_second_elts(norm(expect.items()))) first_second_elts(expect.items()))
def test_weird_formcontentdict(self): def test_weird_formcontentdict(self):
# Test the weird FormContentDict classes # Test the weird FormContentDict classes
@ -184,7 +179,7 @@ class CgiTests(unittest.TestCase):
self.assertEqual(d[k], v) self.assertEqual(d[k], v)
for k, v in d.items(): for k, v in d.items():
self.assertEqual(expect[k], v) self.assertEqual(expect[k], v)
self.assertEqual(norm(expect.values()), norm(d.values())) self.assertSameElements(expect.values(), d.values())
def test_log(self): def test_log(self):
cgi.log("Testing") cgi.log("Testing")
@ -345,11 +340,13 @@ 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():
# this func is moved to urlparse, this is just a sanity check # this func is moved to urlparse, this is just a sanity check
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():
# this func is moved to urlparse, this is just a sanity check # this func is moved to urlparse, this is just a sanity check
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'))

View File

@ -223,7 +223,9 @@ def process_infix_results():
infix_results[key] = res infix_results[key] = res
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "classic int division",
DeprecationWarning)
process_infix_results() process_infix_results()
# now infix_results has two lists of results for every pairing. # now infix_results has two lists of results for every pairing.
@ -337,10 +339,11 @@ class CoercionTest(unittest.TestCase):
raise exc raise exc
def test_main(): def test_main():
warnings.filterwarnings("ignore", with warnings.catch_warnings():
r'complex divmod\(\), // and % are deprecated', warnings.filterwarnings("ignore", "complex divmod.., // and % "
DeprecationWarning, "are deprecated", DeprecationWarning)
r'test.test_coercion$') warnings.filterwarnings("ignore", "classic (int|long) division",
DeprecationWarning)
run_unittest(CoercionTest) run_unittest(CoercionTest)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -7,9 +7,14 @@ be run.
import distutils.tests import distutils.tests
import test.test_support import test.test_support
import warnings
def test_main(): def test_main():
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.run_unittest(distutils.tests.test_suite())
test.test_support.reap_children() test.test_support.reap_children()

View File

@ -136,7 +136,10 @@ class MutableStringTest(UserStringTest):
def test_main(): def test_main():
with warnings.catch_warnings(): 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) DeprecationWarning)
test_support.run_unittest(UserStringTest, MutableStringTest) test_support.run_unittest(UserStringTest, MutableStringTest)