Merge "swob: Raise RuntimeError instead of IndexError"
This commit is contained in:
commit
097a9083ec
@ -999,6 +999,8 @@ class Request(object):
|
||||
app_iter = output
|
||||
if not captured:
|
||||
app_iter = reiterate(app_iter)
|
||||
if not captured:
|
||||
raise RuntimeError('application never called start_response')
|
||||
return (captured[0], captured[1], app_iter)
|
||||
|
||||
def get_response(self, application):
|
||||
|
@ -1079,6 +1079,30 @@ class TestResponse(unittest.TestCase):
|
||||
app_iter.close()
|
||||
self.assertRaises(StopIteration, iterator.next)
|
||||
|
||||
def test_call_finds_nonempty_chunk(self):
|
||||
def test_app(environ, start_response):
|
||||
start_response('400 Bad Request', [])
|
||||
yield ''
|
||||
start_response('200 OK', [])
|
||||
yield 'complete '
|
||||
yield ''
|
||||
yield 'response'
|
||||
req = swift.common.swob.Request.blank('/')
|
||||
req.method = 'GET'
|
||||
status, headers, app_iter = req.call_application(test_app)
|
||||
self.assertEqual(status, '200 OK')
|
||||
self.assertEqual(list(app_iter), ['complete ', '', 'response'])
|
||||
|
||||
def test_call_requires_that_start_response_is_called(self):
|
||||
def test_app(environ, start_response):
|
||||
yield 'response'
|
||||
req = swift.common.swob.Request.blank('/')
|
||||
req.method = 'GET'
|
||||
with self.assertRaises(RuntimeError) as mgr:
|
||||
req.call_application(test_app)
|
||||
self.assertEqual(mgr.exception.args[0],
|
||||
'application never called start_response')
|
||||
|
||||
def test_location_rewrite(self):
|
||||
def start_response(env, headers):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user