assertForbidden doesn't work because webtest throws error on 403 #5

Closed
Enome opened this Issue Aug 27, 2010 · 2 comments

Projects

None yet

2 participants

Enome commented Aug 27, 2010

In my handler I have:
self.error(403)

But before I can test it with assertForbidden webtest will throw AppError line 403(yeah I know creepy coincidence).

 if res.status_int >= 200 and res.status_int < 400:
      return raise AppError(
            "Bad response: %s (not 200 OK or 3xx redirect for %s)\n%s"
            % (res.status, res.request.url,
               res.body))

I guess the above piece of code is the problem.

Owner
jgeewax commented Aug 27, 2010

Are you using self.get (or post, put, delete...)? (see http://github.com/jgeewax/gaetestbed/blob/master/gaetestbed/web.py#L109)

Those methods set the "status" keyword argument to * which effectively says "even if there's an error, return nicely".

Enome commented Aug 27, 2010

Aha, thanks I was indeed not using self I was using the app directly.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment