1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Replaced use of TestCase.fail() with assertRaises().

Also removed try/except/fail antipattern that hides exceptions.
This commit is contained in:
Tim Graham
2016-06-28 11:21:26 -04:00
committed by GitHub
parent c1b6f554e4
commit c9ae09addf
30 changed files with 205 additions and 447 deletions

View File

@@ -613,14 +613,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')
@@ -644,13 +640,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"