zope.testbrowser's handleErrors and pyramid

28 views
Skip to first unread message

Brian Sutherland

unread,
May 24, 2011, 12:48:03 PM5/24/11
to Pylons Devel
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?

--
Brian Sutherland

Gael Pasgrimaud

unread,
May 24, 2011, 12:55:34 PM5/24/11
to pylons...@googlegroups.com
Hi,

On Tue, May 24, 2011 at 6:48 PM, Brian Sutherland
<br...@vanguardistas.net> wrote:
>
> But I'm guessing not. Any advice before I start working up a patch?
>

Use WebTest ? Just a thought. Maybe you really want to use zope.testbrowser.

--
Gael

> --
> Brian Sutherland
>
> --
> You received this message because you are subscribed to the Google Groups "pylons-devel" group.
> To post to this group, send email to pylons...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-devel...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.
>
>

Brian Sutherland

unread,
May 24, 2011, 1:25:51 PM5/24/11
to pylons...@googlegroups.com
On Tue, May 24, 2011 at 06:55:34PM +0200, Gael Pasgrimaud wrote:
> Hi,
>
> On Tue, May 24, 2011 at 6:48 PM, Brian Sutherland
> <br...@vanguardistas.net> wrote:
> >
> > But I'm guessing not. Any advice before I start working up a patch?
> >
>
> Use WebTest ? Just a thought. Maybe you really want to use zope.testbrowser.

Same question really. How do I ask, with WebTest, for the error not to
be caught?

http://pythonpaste.org/webtest/#framework-hooks mentions "paste.throw_errors".

--
Brian Sutherland

Wichert Akkerman

unread,
May 24, 2011, 2:41:38 PM5/24/11
to pylons...@googlegroups.com

I'm not sure what you mean exactly, but have you tried setting
browser.raiseHttpErrors = False ?

Wichert.


--
Wichert Akkerman <wic...@wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.

Brian Sutherland

unread,
May 25, 2011, 5:00:26 AM5/25/11
to pylons...@googlegroups.com
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:

http://pypi.python.org/pypi/zope.testbrowser#handling-errors

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__.

--
Brian Sutherland

Reply all
Reply to author
Forward
0 new messages