1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16: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

@@ -1243,10 +1243,7 @@ class CustomModelAdminTest(AdminViewBasicTestCase):
self.assertContains(response, 'Hello from a custom logout template')
def test_custom_admin_site_index_view_and_template(self):
try:
response = self.client.get(reverse('admin2:index'))
except TypeError:
self.fail('AdminSite.index_template should accept a list of template paths')
response = self.client.get(reverse('admin2:index'))
self.assertIsInstance(response, TemplateResponse)
self.assertTemplateUsed(response, 'custom_admin/index.html')
self.assertContains(response, 'Hello from a custom index template *bar*')
@@ -1283,12 +1280,7 @@ class CustomModelAdminTest(AdminViewBasicTestCase):
def test_pwd_change_custom_template(self):
self.client.force_login(self.superuser)
su = User.objects.get(username='super')
try:
response = self.client.get(
reverse('admin4:auth_user_password_change', args=(su.pk,))
)
except TypeError:
self.fail('ModelAdmin.change_user_password_template should accept a list of template paths')
response = self.client.get(reverse('admin4:auth_user_password_change', args=(su.pk,)))
self.assertEqual(response.status_code, 200)