diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-10-21 12:09:05 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-10-21 12:09:05 (GMT) |
commit | ae247a5ff6bd937f2049b2d403893d46840dfc21 (patch) | |
tree | 01cec3294190fbaeb7bc03bdd0761d1e7d3bee97 /Lib/test/test_wsgiref.py | |
parent | 2778d0d1477f854d7443075a21369fde2032d43c (diff) | |
download | cpython-ae247a5ff6bd937f2049b2d403893d46840dfc21.zip cpython-ae247a5ff6bd937f2049b2d403893d46840dfc21.tar.gz cpython-ae247a5ff6bd937f2049b2d403893d46840dfc21.tar.bz2 |
Issue #16220: wsgiref now always calls close() on an iterable response.
Patch by Brent Tubbs.
Diffstat (limited to 'Lib/test/test_wsgiref.py')
-rw-r--r-- | Lib/test/test_wsgiref.py | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index a08f66b..c06f94a 100644 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -656,40 +656,27 @@ class HandlerTests(TestCase): b"data", h.stdout.getvalue()) -# This epilogue is needed for compatibility with the Python 2.5 regrtest module + def testCloseOnError(self): + side_effects = {'close_called': False} + MSG = b"Some output has been sent" + def error_app(e,s): + s("200 OK",[])(MSG) + class CrashyIterable(object): + def __iter__(self): + while True: + yield b'blah' + raise AssertionError("This should be caught by handler") + def close(self): + side_effects['close_called'] = True + return CrashyIterable() + + h = ErrorHandler() + h.run(error_app) + self.assertEqual(side_effects['close_called'], True) + def test_main(): support.run_unittest(__name__) if __name__ == "__main__": test_main() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# the above lines intentionally left blank |