diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-02-20 03:16:10 -0800 |
---|---|---|
committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-02-20 12:16:10 +0100 |
commit | 7feddd878cd0d4ad6cc98f0da2b597d603a211a7 (patch) | |
tree | c46e8a85e07348989f3afd0103123ab09dc848fa /tests/test_client | |
parent | 7071f8f2729295b0da77b6c651966dc32c71f1ab (diff) | |
download | django-7feddd878cd0d4ad6cc98f0da2b597d603a211a7.tar.gz |
Fixed #18707 -- Added support for the test client to return 500 responses.
Diffstat (limited to 'tests/test_client')
-rw-r--r-- | tests/test_client/tests.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 432865328f..02f5113890 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -759,6 +759,20 @@ class ClientTest(TestCase): with self.assertRaises(KeyError): self.client.get("/broken_view/") + def test_exc_info(self): + client = Client(raise_request_exception=False) + response = client.get("/broken_view/") + self.assertEqual(response.status_code, 500) + exc_type, exc_value, exc_traceback = response.exc_info + self.assertIs(exc_type, KeyError) + self.assertIsInstance(exc_value, KeyError) + self.assertEqual(str(exc_value), "'Oops! Looks like you wrote some bad code.'") + self.assertIsNotNone(exc_traceback) + + def test_exc_info_none(self): + response = self.client.get("/get_view/") + self.assertIsNone(response.exc_info) + def test_mail_sending(self): "Mail is redirected to a dummy outbox during test setup" response = self.client.get('/mail_sending_view/') |