From f9cdde0cb41851e9d1eb70bd108debb75f267585 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 11 Feb 2007 00:23:31 +0000 Subject: Fixed #3162 -- Added coded to catch and rethrow exceptions that are thrown by the views visited by the test client. Thanks, Ben . git-svn-id: http://code.djangoproject.com/svn/django/trunk@4482 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/testing.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'docs') diff --git a/docs/testing.txt b/docs/testing.txt index 9906749723..cab31ed63b 100644 --- a/docs/testing.txt +++ b/docs/testing.txt @@ -291,6 +291,17 @@ for testing purposes: .. _RFC2616: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html +Exceptions +~~~~~~~~~~ + +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...catch`` +block, or ``unittest.TestCase.assertRaises()`` to test for exceptions. + +The only exceptions that are not visible in a Test Case are ``Http404``, +``PermissionDenied`` and ``SystemExit``. Django catches these exceptions +internally and converts them into the appropriate HTTP responses codes. + Persistent state ~~~~~~~~~~~~~~~~ -- cgit v1.3