diff options
author | Tim Peters <tim.peters@gmail.com> | 2006-06-11 20:52:59 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2006-06-11 20:52:59 (GMT) |
commit | 06524b61d05c604543e6d3603dee11425ccff637 (patch) | |
tree | ed8bb651216df9557611d78b8280476b71c748f5 /Lib | |
parent | 896c1ea15e9ec67fd1b33998ba8daaf17528ba31 (diff) | |
download | cpython-06524b61d05c604543e6d3603dee11425ccff637.zip cpython-06524b61d05c604543e6d3603dee11425ccff637.tar.gz cpython-06524b61d05c604543e6d3603dee11425ccff637.tar.bz2 |
compare_generic_iter(): Fixed the failure of test_wsgiref's testFileWrapper
when running with -O.
test_simple_validation_error still fails under -O. That appears to be because
wsgiref's validate.py uses `assert` statements all over the place to check
arguments for sanity. That should all be changed (it's not a logical error
in the software if a user passes bogus arguments, so this isn't a reasonable
use for `assert` -- checking external preconditions should generally raise
ValueError or TypeError instead, as appropriate).
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/test/test_wsgiref.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index f939764..c8d1262 100755 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -80,7 +80,7 @@ def run_amock(app=hello_app, data="GET / HTTP/1.0\n\n"): -def compare_generic_iter(make_it,match): +def compare_generic_iter(test, make_it, match): """Utility to compare a generic 2.1/2.2+ iterator with an iterable If running under Python 2.2+, this tests the iterator using iter()/next(), @@ -90,7 +90,7 @@ def compare_generic_iter(make_it,match): it = make_it() n = 0 for item in match: - assert it[n]==item + test.assertEqual(it[n], item) n+=1 try: it[n] @@ -106,15 +106,10 @@ def compare_generic_iter(make_it,match): else: # Only test iter mode under 2.2+ it = make_it() - assert iter(it) is it + test.assert_(iter(it) is it) for item in match: - assert it.next()==item - try: - it.next() - except StopIteration: - pass - else: - raise AssertionError("Too many items from .next()",it) + test.assertEqual(it.next(), item) + test.assertRaises(StopIteration, it.next) @@ -208,7 +203,7 @@ class UtilityTests(TestCase): def make_it(text=text,size=size): return util.FileWrapper(StringIO(text),size) - compare_generic_iter(make_it,match) + compare_generic_iter(self, make_it, match) it = make_it() self.failIf(it.filelike.closed) @@ -440,7 +435,7 @@ class HandlerTests(TestCase): h = BaseCGIHandler(None,None,None,{}) h.setup_environ() for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors': - assert h.environ.has_key(key) + self.assert_(h.environ.has_key(key)) def testScheme(self): h=TestHandler(HTTPS="on"); h.setup_environ() |