mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
Issue #16220: wsgiref now always calls close() on an iterable response.
Patch by Brent Tubbs.
This commit is contained in:
parent
2778d0d147
commit
ae247a5ff6
4 changed files with 29 additions and 36 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue