#146: In TESTING mode, pass through exceptions
- From:
- Michael Elsdörfer
- Date:
- 2010-11-28 @ 01:14
This is about https://github.com/mitsuhiko/flask/issues#issue/146
I'm currently testing an app using alfajar (local WSGI-bound browser),
but the same issue arises when using Flask's TestClient.
When the view I am testing raises an exception, I believe the exception
should pass through to the tests, rather than given a 500 response to
the test client, which then may or may not cause the test to fail (while
it usually will, having the stack trace of the exception available is a
big plus).
Django has a DEBUG_PROPAGATE_EXCEPTIONS setting to enable this behavior.
Flask currently does the same thing when DEBUG is enabled, but I might
not want to run my tests in DEBUG mode - that's why there is a TESTING
setting after all.
I only see this breaking peoples test code (it shouldn't affect an app
running in production) if they specifically want to test for a 500
response, in which case this change would break their ability to do so.
I'm not convinced that is actually a particularly useful thing to do,
but if that's an ability we want to retain, then an alternative option
might be to add another setting, similar to Django's
DEBUG_PROPAGATE_EXCEPTIONS (note however that Django does not have a
separate TESTING mode).
However, grepping through the Flask source it seems that the TESTING
setting currently isn't used anywhere, i.e. has no actual effect, so
given that, I'm dubious as to whether a second one is really what we want.
Re: [flask] #146: In TESTING mode, pass through exceptions
- From:
- Armin Ronacher
- Date:
- 2010-11-28 @ 14:45
Hi,
On 2010-11-28 2:14 AM, Michael Elsdörfer wrote:
> However, grepping through the Flask source it seems that the TESTING
> setting currently isn't used anywhere, i.e. has no actual effect, so
> given that, I'm dubious as to whether a second one is really what we want.
TESTING was introduced to aid exceptions switch into testing mode, it
was however not used in Flask internally so far. I would like to change
it with 0.7 to propagate exceptions on TESTING but I will add a separate
flag called PROPAGATE_EXCEPTIONS that can be used to override the
setting from TESTING.
If anyone can think of a nicer way, let me know.
Regards,
Armin
Re: [flask] #146: In TESTING mode, pass through exceptions
- From:
- Armin Ronacher
- Date:
- 2010-11-29 @ 07:58
Hi,
On 11/28/10 3:45 PM, Armin Ronacher wrote:
> TESTING was introduced to aid exceptions switch into testing mode, it
> was however not used in Flask internally so far. I would like to change
> it with 0.7 to propagate exceptions on TESTING but I will add a separate
> flag called PROPAGATE_EXCEPTIONS that can be used to override the
> setting from TESTING.
Implemented on git:master
Regards,
Armin