From 567cfc1601a5f475eea12bc5de53b849fa5dadea Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 28 Jun 2016 11:21:26 -0400 Subject: [1.10.x] Replaced use of TestCase.fail() with assertRaises(). Also removed try/except/fail antipattern that hides exceptions. Backport of c9ae09addffb839403312131d4251e9d8b454508 from master --- tests/test_client/tests.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'tests/test_client') diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 833306a4a9..5594e71e12 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -598,14 +598,10 @@ class ClientTest(TestCase): def test_session_modifying_view(self): "Request a page that modifies the session" # Session value isn't set initially - try: + with self.assertRaises(KeyError): self.client.session['tobacconist'] - self.fail("Shouldn't have a session value") - except KeyError: - pass self.client.post('/session_view/') - # Check that the session was modified self.assertEqual(self.client.session['tobacconist'], 'hovercraft') @@ -629,13 +625,6 @@ class ClientTest(TestCase): with self.assertRaises(KeyError): self.client.get("/broken_view/") - # Try the same assertion, a different way - try: - self.client.get('/broken_view/') - self.fail('Should raise an error') - except KeyError: - pass - def test_mail_sending(self): "Test that mail is redirected to a dummy outbox during test setup" -- cgit v1.3