summaryrefslogtreecommitdiff
path: root/paste/wsgilib.py
diff options
context:
space:
mode:
authorianb <devnull@localhost>2006-02-28 20:25:58 +0000
committerianb <devnull@localhost>2006-02-28 20:25:58 +0000
commit7a97d609a29051be71db1e746b7ccb773f50addf (patch)
tree358233764796ecab5d3b0a74ce63e40d9b21e970 /paste/wsgilib.py
parentbeb6deb1dd0680a785699cbd89190b4d084bd74f (diff)
downloadpaste-7a97d609a29051be71db1e746b7ccb773f50addf.tar.gz
If we don't expect errors in wsgi.errors, raise an exception immediately when the error message is printed, instead of waiting until the end
Diffstat (limited to 'paste/wsgilib.py')
-rw-r--r--paste/wsgilib.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/paste/wsgilib.py b/paste/wsgilib.py
index 8b11035..a7932a3 100644
--- a/paste/wsgilib.py
+++ b/paste/wsgilib.py
@@ -160,12 +160,16 @@ class _wrap_app_iter_app(object):
self.next = app_iter.next
return self.next()
-def raw_interactive(application, path='', **environ):
+def raw_interactive(application, path='', raise_on_wsgi_error=False,
+ **environ):
"""
Runs the application in a fake environment.
"""
assert "path_info" not in environ, "argument list changed"
- errors = StringIO()
+ if raise_on_wsgi_errors:
+ errors = ErrorRaiser()
+ else:
+ errors = StringIO()
basic_environ = {
# mandatory CGI variables
'REQUEST_METHOD': 'GET', # always mandatory
@@ -241,6 +245,19 @@ def raw_interactive(application, path='', **environ):
return (data['status'], data['headers'], ''.join(output),
errors.getvalue())
+class ErrorRaiser(object):
+
+ def flush(self):
+ pass
+
+ def write(self, value):
+ raise AssertionError(
+ "No errors should be written (got: %r)" % value)
+
+ def writelines(self, seq):
+ raise AssertionError(
+ "No errors should be written (got lines: %s)" % list(seq))
+
def interactive(*args, **kw):
"""
Runs the application interatively, wrapping `raw_interactive` but