diff options
Diffstat (limited to 'paste/wsgilib.py')
-rw-r--r-- | paste/wsgilib.py | 21 |
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 |