#27893: Make it possible to disable exception re-raising in test client
---------------------------------------------+------------------------
               Reporter:  Carl Meyer         |          Owner:  nobody
                   Type:  New feature        |         Status:  new
              Component:  Testing framework  |        Version:  1.10
               Severity:  Normal             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 In the Django test client, we connect to the `got_request_exception`
 signal, store any signalled exception on the test client, and then after
 the response is returned, we check for a signalled exception and re-raise
 it
 (https://github.com/django/django/blob/master/django/test/client.py#L492-L495).
 Fair enough; usually in tests you prefer to have the exception raised
 instead of just seeing a 500 error.

 But there are two problems with this: 1) it's impossible to turn off (and
 sometimes there are times when you'd want to, e.g. if testing behavior of
 `handle_uncaught_exception` in a custom WSGI handler subclass), and 2)
 Django has long had an alternate method to do exactly the same thing, the
 `DEBUG_PROPAGATE_EXCEPTIONS` setting.

 The setting is much simpler, and it's easy to turn off for a selected
 test.

 I think we should at least provide a way to turn off the test client re-
 raising behavior (perhaps via a flag set on the client).

 I'm tempted to suggest we should also at some point raise a deprecation
 warning if this flag is not set, suggesting to use
 DEBUG_PROPAGATE_EXCEPTIONS when running tests instead, and then later
 remove the test-client re-raising altogether. But removing this bit of
 code may not be worth the churn of that deprecation.

--
Ticket URL: <https://code.djangoproject.com/ticket/27893>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.9a3d06cdeebaeb7777d611de9c76d1e1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to