Added SuspiciousOperation to list of caught exceptions in testing docs.
This commit is contained in:
parent
b9a670b227
commit
21683011d5
|
@ -462,10 +462,12 @@ If you point the test client at a view that raises an exception, that exception
|
||||||
will be visible in the test case. You can then use a standard ``try ... except``
|
will be visible in the test case. You can then use a standard ``try ... except``
|
||||||
block or :meth:`~unittest.TestCase.assertRaises` to test for exceptions.
|
block or :meth:`~unittest.TestCase.assertRaises` to test for exceptions.
|
||||||
|
|
||||||
The only exceptions that are not visible to the test client are ``Http404``,
|
The only exceptions that are not visible to the test client are
|
||||||
``PermissionDenied`` and ``SystemExit``. Django catches these exceptions
|
:class:`~django.http.Http404`,
|
||||||
internally and converts them into the appropriate HTTP response codes. In these
|
:class:`~django.core.exceptions.PermissionDenied`, :exc:`SystemExit`, and
|
||||||
cases, you can check ``response.status_code`` in your test.
|
:class:`~django.core.exceptions.SuspiciousOperation`. Django catches these
|
||||||
|
exceptions internally and converts them into the appropriate HTTP response
|
||||||
|
codes. In these cases, you can check ``response.status_code`` in your test.
|
||||||
|
|
||||||
Persistent state
|
Persistent state
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
Loading…
Reference in New Issue