I'm using zope.testbrowser to test a pyramid application I'm working on. I'd really like to get the Browser.handleErrors knob working.
zope.testbrowser puts two variables into the WSGI envronment to try get the application it's testing to throw rather than catch errors:
if not handle_errors: # There doesn't seem to be a "Right Way" to do this extra_environ['wsgi.handleErrors'] = False # zope.app.wsgi does this extra_environ['paste.throw_errors'] = True # the paste way of doing this
Perhaps it's as simple as putting this in pyramid/router.py:
if not environ.get('wsgi.handleErrors', True): raise
But I'm guessing not. Any advice before I start working up a patch?
> -- > You received this message because you are subscribed to the Google Groups "pylons-devel" group. > To post to this group, send email to pylons-devel@googlegroups.com. > To unsubscribe from this group, send email to pylons-devel+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.
> I'm using zope.testbrowser to test a pyramid application I'm working on. > I'd really like to get the Browser.handleErrors knob working.
> zope.testbrowser puts two variables into the WSGI envronment to try get > the application it's testing to throw rather than catch errors:
> if not handle_errors: > # There doesn't seem to be a "Right Way" to do this > extra_environ['wsgi.handleErrors'] = False # zope.app.wsgi does this > extra_environ['paste.throw_errors'] = True # the paste way of doing this
> Perhaps it's as simple as putting this in pyramid/router.py:
> if not environ.get('wsgi.handleErrors', True): > raise
> But I'm guessing not. Any advice before I start working up a patch?
I'm not sure what you mean exactly, but have you tried setting browser.raiseHttpErrors = False ?
Wichert.
-- Wichert Akkerman <wich...@wiggy.net> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple.
On Tue, May 24, 2011 at 08:41:38PM +0200, Wichert Akkerman wrote: > On 2011-5-24 18:48, Brian Sutherland wrote: > >Hi,
> >I'm using zope.testbrowser to test a pyramid application I'm working on. > >I'd really like to get the Browser.handleErrors knob working.
> >zope.testbrowser puts two variables into the WSGI envronment to try get > >the application it's testing to throw rather than catch errors:
> > if not handle_errors: > > # There doesn't seem to be a "Right Way" to do this > > extra_environ['wsgi.handleErrors'] = False # zope.app.wsgi does this > > extra_environ['paste.throw_errors'] = True # the paste way of doing this
> >Perhaps it's as simple as putting this in pyramid/router.py:
> > if not environ.get('wsgi.handleErrors', True): > > raise
> >But I'm guessing not. Any advice before I start working up a patch?
> I'm not sure what you mean exactly, but have you tried setting > browser.raiseHttpErrors = False ?
raiseHttpErrors is slightly different from handleErrors and doesn't require any help from the WSGI application under test:
I mostly use handleErrors to quickly debug test failures. i.e. when an exception is raised inside a view but then converted to a nicely formatted error page by a bare try/except.
In that case you want to quickly see the exception rather than the HTML error page.
The specific bare try/except bothering me in this case is in pyramid.router.Router.__call__.