Skip to content

Commit

Permalink
A basic test for changes to "start_response".
Browse files Browse the repository at this point in the history
  • Loading branch information
satchit committed May 11, 2011
1 parent 4a4e600 commit 07e3063
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/zope/server/http/tests/test_wsgiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,42 @@ def write(self, v):

self.server.application = orig_app

def test_exception_handling(self):
# some applications/middleware (like repoze.retry) might pass the
# exc_info to start_response.

orig_app = self.server.application

class DummyException(Exception):
value = "Dummy Exception to test start_response"
def __str__(self):
return repr(self.value)

def app(environ, start_response):
try:
start_response(
"500 Error",
[],
(DummyException, DummyException.value, None))
except DummyException as e:
return e.value.split()

class FakeTask:
response = []
getCGIEnvironment = lambda _: {}
class request_data:
getBodyStream = lambda _: StringIO.StringIO()
request_data = request_data()
setResponseStatus = appendResponseHeaders = lambda *_: None
def write(self, v):
self.response.append(v)

self.server.application = app
task = FakeTask()
self.server.executeRequest(task)

self.assertEqual(task.response, DummyException.value.split())
self.server.application = orig_app

class PMDBTests(Tests):

Expand Down

0 comments on commit 07e3063

Please sign in to comment.