pecan.abort exception changes on each run
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pecan |
Invalid
|
Undecided
|
Unassigned |
Bug Description
There's an issue with the way Pecan chooses exception to raise on pecan.abort(). The exception is selected based only on the http status code, but that's not a 1-many mapping.
When webob initialises the status_map, any out of 5 exceptions can end up being the last one assigned to 500 for example. With some debugging code:
added error 500 = <class 'webob.
added error 500 = <class 'webob.
added error 500 = <class 'webob.
added error 500 = <class 'webob.
added error 500 = <class 'webob.
This wouldn't be that bad if they were all HTTPServerError-s for example. But here WSGIHTTPException comes from a different hierarhy and it's not a child of HTTPServerError, only of HTTPError.
While this doesn't make much difference at runtime and the final response for the user, it affects functional testing of pecan apps. Anchor ran into this issue when testing for failures produced by pecan.abort(500, "..."). On half of the test runs the expected HTTPServerError was caught, on the other half WSGIHTTPException broke the testing.
I think pecan should keep its own status map keeping the most specific errors only (like the table in the comment at https:/
Changed in pecan: | |
status: | New → Invalid |
See https:/ /github. com/pecan/ pecan/pull/ 7