Fix for subtle bug from 5c8f9c52e3
Change-Id: If2bd1d4a850936b2e575a96073c116a8b9522602
This commit is contained in:
parent
c1964e5f6a
commit
5f19ccf28f
@ -249,10 +249,6 @@ class WSGIContext(object):
|
||||
"""
|
||||
def __init__(self, wsgi_app):
|
||||
self.app = wsgi_app
|
||||
# Results from the last call to self._start_response.
|
||||
self._response_status = None
|
||||
self._response_headers = None
|
||||
self._response_exc_info = None
|
||||
|
||||
def _start_response(self, status, headers, exc_info=None):
|
||||
"""
|
||||
@ -267,6 +263,9 @@ class WSGIContext(object):
|
||||
"""
|
||||
Ensures start_response has been called before returning.
|
||||
"""
|
||||
self._response_status = None
|
||||
self._response_headers = None
|
||||
self._response_exc_info = None
|
||||
resp = self.app(env, self._start_response)
|
||||
# if start_response has been called, just return the iter
|
||||
if self._response_status is not None:
|
||||
|
@ -238,5 +238,25 @@ class TestWSGI(unittest.TestCase):
|
||||
self.assertEquals(e['PATH_INFO'], '/override')
|
||||
|
||||
|
||||
class TestWSGIContext(unittest.TestCase):
|
||||
|
||||
def test_app_call(self):
|
||||
statuses = ['200 Ok', '404 Not Found']
|
||||
|
||||
def app(env, start_response):
|
||||
start_response(statuses.pop(0), [('Content-Length', '3')])
|
||||
yield 'Ok\n'
|
||||
|
||||
wc = wsgi.WSGIContext(app)
|
||||
r = Request.blank('/')
|
||||
it = wc._app_call(r.environ)
|
||||
self.assertEquals(wc._response_status, '200 Ok')
|
||||
self.assertEquals(''.join(it), 'Ok\n')
|
||||
r = Request.blank('/')
|
||||
it = wc._app_call(r.environ)
|
||||
self.assertEquals(wc._response_status, '404 Not Found')
|
||||
self.assertEquals(''.join(it), 'Ok\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user