#18707: Test client doesn't allow testing 500 responses content
-----------------------------------+------------------------------------
Reporter: ricardokirkner@… | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Jon Dufresne):
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/10892 PR]
This PR takes the following approach:
Adds a new test client argument and attribute `raise_view_exception` to
allow controlling whether or not exceptions raised in a view should also
be raised in the test. The value defaults to `True` for backwards
compatibility. If it is `False` and an exception occurs in the view, the
test client will return a 500 response with the attribute `exc_info`, a
tuple providing information of the exception that occurred in the same
format as Python's `sys.exc_inf()` (type, value, traceback).
However, I would like to suggest that `raise_view_exception=False` become
the default after a deprecation period and perhaps eventually dropping the
old behavior (again, after a deprecation period). IMO, the test client
should try to interact with views as close to production as possible. By
injecting alternative code paths, such as eagerly raising exceptions, we
drift from the real world scenario to a different one. A default of
`raise_view_exception=False` would better allow full stack integration
testing with the test client. With the introduction of `exc_info`, testing
precisely what exception occurred is still available and easy to do. This
proposal is not included in the PR, as I'd like some agreement before
beginning work.
--
Ticket URL: <https://code.djangoproject.com/ticket/18707#comment:14>
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/082.4051e3268738f46d19f7795fa0464e4d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.