#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:
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,

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 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(

View File

@ -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()

View File

@ -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()

View File

@ -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)