1
0
mirror of https://github.com/django/django.git synced 2025-10-28 16:16:12 +00:00

[1.10.x] Replaced use of TestCase.fail() with assertRaises().

Also removed try/except/fail antipattern that hides exceptions.

Backport of c9ae09addf from master
This commit is contained in:
Tim Graham
2016-06-28 11:21:26 -04:00
parent 9c48e17480
commit 567cfc1601
30 changed files with 205 additions and 447 deletions

View File

@@ -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"