mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Replaced use of TestCase.fail() with assertRaises().
Also removed try/except/fail antipattern that hides exceptions.
This commit is contained in:
parent
c1b6f554e4
commit
c9ae09addf
30 changed files with 205 additions and 447 deletions
|
@ -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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue