#30249: Deprecate re-raising view exceptions from test client in tests
------------------------------------------------+------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: master
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 |
------------------------------------------------+------------------------
This is a continuation of the work started in ticket #18707.
Set for removal in 4.0.
By no longer re-raising the view exceptions in tests, we'll move the test
`Client` closer to behaving like a real world HTTP client. This assists
integration tests by providing more realistic side effects to test
against. Instead of altering the behavior under test, integration tests
can more reliably test the full stack, including the error handlers (which
were previously skipped in the default configuration).
Additionally, this behavior is duplicating the setting
[https://docs.djangoproject.com/en/2.2/ref/settings/#debug-propagate-
exceptions DEBUG_PROPAGATE_EXCEPTIONS].
Should a test want this behavior explicitly, it is already available by
adjusting this setting. For example:
{{{
class MyTest(TestCase):
@override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True)
def test_raises_exception(self):
with self.assertRaises(KeyError):
self.client.get('/broken_view/')
}}}
To assist in the deprecation period, I've opted to allow users to force
the new behavior and silence warnings by setting
`DEBUG_PROPAGATE_EXCEPTIONS` to the alternative falsey value `None`.
--
Ticket URL: <https://code.djangoproject.com/ticket/30249>
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/052.f3caad2319a0619689616dcb41f03551%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.