#30249: Deprecate re-raising view exceptions from test client in tests
-------------------------------------+-------------------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Testing framework | Version: master
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* status: new => closed
* needs_better_patch: 0 => 1
* resolution: => needsinfo
Comment:
Hey Jon.
Looking at the PR, I don't think we **can** re-purpose
`DEBUG_PROPAGATE_EXCEPTIONS` as per your suggestion, since it plays that
"your web server (instead of Django) to generate “Internal Server Error”
responses" role. (That's independent of also thinking that a flag on the
client is the right place to have that switch.)
The new `raise_request_exception` is targeting 3.0, so there's still time
to make adjustments.
Initial thought was something like...
{{{
from django import test
class Client(test.Client):
"""Client subclass defaulting to raise_request_exception=False"""
def __init__(self, enforce_csrf_checks=False,
raise_request_exception=False, **defaults):
super().__init__(enforce_csrf_checks, raise_request_exception,
**defaults)
class ClientMixin:
client_class = Client
}}}
Where you just mixin using a appropriate client subclass. Maybe we could
do something better making `client` a property or such? (Or similar...) —
Really happy to think about suggestions here!
**Maybe** we should take this opportunity to also switch the default
behaviour from "yes, raise" to "no, don't", but personally I'd leave it
how it is.
I'm really happy if you want to take this to the mailing list to discuss.
In the meantime I'm going as `needsinfo`, either on suggestions for
improving the API, or whether we should change the default, or, indeed,
whether we can/should/want to use the setting as you suggested.
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/30249#comment:7>
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/067.05574d7a262654a25d0519ccff9ad179%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.