Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed all usages of deprecated TestCase methods (self.fail*). This …

…removed most of the Warnings emitted (with -Wall) during the test suite.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14803 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5bc0ec4ec4b7c888a291bc81b2edd72812231d96 1 parent 6770c36
Alex Gaynor authored December 04, 2010

Showing 30 changed files with 385 additions and 378 deletions. Show diff stats Hide diff stats

  1. 14  django/contrib/formtools/tests/__init__.py
  2. 10  django/test/testcases.py
  3. 10  tests/modeltests/model_formsets/tests.py
  4. 4  tests/modeltests/signals/tests.py
  5. 16  tests/modeltests/test_client/models.py
  6. 19  tests/modeltests/update/tests.py
  7. 22  tests/regressiontests/admin_changelist/tests.py
  8. 14  tests/regressiontests/admin_inlines/tests.py
  9. 3  tests/regressiontests/admin_scripts/tests.py
  10. 412  tests/regressiontests/admin_views/tests.py
  11. 2  tests/regressiontests/admin_widgets/tests.py
  12. 10  tests/regressiontests/app_loading/tests.py
  13. 4  tests/regressiontests/bug8245/tests.py
  14. 2  tests/regressiontests/builtin_server/tests.py
  15. 16  tests/regressiontests/comment_tests/tests/comment_form_tests.py
  16. 10  tests/regressiontests/comment_tests/tests/comment_view_tests.py
  17. 5  tests/regressiontests/comment_tests/tests/model_tests.py
  18. 28  tests/regressiontests/comment_tests/tests/moderation_view_tests.py
  19. 27  tests/regressiontests/file_storage/tests.py
  20. 3  tests/regressiontests/file_uploads/tests.py
  21. 19  tests/regressiontests/generic_inline_admin/tests.py
  22. 16  tests/regressiontests/httpwrappers/tests.py
  23. 2  tests/regressiontests/i18n/commands/compilation.py
  24. 5  tests/regressiontests/inline_formsets/tests.py
  25. 15  tests/regressiontests/middleware/tests.py
  26. 13  tests/regressiontests/model_forms_regress/tests.py
  27. 19  tests/regressiontests/staticfiles_tests/tests.py
  28. 26  tests/regressiontests/test_client_regress/models.py
  29. 15  tests/regressiontests/views/tests/debug.py
  30. 2  tests/regressiontests/views/tests/generic/create_update.py
14  django/contrib/formtools/tests/__init__.py
... ...
@@ -1,14 +1,13 @@
1 1
 import os
2 2
 
3  
-from django import forms
4  
-from django import http
  3
+from django import forms, http
5 4
 from django.conf import settings
6 5
 from django.contrib.formtools import preview, wizard, utils
7 6
 from django.test import TestCase
8 7
 from django.utils import unittest
9 8
 
10  
-success_string = "Done was called!"
11 9
 
  10
+success_string = "Done was called!"
12 11
 
13 12
 class TestFormPreview(preview.FormPreview):
14 13
     def get_context(self, request, form):
@@ -100,7 +99,7 @@ def test_form_submit(self):
100 99
         # show we previously saw first stage of the form.
101 100
         self.test_data.update({'stage':2})
102 101
         response = self.client.post('/test1/', self.test_data)
103  
-        self.failIfEqual(response.content, success_string)
  102
+        self.assertNotEqual(response.content, success_string)
104 103
         hash = self.preview.security_hash(None, TestForm(self.test_data))
105 104
         self.test_data.update({'hash': hash})
106 105
         response = self.client.post('/test1/', self.test_data)
@@ -134,7 +133,7 @@ def test_form_submit_django12_hash(self):
134 133
         # show we previously saw first stage of the form.
135 134
         self.test_data.update({'stage':2})
136 135
         response = self.client.post('/test1/', self.test_data)
137  
-        self.failIfEqual(response.content, success_string)
  136
+        self.assertNotEqual(response.content, success_string)
138 137
         hash = utils.security_hash(None, TestForm(self.test_data))
139 138
         self.test_data.update({'hash': hash})
140 139
         response = self.client.post('/test1/', self.test_data)
@@ -151,11 +150,11 @@ def test_form_submit_django12_hash_custom_hash(self):
151 150
         self.test_data.update({'stage':2})
152 151
         response = self.client.post('/test2/', self.test_data)
153 152
         self.assertEqual(response.status_code, 200)
154  
-        self.failIfEqual(response.content, success_string)
  153
+        self.assertNotEqual(response.content, success_string)
155 154
         hash = utils.security_hash(None, TestForm(self.test_data))
156 155
         self.test_data.update({'hash': hash})
157 156
         response = self.client.post('/test2/', self.test_data)
158  
-        self.failIfEqual(response.content, success_string)
  157
+        self.assertNotEqual(response.content, success_string)
159 158
 
160 159
 
161 160
 class SecurityHashTests(unittest.TestCase):
@@ -392,4 +391,3 @@ def done(self, request, form_list):
392 391
                 "wizard_step": "1"}
393 392
         wizard(DummyRequest(POST=data))
394 393
         self.assertTrue(reached[0])
395  
-
10  django/test/testcases.py
@@ -355,7 +355,7 @@ def assertRedirects(self, response, expected_url, status_code=302,
355 355
 
356 356
         if hasattr(response, 'redirect_chain'):
357 357
             # The request was a followed redirect
358  
-            self.failUnless(len(response.redirect_chain) > 0,
  358
+            self.assertTrue(len(response.redirect_chain) > 0,
359 359
                 msg_prefix + "Response didn't redirect as expected: Response"
360 360
                 " code was %d (expected %d)" %
361 361
                     (response.status_code, status_code))
@@ -469,7 +469,7 @@ def assertFormError(self, response, form, field, errors, msg_prefix=''):
469 469
                 if field:
470 470
                     if field in context[form].errors:
471 471
                         field_errors = context[form].errors[field]
472  
-                        self.failUnless(err in field_errors,
  472
+                        self.assertTrue(err in field_errors,
473 473
                             msg_prefix + "The field '%s' on form '%s' in"
474 474
                             " context %d does not contain the error '%s'"
475 475
                             " (actual errors: %s)" %
@@ -484,7 +484,7 @@ def assertFormError(self, response, form, field, errors, msg_prefix=''):
484 484
                                       (form, i, field))
485 485
                 else:
486 486
                     non_field_errors = context[form].non_field_errors()
487  
-                    self.failUnless(err in non_field_errors,
  487
+                    self.assertTrue(err in non_field_errors,
488 488
                         msg_prefix + "The form '%s' in context %d does not"
489 489
                         " contain the non-field error '%s'"
490 490
                         " (actual errors: %s)" %
@@ -504,7 +504,7 @@ def assertTemplateUsed(self, response, template_name, msg_prefix=''):
504 504
         template_names = [t.name for t in response.templates]
505 505
         if not template_names:
506 506
             self.fail(msg_prefix + "No templates used to render the response")
507  
-        self.failUnless(template_name in template_names,
  507
+        self.assertTrue(template_name in template_names,
508 508
             msg_prefix + "Template '%s' was not a template used to render"
509 509
             " the response. Actual template(s) used: %s" %
510 510
                 (template_name, u', '.join(template_names)))
@@ -518,7 +518,7 @@ def assertTemplateNotUsed(self, response, template_name, msg_prefix=''):
518 518
             msg_prefix += ": "
519 519
 
520 520
         template_names = [t.name for t in response.templates]
521  
-        self.failIf(template_name in template_names,
  521
+        self.assertFalse(template_name in template_names,
522 522
             msg_prefix + "Template '%s' was used unexpectedly in rendering"
523 523
             " the response" % template_name)
524 524
 
10  tests/modeltests/model_formsets/tests.py
@@ -2,13 +2,13 @@
2 2
 import re
3 3
 from datetime import date
4 4
 from decimal import Decimal
  5
+
5 6
 from django import forms
6 7
 from django.db import models
7  
-from django.forms.models import _get_foreign_key
8  
-from django.forms.models import inlineformset_factory
9  
-from django.forms.models import modelformset_factory
10  
-from django.forms.models import modelformset_factory
  8
+from django.forms.models import (_get_foreign_key, inlineformset_factory,
  9
+    modelformset_factory, modelformset_factory)
11 10
 from django.test import TestCase
  11
+
12 12
 from modeltests.model_formsets.models import (
13 13
     Author, BetterAuthor, Book, BookWithCustomPK, Editor,
14 14
     BookWithOptionalAltEditor, AlternateBook, AuthorMeeting, CustomPrimaryKey,
@@ -30,7 +30,7 @@ def test_deletion(self):
30 30
         }
31 31
         formset = PoetFormSet(data, queryset=Poet.objects.all())
32 32
         formset.save()
33  
-        self.failUnless(formset.is_valid())
  33
+        self.assertTrue(formset.is_valid())
34 34
         self.assertEqual(Poet.objects.count(), 0)
35 35
 
36 36
     def test_add_form_deletion_when_invalid(self):
4  tests/modeltests/signals/tests.py
@@ -171,6 +171,6 @@ def test_disconnect_in_dispatch(self):
171 171
         signals.post_save.connect(sender=Person, receiver=b)
172 172
         p = Person.objects.create(first_name='John', last_name='Smith')
173 173
 
174  
-        self.failUnless(a._run)
175  
-        self.failUnless(b._run)
  174
+        self.assertTrue(a._run)
  175
+        self.assertTrue(b._run)
176 176
         self.assertEqual(signals.post_save.receivers, [])
16  tests/modeltests/test_client/models.py
@@ -73,7 +73,7 @@ def test_post(self):
73 73
         self.assertEqual(response.status_code, 200)
74 74
         self.assertEqual(response.context['data'], '37')
75 75
         self.assertEqual(response.templates[0].name, 'POST Template')
76  
-        self.failUnless('Data received' in response.content)
  76
+        self.assertTrue('Data received' in response.content)
77 77
 
78 78
     def test_response_headers(self):
79 79
         "Check the value of HTTP headers returned in a response"
@@ -278,7 +278,7 @@ def test_view_with_login(self):
278 278
 
279 279
         # Log in
280 280
         login = self.client.login(username='testclient', password='password')
281  
-        self.failUnless(login, 'Could not log in')
  281
+        self.assertTrue(login, 'Could not log in')
282 282
 
283 283
         # Request a page that requires a login
284 284
         response = self.client.get('/test_client/login_protected_view/')
@@ -294,7 +294,7 @@ def test_view_with_method_login(self):
294 294
 
295 295
         # Log in
296 296
         login = self.client.login(username='testclient', password='password')
297  
-        self.failUnless(login, 'Could not log in')
  297
+        self.assertTrue(login, 'Could not log in')
298 298
 
299 299
         # Request a page that requires a login
300 300
         response = self.client.get('/test_client/login_protected_method_view/')
@@ -310,7 +310,7 @@ def test_view_with_login_and_custom_redirect(self):
310 310
 
311 311
         # Log in
312 312
         login = self.client.login(username='testclient', password='password')
313  
-        self.failUnless(login, 'Could not log in')
  313
+        self.assertTrue(login, 'Could not log in')
314 314
 
315 315
         # Request a page that requires a login
316 316
         response = self.client.get('/test_client/login_protected_view_custom_redirect/')
@@ -321,13 +321,13 @@ def test_view_with_bad_login(self):
321 321
         "Request a page that is protected with @login, but use bad credentials"
322 322
 
323 323
         login = self.client.login(username='otheruser', password='nopassword')
324  
-        self.failIf(login)
  324
+        self.assertFalse(login)
325 325
 
326 326
     def test_view_with_inactive_login(self):
327 327
         "Request a page that is protected with @login, but use an inactive login"
328 328
 
329 329
         login = self.client.login(username='inactive', password='password')
330  
-        self.failIf(login)
  330
+        self.assertFalse(login)
331 331
 
332 332
     def test_logout(self):
333 333
         "Request a logout after logging in"
@@ -355,7 +355,7 @@ def test_view_with_permissions(self):
355 355
 
356 356
         # Log in
357 357
         login = self.client.login(username='testclient', password='password')
358  
-        self.failUnless(login, 'Could not log in')
  358
+        self.assertTrue(login, 'Could not log in')
359 359
 
360 360
         # Log in with wrong permissions. Should result in 302.
361 361
         response = self.client.get('/test_client/permission_protected_view/')
@@ -372,7 +372,7 @@ def test_view_with_method_permissions(self):
372 372
 
373 373
         # Log in
374 374
         login = self.client.login(username='testclient', password='password')
375  
-        self.failUnless(login, 'Could not log in')
  375
+        self.assertTrue(login, 'Could not log in')
376 376
 
377 377
         # Log in with wrong permissions. Should result in 302.
378 378
         response = self.client.get('/test_client/permission_protected_method_view/')
19  tests/modeltests/update/tests.py
@@ -2,6 +2,7 @@
2 2
 
3 3
 from models import A, B, C, D, DataPoint, RelatedPoint
4 4
 
  5
+
5 6
 class SimpleTest(TestCase):
6 7
     def setUp(self):
7 8
         self.a1 = A.objects.create()
@@ -15,18 +16,18 @@ def test_nonempty_update(self):
15 16
         Test that update changes the right number of rows for a nonempty queryset
16 17
         """
17 18
         num_updated = self.a1.b_set.update(y=100)
18  
-        self.failUnlessEqual(num_updated, 20)
  19
+        self.assertEqual(num_updated, 20)
19 20
         cnt = B.objects.filter(y=100).count()
20  
-        self.failUnlessEqual(cnt, 20)
  21
+        self.assertEqual(cnt, 20)
21 22
 
22 23
     def test_empty_update(self):
23 24
         """
24 25
         Test that update changes the right number of rows for an empty queryset
25 26
         """
26 27
         num_updated = self.a2.b_set.update(y=100)
27  
-        self.failUnlessEqual(num_updated, 0)
  28
+        self.assertEqual(num_updated, 0)
28 29
         cnt = B.objects.filter(y=100).count()
29  
-        self.failUnlessEqual(cnt, 0)
  30
+        self.assertEqual(cnt, 0)
30 31
 
31 32
     def test_nonempty_update_with_inheritance(self):
32 33
         """
@@ -34,9 +35,9 @@ def test_nonempty_update_with_inheritance(self):
34 35
         when the update affects only a base table
35 36
         """
36 37
         num_updated = self.a1.d_set.update(y=100)
37  
-        self.failUnlessEqual(num_updated, 20)
  38
+        self.assertEqual(num_updated, 20)
38 39
         cnt = D.objects.filter(y=100).count()
39  
-        self.failUnlessEqual(cnt, 20)
  40
+        self.assertEqual(cnt, 20)
40 41
 
41 42
     def test_empty_update_with_inheritance(self):
42 43
         """
@@ -44,9 +45,9 @@ def test_empty_update_with_inheritance(self):
44 45
         when the update affects only a base table
45 46
         """
46 47
         num_updated = self.a2.d_set.update(y=100)
47  
-        self.failUnlessEqual(num_updated, 0)
  48
+        self.assertEqual(num_updated, 0)
48 49
         cnt = D.objects.filter(y=100).count()
49  
-        self.failUnlessEqual(cnt, 0)
  50
+        self.assertEqual(cnt, 0)
50 51
 
51 52
 class AdvancedTests(TestCase):
52 53
 
@@ -112,4 +113,4 @@ def test_update_slice_fail(self):
112 113
         """
113 114
         method = DataPoint.objects.all()[:2].update
114 115
         self.assertRaises(AssertionError, method,
115  
-            another_value='another thing')
  116
+            another_value='another thing')
22  tests/regressiontests/admin_changelist/tests.py
@@ -11,8 +11,8 @@ def test_select_related_preserved(self):
11 11
         overwrite a custom select_related provided by ModelAdmin.queryset().
12 12
         """
13 13
         m = ChildAdmin(Child, admin.site)
14  
-        cl = ChangeList(MockRequest(), Child, m.list_display, m.list_display_links, 
15  
-                m.list_filter, m.date_hierarchy, m.search_fields, 
  14
+        cl = ChangeList(MockRequest(), Child, m.list_display, m.list_display_links,
  15
+                m.list_filter, m.date_hierarchy, m.search_fields,
16 16
                 m.list_select_related, m.list_per_page, m.list_editable, m)
17 17
         self.assertEqual(cl.query_set.query.select_related, {'parent': {'name': {}}})
18 18
 
@@ -25,24 +25,24 @@ def test_result_list_html(self):
25 25
         new_child = Child.objects.create(name='name', parent=new_parent)
26 26
         request = MockRequest()
27 27
         m = ChildAdmin(Child, admin.site)
28  
-        cl = ChangeList(request, Child, m.list_display, m.list_display_links, 
29  
-                m.list_filter, m.date_hierarchy, m.search_fields, 
  28
+        cl = ChangeList(request, Child, m.list_display, m.list_display_links,
  29
+                m.list_filter, m.date_hierarchy, m.search_fields,
30 30
                 m.list_select_related, m.list_per_page, m.list_editable, m)
31 31
         cl.formset = None
32 32
         template = Template('{% load admin_list %}{% spaceless %}{% result_list cl %}{% endspaceless %}')
33 33
         context = Context({'cl': cl})
34 34
         table_output = template.render(context)
35 35
         row_html = '<tbody><tr class="row1"><td><input type="checkbox" class="action-select" value="1" name="_selected_action" /></td><th><a href="1/">name</a></th><td>Parent object</td></tr></tbody>'
36  
-        self.failIf(table_output.find(row_html) == -1,
  36
+        self.assertFalse(table_output.find(row_html) == -1,
37 37
             'Failed to find expected row element: %s' % table_output)
38 38
 
39 39
     def test_result_list_editable_html(self):
40 40
         """
41  
-        Regression tests for #11791: Inclusion tag result_list generates a 
  41
+        Regression tests for #11791: Inclusion tag result_list generates a
42 42
         table and this checks that the items are nested within the table
43 43
         element tags.
44 44
         Also a regression test for #13599, verifies that hidden fields
45  
-        when list_editable is enabled are rendered in a div outside the 
  45
+        when list_editable is enabled are rendered in a div outside the
46 46
         table.
47 47
         """
48 48
         new_parent = Parent.objects.create(name='parent')
@@ -54,8 +54,8 @@ def test_result_list_editable_html(self):
54 54
         m.list_display = ['id', 'name', 'parent']
55 55
         m.list_display_links = ['id']
56 56
         m.list_editable = ['name']
57  
-        cl = ChangeList(request, Child, m.list_display, m.list_display_links, 
58  
-                m.list_filter, m.date_hierarchy, m.search_fields, 
  57
+        cl = ChangeList(request, Child, m.list_display, m.list_display_links,
  58
+                m.list_filter, m.date_hierarchy, m.search_fields,
59 59
                 m.list_select_related, m.list_per_page, m.list_editable, m)
60 60
         FormSet = m.get_changelist_formset(request)
61 61
         cl.formset = FormSet(queryset=cl.result_list)
@@ -64,11 +64,11 @@ def test_result_list_editable_html(self):
64 64
         table_output = template.render(context)
65 65
         # make sure that hidden fields are in the correct place
66 66
         hiddenfields_div = '<div class="hiddenfields"><input type="hidden" name="form-0-id" value="1" id="id_form-0-id" /></div>'
67  
-        self.failIf(table_output.find(hiddenfields_div) == -1,
  67
+        self.assertFalse(table_output.find(hiddenfields_div) == -1,
68 68
             'Failed to find hidden fields in: %s' % table_output)
69 69
         # make sure that list editable fields are rendered in divs correctly
70 70
         editable_name_field = '<input name="form-0-name" value="name" class="vTextField" maxlength="30" type="text" id="id_form-0-name" />'
71  
-        self.failIf('<td>%s</td>' % editable_name_field == -1,
  71
+        self.assertFalse('<td>%s</td>' % editable_name_field == -1,
72 72
             'Failed to find "name" list_editable field in: %s' % table_output)
73 73
 
74 74
 class ChildAdmin(admin.ModelAdmin):
14  tests/regressiontests/admin_inlines/tests.py
... ...
@@ -1,12 +1,10 @@
1  
-from django.test import TestCase
2  
-
3 1
 from django.contrib.admin.helpers import InlineAdminForm
4 2
 from django.contrib.contenttypes.models import ContentType
  3
+from django.test import TestCase
  4
+
5 5
 # local test models
6  
-from models import Holder, Inner, InnerInline
7  
-from models import Holder2, Inner2, Holder3, Inner3
8  
-from models import Person, OutfitItem, Fashionista
9  
-from models import Teacher, Parent, Child
  6
+from models import (Holder, Inner, InnerInline, Holder2, Inner2, Holder3,
  7
+    Inner3, Person, OutfitItem, Fashionista, Teacher, Parent, Child)
10 8
 
11 9
 
12 10
 class TestInline(TestCase):
@@ -19,7 +17,7 @@ def setUp(self):
19 17
         self.change_url = '/test_admin/admin/admin_inlines/holder/%i/' % holder.id
20 18
 
21 19
         result = self.client.login(username='super', password='secret')
22  
-        self.failUnlessEqual(result, True)
  20
+        self.assertEqual(result, True)
23 21
 
24 22
     def tearDown(self):
25 23
         self.client.logout()
@@ -75,7 +73,7 @@ class TestInlineMedia(TestCase):
75 73
     def setUp(self):
76 74
 
77 75
         result = self.client.login(username='super', password='secret')
78  
-        self.failUnlessEqual(result, True)
  76
+        self.assertEqual(result, True)
79 77
 
80 78
     def tearDown(self):
81 79
         self.client.logout()
3  tests/regressiontests/admin_scripts/tests.py
@@ -12,6 +12,7 @@
12 12
 from django.conf import settings
13 13
 from django.utils import unittest
14 14
 
  15
+
15 16
 class AdminScriptTestCase(unittest.TestCase):
16 17
     def write_settings(self, filename, apps=None, is_dir=False, sdict=None):
17 18
         test_dir = os.path.dirname(os.path.dirname(__file__))
@@ -156,7 +157,7 @@ def assertNoOutput(self, stream):
156 157
         self.assertEquals(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)
157 158
     def assertOutput(self, stream, msg):
158 159
         "Utility assertion: assert that the given message exists in the output"
159  
-        self.failUnless(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))
  160
+        self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))
160 161
 
161 162
 ##########################################################################
162 163
 # DJANGO ADMIN TESTS
412  tests/regressiontests/admin_views/tests.py
@@ -2,10 +2,12 @@
2 2
 
3 3
 import re
4 4
 import datetime
  5
+
5 6
 from django.conf import settings
6 7
 from django.core import mail
7 8
 from django.core.files import temp as tempfile
8  
-from django.contrib.auth import REDIRECT_FIELD_NAME, admin # Register auth models with the admin.
  9
+# Register auth models with the admin.
  10
+from django.contrib.auth import REDIRECT_FIELD_NAME, admin
9 11
 from django.contrib.auth.models import User, Permission, UNUSABLE_PASSWORD
10 12
 from django.contrib.contenttypes.models import ContentType
11 13
 from django.contrib.admin.models import LogEntry, DELETION
@@ -62,12 +64,12 @@ def testBasicAddGet(self):
62 64
         A smoke test to ensure GET on the add_view works.
63 65
         """
64 66
         response = self.client.get('/test_admin/%s/admin_views/section/add/' % self.urlbit)
65  
-        self.failUnlessEqual(response.status_code, 200)
  67
+        self.assertEqual(response.status_code, 200)
66 68
 
67 69
     def testAddWithGETArgs(self):
68 70
         response = self.client.get('/test_admin/%s/admin_views/section/add/' % self.urlbit, {'name': 'My Section'})
69  
-        self.failUnlessEqual(response.status_code, 200)
70  
-        self.failUnless(
  71
+        self.assertEqual(response.status_code, 200)
  72
+        self.assertTrue(
71 73
             'value="My Section"' in response.content,
72 74
             "Couldn't find an input with the right value in the response."
73 75
         )
@@ -77,7 +79,7 @@ def testBasicEditGet(self):
77 79
         A smoke test to ensure GET on the change_view works.
78 80
         """
79 81
         response = self.client.get('/test_admin/%s/admin_views/section/1/' % self.urlbit)
80  
-        self.failUnlessEqual(response.status_code, 200)
  82
+        self.assertEqual(response.status_code, 200)
81 83
 
82 84
     def testBasicEditGetStringPK(self):
83 85
         """
@@ -86,7 +88,7 @@ def testBasicEditGetStringPK(self):
86 88
         model with an integer PK field.
87 89
         """
88 90
         response = self.client.get('/test_admin/%s/admin_views/section/abc/' % self.urlbit)
89  
-        self.failUnlessEqual(response.status_code, 404)
  91
+        self.assertEqual(response.status_code, 404)
90 92
 
91 93
     def testBasicAddPost(self):
92 94
         """
@@ -100,7 +102,7 @@ def testBasicAddPost(self):
100 102
             "article_set-MAX_NUM_FORMS": u"0",
101 103
         }
102 104
         response = self.client.post('/test_admin/%s/admin_views/section/add/' % self.urlbit, post_data)
103  
-        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
  105
+        self.assertEqual(response.status_code, 302) # redirect somewhere
104 106
 
105 107
     # Post data for edit inline
106 108
     inline_post_data = {
@@ -148,7 +150,7 @@ def testBasicEditPost(self):
148 150
         A smoke test to ensure POST on edit_view works.
149 151
         """
150 152
         response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, self.inline_post_data)
151  
-        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
  153
+        self.assertEqual(response.status_code, 302) # redirect somewhere
152 154
 
153 155
     def testEditSaveAs(self):
154 156
         """
@@ -164,7 +166,7 @@ def testEditSaveAs(self):
164 166
             "article_set-5-section": u"1",
165 167
         })
166 168
         response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, post_data)
167  
-        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
  169
+        self.assertEqual(response.status_code, 302) # redirect somewhere
168 170
 
169 171
     def testChangeListSortingCallable(self):
170 172
         """
@@ -172,8 +174,8 @@ def testChangeListSortingCallable(self):
172 174
         (column 2 is callable_year in ArticleAdmin)
173 175
         """
174 176
         response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'ot': 'asc', 'o': 2})
175  
-        self.failUnlessEqual(response.status_code, 200)
176  
-        self.failUnless(
  177
+        self.assertEqual(response.status_code, 200)
  178
+        self.assertTrue(
177 179
             response.content.index('Oldest content') < response.content.index('Middle content') and
178 180
             response.content.index('Middle content') < response.content.index('Newest content'),
179 181
             "Results of sorting on callable are out of order."
@@ -185,8 +187,8 @@ def testChangeListSortingModel(self):
185 187
         (colunn 3 is 'model_year' in ArticleAdmin)
186 188
         """
187 189
         response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'ot': 'dsc', 'o': 3})
188  
-        self.failUnlessEqual(response.status_code, 200)
189  
-        self.failUnless(
  190
+        self.assertEqual(response.status_code, 200)
  191
+        self.assertTrue(
190 192
             response.content.index('Newest content') < response.content.index('Middle content') and
191 193
             response.content.index('Middle content') < response.content.index('Oldest content'),
192 194
             "Results of sorting on Model method are out of order."
@@ -198,8 +200,8 @@ def testChangeListSortingModelAdmin(self):
198 200
         (colunn 4 is 'modeladmin_year' in ArticleAdmin)
199 201
         """
200 202
         response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'ot': 'asc', 'o': 4})
201  
-        self.failUnlessEqual(response.status_code, 200)
202  
-        self.failUnless(
  203
+        self.assertEqual(response.status_code, 200)
  204
+        self.assertTrue(
203 205
             response.content.index('Oldest content') < response.content.index('Middle content') and
204 206
             response.content.index('Middle content') < response.content.index('Newest content'),
205 207
             "Results of sorting on ModelAdmin method are out of order."
@@ -210,12 +212,12 @@ def testLimitedFilter(self):
210 212
         This also tests relation-spanning filters (e.g. 'color__value').
211 213
         """
212 214
         response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit)
213  
-        self.failUnlessEqual(response.status_code, 200)
214  
-        self.failUnless(
  215
+        self.assertEqual(response.status_code, 200)
  216
+        self.assertTrue(
215 217
             '<div id="changelist-filter">' in response.content,
216 218
             "Expected filter not found in changelist view."
217 219
         )
218  
-        self.failIf(
  220
+        self.assertFalse(
219 221
             '<a href="?color__id__exact=3">Blue</a>' in response.content,
220 222
             "Changelist filter not correctly limited by limit_choices_to."
221 223
         )
@@ -223,7 +225,7 @@ def testLimitedFilter(self):
223 225
     def testRelationSpanningFilters(self):
224 226
         response = self.client.get('/test_admin/%s/admin_views/chapterxtra1/' %
225 227
                                    self.urlbit)
226  
-        self.failUnlessEqual(response.status_code, 200)
  228
+        self.assertEqual(response.status_code, 200)
227 229
         self.assertContains(response, '<div id="changelist-filter">')
228 230
         filters = {
229 231
             'chap__id__exact': dict(
@@ -256,7 +258,7 @@ def testRelationSpanningFilters(self):
256 258
                 filtered_response = self.client.get(
257 259
                     '/test_admin/%s/admin_views/chapterxtra1/?%s' % (
258 260
                         self.urlbit, query_string))
259  
-                self.failUnlessEqual(filtered_response.status_code, 200)
  261
+                self.assertEqual(filtered_response.status_code, 200)
260 262
                 # ensure changelist contains only valid objects
261 263
                 for obj in filtered_response.context['cl'].query_set.all():
262 264
                     self.assertTrue(params['test'](obj, value))
@@ -280,8 +282,8 @@ def testIsNullLookups(self):
280 282
 
281 283
     def testLogoutAndPasswordChangeURLs(self):
282 284
         response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit)
283  
-        self.failIf('<a href="/test_admin/%s/logout/">' % self.urlbit not in response.content)
284  
-        self.failIf('<a href="/test_admin/%s/password_change/">' % self.urlbit not in response.content)
  285
+        self.assertFalse('<a href="/test_admin/%s/logout/">' % self.urlbit not in response.content)
  286
+        self.assertFalse('<a href="/test_admin/%s/password_change/">' % self.urlbit not in response.content)
285 287
 
286 288
     def testNamedGroupFieldChoicesChangeList(self):
287 289
         """
@@ -290,8 +292,8 @@ def testNamedGroupFieldChoicesChangeList(self):
290 292
         has been used in the choices option of a field.
291 293
         """
292 294
         response = self.client.get('/test_admin/%s/admin_views/fabric/' % self.urlbit)
293  
-        self.failUnlessEqual(response.status_code, 200)
294  
-        self.failUnless(
  295
+        self.assertEqual(response.status_code, 200)
  296
+        self.assertTrue(
295 297
             '<a href="1/">Horizontal</a>' in response.content and
296 298
             '<a href="2/">Vertical</a>' in response.content,
297 299
             "Changelist table isn't showing the right human-readable values set by a model field 'choices' option named group."
@@ -303,12 +305,12 @@ def testNamedGroupFieldChoicesFilter(self):
303 305
         been used in the choices option of a model field.
304 306
         """
305 307
         response = self.client.get('/test_admin/%s/admin_views/fabric/' % self.urlbit)
306  
-        self.failUnlessEqual(response.status_code, 200)
307  
-        self.failUnless(
  308
+        self.assertEqual(response.status_code, 200)
  309
+        self.assertTrue(
308 310
             '<div id="changelist-filter">' in response.content,
309 311
             "Expected filter not found in changelist view."
310 312
         )
311  
-        self.failUnless(
  313
+        self.assertTrue(
312 314
             '<a href="?surface__exact=x">Horizontal</a>' in response.content and
313 315
             '<a href="?surface__exact=y">Vertical</a>' in response.content,
314 316
             "Changelist filter isn't showing options contained inside a model field 'choices' option named group."
@@ -320,7 +322,7 @@ def testChangeListNullBooleanDisplay(self):
320 322
         # against the 'admin2' custom admin (which doesn't have the
321 323
         # Post model).
322 324
         response = self.client.get("/test_admin/admin/admin_views/post/")
323  
-        self.failUnless('icon-unknown.gif' in response.content)
  325
+        self.assertTrue('icon-unknown.gif' in response.content)
324 326
 
325 327
     def testI18NLanguageNonEnglishDefault(self):
326 328
         """
@@ -380,14 +382,14 @@ class CustomModelAdminTest(AdminViewBasicTest):
380 382
     def testCustomAdminSiteLoginForm(self):
381 383
         self.client.logout()
382 384
         request = self.client.get('/test_admin/admin2/')
383  
-        self.failUnlessEqual(request.status_code, 200)
  385
+        self.assertEqual(request.status_code, 200)
384 386
         login = self.client.post('/test_admin/admin2/', {
385 387
             REDIRECT_FIELD_NAME: '/test_admin/admin2/',
386 388
             LOGIN_FORM_KEY: 1,
387 389
             'username': 'customform',
388 390
             'password': 'secret',
389 391
         })
390  
-        self.failUnlessEqual(login.status_code, 200)
  392
+        self.assertEqual(login.status_code, 200)
391 393
         self.assertContains(login, 'custom form error')
392 394
 
393 395
     def testCustomAdminSiteLoginTemplate(self):
@@ -516,15 +518,15 @@ def testLogin(self):
516 518
         """
517 519
         # Super User
518 520
         request = self.client.get('/test_admin/admin/')
519  
-        self.failUnlessEqual(request.status_code, 200)
  521
+        self.assertEqual(request.status_code, 200)
520 522
         login = self.client.post('/test_admin/admin/', self.super_login)
521 523
         self.assertRedirects(login, '/test_admin/admin/')
522  
-        self.failIf(login.context)
  524
+        self.assertFalse(login.context)
523 525
         self.client.get('/test_admin/admin/logout/')
524 526
 
525 527
         # Test if user enters e-mail address
526 528
         request = self.client.get('/test_admin/admin/')
527  
-        self.failUnlessEqual(request.status_code, 200)
  529
+        self.assertEqual(request.status_code, 200)
528 530
         login = self.client.post('/test_admin/admin/', self.super_email_login)
529 531
         self.assertContains(login, "Your e-mail address is not your username")
530 532
         # only correct passwords get a username hint
@@ -538,46 +540,46 @@ def testLogin(self):
538 540
 
539 541
         # Add User
540 542
         request = self.client.get('/test_admin/admin/')
541  
-        self.failUnlessEqual(request.status_code, 200)
  543
+        self.assertEqual(request.status_code, 200)
542 544
         login = self.client.post('/test_admin/admin/', self.adduser_login)
543 545
         self.assertRedirects(login, '/test_admin/admin/')
544  
-        self.failIf(login.context)
  546
+        self.assertFalse(login.context)
545 547
         self.client.get('/test_admin/admin/logout/')
546 548
 
547 549
         # Change User
548 550
         request = self.client.get('/test_admin/admin/')
549  
-        self.failUnlessEqual(request.status_code, 200)
  551
+        self.assertEqual(request.status_code, 200)
550 552
         login = self.client.post('/test_admin/admin/', self.changeuser_login)
551 553
         self.assertRedirects(login, '/test_admin/admin/')
552  
-        self.failIf(login.context)
  554
+        self.assertFalse(login.context)
553 555
         self.client.get('/test_admin/admin/logout/')
554 556
 
555 557
         # Delete User
556 558
         request = self.client.get('/test_admin/admin/')
557  
-        self.failUnlessEqual(request.status_code, 200)
  559
+        self.assertEqual(request.status_code, 200)
558 560
         login = self.client.post('/test_admin/admin/', self.deleteuser_login)
559 561
         self.assertRedirects(login, '/test_admin/admin/')
560  
-        self.failIf(login.context)
  562
+        self.assertFalse(login.context)
561 563
         self.client.get('/test_admin/admin/logout/')
562 564
 
563 565
         # Regular User should not be able to login.
564 566
         request = self.client.get('/test_admin/admin/')
565  
-        self.failUnlessEqual(request.status_code, 200)
  567
+        self.assertEqual(request.status_code, 200)
566 568
         login = self.client.post('/test_admin/admin/', self.joepublic_login)
567  
-        self.failUnlessEqual(login.status_code, 200)
  569
+        self.assertEqual(login.status_code, 200)
568 570
         self.assertContains(login, "Please enter a correct username and password.")
569 571
 
570 572
         # Requests without username should not return 500 errors.
571 573
         request = self.client.get('/test_admin/admin/')
572  
-        self.failUnlessEqual(request.status_code, 200)
  574
+        self.assertEqual(request.status_code, 200)
573 575
         login = self.client.post('/test_admin/admin/', self.no_username_login)
574  
-        self.failUnlessEqual(login.status_code, 200)
  576
+        self.assertEqual(login.status_code, 200)
575 577
         form = login.context[0].get('form')
576  
-        self.failUnlessEqual(form.errors['username'][0], 'This field is required.')
  578
+        self.assertEqual(form.errors['username'][0], 'This field is required.')
577 579
 
578 580
     def testLoginSuccessfullyRedirectsToOriginalUrl(self):
579 581
         request = self.client.get('/test_admin/admin/')
580  
-        self.failUnlessEqual(request.status_code, 200)
  582
+        self.assertEqual(request.status_code, 200)
581 583
         query_string = 'the-answer=42'
582 584
         redirect_url = '/test_admin/admin/?%s' % query_string
583 585
         new_next = {REDIRECT_FIELD_NAME: redirect_url}
@@ -596,26 +598,26 @@ def testAddView(self):
596 598
         self.client.get('/test_admin/admin/')
597 599
         self.client.post('/test_admin/admin/', self.changeuser_login)
598 600
         # make sure the view removes test cookie
599  
-        self.failUnlessEqual(self.client.session.test_cookie_worked(), False)
  601
+        self.assertEqual(self.client.session.test_cookie_worked(), False)
600 602
         request = self.client.get('/test_admin/admin/admin_views/article/add/')
601  
-        self.failUnlessEqual(request.status_code, 403)
  603
+        self.assertEqual(request.status_code, 403)
602 604
         # Try POST just to make sure
603 605
         post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
604  
-        self.failUnlessEqual(post.status_code, 403)
605  
-        self.failUnlessEqual(Article.objects.all().count(), 3)
  606
+        self.assertEqual(post.status_code, 403)
  607
+        self.assertEqual(Article.objects.all().count(), 3)
606 608
         self.client.get('/test_admin/admin/logout/')
607 609
 
608 610
         # Add user may login and POST to add view, then redirect to admin root
609 611
         self.client.get('/test_admin/admin/')
610 612
         self.client.post('/test_admin/admin/', self.adduser_login)
611 613
         addpage = self.client.get('/test_admin/admin/admin_views/article/add/')
612  
-        self.failUnlessEqual(addpage.status_code, 200)
  614
+        self.assertEqual(addpage.status_code, 200)
613 615
         change_list_link = '<a href="../">Articles</a> &rsaquo;'
614  
-        self.failIf(change_list_link in addpage.content,
  616
+        self.assertFalse(change_list_link in addpage.content,
615 617
                     'User restricted to add permission is given link to change list view in breadcrumbs.')
616 618
         post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
617 619
         self.assertRedirects(post, '/test_admin/admin/')
618  
-        self.failUnlessEqual(Article.objects.all().count(), 4)
  620
+        self.assertEqual(Article.objects.all().count(), 4)
619 621
         self.assertEquals(len(mail.outbox), 1)
620 622
         self.assertEquals(mail.outbox[0].subject, 'Greetings from a created object')
621 623
         self.client.get('/test_admin/admin/logout/')
@@ -624,12 +626,12 @@ def testAddView(self):
624 626
         self.client.get('/test_admin/admin/')
625 627
         self.client.post('/test_admin/admin/', self.super_login)
626 628
         addpage = self.client.get('/test_admin/admin/admin_views/article/add/')
627  
-        self.failUnlessEqual(addpage.status_code, 200)
628  
-        self.failIf(change_list_link not in addpage.content,
  629
+        self.assertEqual(addpage.status_code, 200)
  630
+        self.assertFalse(change_list_link not in addpage.content,
629 631
                     'Unrestricted user is not given link to change list view in breadcrumbs.')
630 632
         post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
631 633
         self.assertRedirects(post, '/test_admin/admin/admin_views/article/')
632  
-        self.failUnlessEqual(Article.objects.all().count(), 5)
  634
+        self.assertEqual(Article.objects.all().count(), 5)
633 635
         self.client.get('/test_admin/admin/logout/')
634 636
 
635 637
         # 8509 - if a normal user is already logged in, it is possible
@@ -639,7 +641,7 @@ def testAddView(self):
639 641
         self.client.get('/test_admin/admin/')
640 642
         self.client.post('/test_admin/admin/', self.super_login)
641 643
         # make sure the view removes test cookie
642  
-        self.failUnlessEqual(self.client.session.test_cookie_worked(), False)
  644
+        self.assertEqual(self.client.session.test_cookie_worked(), False)
643 645
 
644 646
     def testChangeView(self):
645 647
         """Change view should restrict access and allow users to edit items."""
@@ -653,34 +655,34 @@ def testChangeView(self):
653 655
         self.client.get('/test_admin/admin/')
654 656
         self.client.post('/test_admin/admin/', self.adduser_login)
655 657
         request = self.client.get('/test_admin/admin/admin_views/article/')
656  
-        self.failUnlessEqual(request.status_code, 403)
  658
+        self.assertEqual(request.status_code, 403)
657 659
         request = self.client.get('/test_admin/admin/admin_views/article/1/')
658  
-        self.failUnlessEqual(request.status_code, 403)
  660
+        self.assertEqual(request.status_code, 403)
659 661
         post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict)
660  
-        self.failUnlessEqual(post.status_code, 403)
  662
+        self.assertEqual(post.status_code, 403)
661 663
         self.client.get('/test_admin/admin/logout/')
662 664
 
663 665
         # change user can view all items and edit them
664 666
         self.client.get('/test_admin/admin/')
665 667
         self.client.post('/test_admin/admin/', self.changeuser_login)
666 668
         request = self.client.get('/test_admin/admin/admin_views/article/')
667  
-        self.failUnlessEqual(request.status_code, 200)
  669
+        self.assertEqual(request.status_code, 200)
668 670
         request = self.client.get('/test_admin/admin/admin_views/article/1/')
669  
-        self.failUnlessEqual(request.status_code, 200)
  671
+        self.assertEqual(request.status_code, 200)
670 672
         post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict)
671 673
         self.assertRedirects(post, '/test_admin/admin/admin_views/article/')
672  
-        self.failUnlessEqual(Article.objects.get(pk=1).content, '<p>edited article</p>')
  674
+        self.assertEqual(Article.objects.get(pk=1).content, '<p>edited article</p>')
673 675
 
674 676
         # one error in form should produce singular error message, multiple errors plural
675 677
         change_dict['title'] = ''
676 678
         post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict)
677  
-        self.failUnlessEqual(request.status_code, 200)
678  
-        self.failUnless('Please correct the error below.' in post.content,
  679
+        self.assertEqual(request.status_code, 200)
  680
+        self.assertTrue('Please correct the error below.' in post.content,
679 681
                         'Singular error message not found in response to post with one error.')
680 682
         change_dict['content'] = ''
681 683
         post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict)
682  
-        self.failUnlessEqual(request.status_code, 200)
683  
-        self.failUnless('Please correct the errors below.' in post.content,
  684
+        self.assertEqual(request.status_code, 200)
  685
+        self.assertTrue('Please correct the errors below.' in post.content,
684 686
                         'Plural error message not found in response to post with multiple errors.')
685 687
         self.client.get('/test_admin/admin/logout/')
686 688
 
@@ -712,7 +714,7 @@ def testCustomModelAdminTemplates(self):
712 714
 
713 715
         # Test custom change list template with custom extra context
714 716
         request = self.client.get('/test_admin/admin/admin_views/customarticle/')
715  
-        self.failUnlessEqual(request.status_code, 200)
  717
+        self.assertEqual(request.status_code, 200)
716 718
         self.assert_("var hello = 'Hello!';" in request.content)
717 719
         self.assertTemplateUsed(request, 'custom_admin/change_list.html')
718 720
 
@@ -727,7 +729,7 @@ def testCustomModelAdminTemplates(self):
727 729
             'date_1': '10:54:39'
728 730
         })
729 731
         self.assertRedirects(post, '/test_admin/admin/admin_views/customarticle/')
730  
-        self.failUnlessEqual(CustomArticle.objects.all().count(), 1)
  732
+        self.assertEqual(CustomArticle.objects.all().count(), 1)
731 733
 
732 734
         # Test custom delete, change, and object history templates
733 735
         # Test custom change form template
@@ -755,10 +757,10 @@ def testDeleteView(self):
755 757
         self.client.get('/test_admin/admin/')
756 758
         self.client.post('/test_admin/admin/', self.adduser_login)
757 759
         request = self.client.get('/test_admin/admin/admin_views/article/1/delete/')
758  
-        self.failUnlessEqual(request.status_code, 403)
  760
+        self.assertEqual(request.status_code, 403)
759 761
         post = self.client.post('/test_admin/admin/admin_views/article/1/delete/', delete_dict)
760  
-        self.failUnlessEqual(post.status_code, 403)
761  
-        self.failUnlessEqual(Article.objects.all().count(), 3)
  762
+        self.assertEqual(post.status_code, 403)
  763
+        self.assertEqual(Article.objects.all().count(), 3)
762 764
         self.client.get('/test_admin/admin/logout/')
763 765
 
764 766
         # Delete user can delete
@@ -769,15 +771,15 @@ def testDeleteView(self):
769 771
         self.assertContains(response, "admin_views/article/1/")
770 772
 
771 773
         response = self.client.get('/test_admin/admin/admin_views/article/1/delete/')
772  
-        self.failUnlessEqual(response.status_code, 200)
  774
+        self.assertEqual(response.status_code, 200)
773 775
         post = self.client.post('/test_admin/admin/admin_views/article/1/delete/', delete_dict)
774 776
         self.assertRedirects(post, '/test_admin/admin/')
775  
-        self.failUnlessEqual(Article.objects.all().count(), 2)
  777
+        self.assertEqual(Article.objects.all().count(), 2)
776 778
         self.assertEquals(len(mail.outbox), 1)
777 779
         self.assertEquals(mail.outbox[0].subject, 'Greetings from a deleted object')
778 780
         article_ct = ContentType.objects.get_for_model(Article)
779 781
         logged = LogEntry.objects.get(content_type=article_ct, action_flag=DELETION)
780  
-        self.failUnlessEqual(logged.object_id, u'1')
  782
+        self.assertEqual(logged.object_id, u'1')
781 783
         self.client.get('/test_admin/admin/logout/')
782 784
 
783 785
     def testDisabledPermissionsWhenLoggedIn(self):
@@ -810,7 +812,7 @@ def test_nesting(self):
810 812
         """
811 813
         pattern = re.compile(r"""<li>Plot: <a href=".+/admin_views/plot/1/">World Domination</a>\s*<ul>\s*<li>Plot details: <a href=".+/admin_views/plotdetails/1/">almost finished</a>""")
812 814
         response = self.client.get('/test_admin/admin/admin_views/villain/%s/delete/' % quote(1))
813  
-        self.failUnless(pattern.search(response.content))
  815
+        self.assertTrue(pattern.search(response.content))
814 816
 
815 817
     def test_cyclic(self):
816 818
         """
@@ -831,7 +833,7 @@ def test_perms_needed(self):
831 833
         delete_user.user_permissions.add(get_perm(Plot,
832 834
             Plot._meta.get_delete_permission()))
833 835
 
834  
-        self.failUnless(self.client.login(username='deleteuser',
  836
+        self.assertTrue(self.client.login(username='deleteuser',
835 837
                                           password='secret'))
836 838
 
837 839
         response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(1))
@@ -919,13 +921,13 @@ def test_get_history_view(self):
919 921
         "Retrieving the history for the object using urlencoded form of primary key should work"
920 922
         response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/history/' % quote(self.pk))
921 923
         self.assertContains(response, escape(self.pk))
922  
-        self.failUnlessEqual(response.status_code, 200)
  924
+        self.assertEqual(response.status_code, 200)
923 925
 
924 926
     def test_get_change_view(self):
925 927
         "Retrieving the object using urlencoded form of primary key should work"
926 928
         response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/' % quote(self.pk))
927 929
         self.assertContains(response, escape(self.pk))
928  
-        self.failUnlessEqual(response.status_code, 200)
  930
+        self.assertEqual(response.status_code, 200)
929 931
 
930 932
     def test_changelist_to_changeform_link(self):
931 933
         "The link from the changelist referring to the changeform of the object should be quoted"
@@ -1049,7 +1051,7 @@ def test_secure_view_shows_login_if_not_logged_in(self):
1049 1051
 
1050 1052
     def test_secure_view_login_successfully_redirects_to_original_url(self):
1051 1053
         request = self.client.get('/test_admin/admin/secure-view/')
1052  
-        self.failUnlessEqual(request.status_code, 200)
  1054
+        self.assertEqual(request.status_code, 200)
1053 1055
         query_string = 'the-answer=42'
1054 1056
         redirect_url = '/test_admin/admin/secure-view/?%s' % query_string
1055 1057
         new_next = {REDIRECT_FIELD_NAME: redirect_url}
@@ -1066,17 +1068,17 @@ def test_staff_member_required_decorator_works_as_per_admin_login(self):
1066 1068
         """
1067 1069
         # Super User
1068 1070
         request = self.client.get('/test_admin/admin/secure-view/')
1069  
-        self.failUnlessEqual(request.status_code, 200)
  1071
+        self.assertEqual(request.status_code, 200)
1070 1072
         login = self.client.post('/test_admin/admin/secure-view/', self.super_login)
1071 1073
         self.assertRedirects(login, '/test_admin/admin/secure-view/')
1072  
-        self.failIf(login.context)
  1074
+        self.assertFalse(login.context)
1073 1075
         self.client.get('/test_admin/admin/logout/')
1074 1076
         # make sure the view removes test cookie
1075  
-        self.failUnlessEqual(self.client.session.test_cookie_worked(), False)
  1077
+        self.assertEqual(self.client.session.test_cookie_worked(), False)
1076 1078
 
1077 1079
         # Test if user enters e-mail address
1078 1080
         request = self.client.get('/test_admin/admin/secure-view/')
1079  
-        self.failUnlessEqual(request.status_code, 200)
  1081
+        self.assertEqual(request.status_code, 200)
1080 1082
         login = self.client.post('/test_admin/admin/secure-view/', self.super_email_login)
1081 1083
         self.assertContains(login, "Your e-mail address is not your username")
1082 1084
         # only correct passwords get a username hint
@@ -1090,33 +1092,33 @@ def test_staff_member_required_decorator_works_as_per_admin_login(self):
1090 1092
 
1091 1093
         # Add User
1092 1094
         request = self.client.get('/test_admin/admin/secure-view/')
1093  
-        self.failUnlessEqual(request.status_code, 200)
  1095
+        self.assertEqual(request.status_code, 200)
1094 1096
         login = self.client.post('/test_admin/admin/secure-view/', self.adduser_login)
1095 1097
         self.assertRedirects(login, '/test_admin/admin/secure-view/')
1096  
-        self.failIf(login.context)
  1098
+        self.assertFalse(login.context)
1097 1099
         self.client.get('/test_admin/admin/logout/')
1098 1100
 
1099 1101
         # Change User
1100 1102
         request = self.client.get('/test_admin/admin/secure-view/')
1101  
-        self.failUnlessEqual(request.status_code, 200)
  1103
+        self.assertEqual(request.status_code, 200)
1102 1104
         login = self.client.post('/test_admin/admin/secure-view/', self.changeuser_login)
1103 1105
         self.assertRedirects(login, '/test_admin/admin/secure-view/')
1104  
-        self.failIf(login.context)
  1106
+        self.assertFalse(login.context)
1105 1107
         self.client.get('/test_admin/admin/logout/')
1106 1108
 
1107 1109
         # Delete User
1108 1110
         request = self.client.get('/test_admin/admin/secure-view/')
1109  
-        self.failUnlessEqual(request.status_code, 200)
  1111
+        self.assertEqual(request.status_code, 200)
1110 1112
         login = self.client.post('/test_admin/admin/secure-view/', self.deleteuser_login)
1111 1113
         self.assertRedirects(login, '/test_admin/admin/secure-view/')
1112  
-        self.failIf(login.context)
  1114
+        self.assertFalse(login.context)
1113 1115
         self.client.get('/test_admin/admin/logout/')
1114 1116
 
1115 1117
         # Regular User should not be able to login.
1116 1118
         request = self.client.get('/test_admin/admin/secure-view/')
1117  
-        self.failUnlessEqual(request.status_code, 200)
  1119
+        self.assertEqual(request.status_code, 200)
1118 1120
         login = self.client.post('/test_admin/admin/secure-view/', self.joepublic_login)
1119  
-        self.failUnlessEqual(login.status_code, 200)
  1121
+        self.assertEqual(login.status_code, 200)
1120 1122
         # Login.context is a list of context dicts we just need to check the first one.
1121 1123
         self.assertContains(login, "Please enter a correct username and password.")
1122 1124
 
@@ -1127,7 +1129,7 @@ def test_staff_member_required_decorator_works_as_per_admin_login(self):
1127 1129
         self.client.get('/test_admin/admin/secure-view/')
1128 1130
         self.client.post('/test_admin/admin/secure-view/', self.super_login)
1129 1131
         # make sure the view removes test cookie
1130  
-        self.failUnlessEqual(self.client.session.test_cookie_worked(), False)
  1132
+        self.assertEqual(self.client.session.test_cookie_worked(), False)
1131 1133
 
1132 1134
 class AdminViewUnicodeTest(TestCase):
1133 1135
     fixtures = ['admin-views-unicode.xml']
@@ -1169,7 +1171,7 @@ def testUnicodeEdit(self):
1169 1171
         }
1170 1172
 
1171 1173
         response = self.client.post('/test_admin/admin/admin_views/book/1/', post_data)
1172  
-        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
  1174
+        self.assertEqual(response.status_code, 302) # redirect somewhere
1173 1175
 
1174 1176
     def testUnicodeDelete(self):
1175 1177
         """
@@ -1177,7 +1179,7 @@ def testUnicodeDelete(self):
1177 1179
         """
1178 1180
         delete_dict = {'post': 'yes'}
1179 1181
         response = self.client.get('/test_admin/admin/admin_views/book/1/delete/')
1180  
-        self.failUnlessEqual(response.status_code, 200)
  1182
+        self.assertEqual(response.status_code, 200)
1181 1183
         response = self.client.post('/test_admin/admin/admin_views/book/1/delete/', delete_dict)
1182 1184
         self.assertRedirects(response, '/test_admin/admin/admin_views/book/')
1183 1185
 
@@ -1195,17 +1197,17 @@ def test_inheritance(self):
1195 1197
         Podcast.objects.create(name="This Week in Django",
1196 1198
             release_date=datetime.date.today())
1197 1199
         response = self.client.get('/test_admin/admin/admin_views/podcast/')
1198  
-        self.failUnlessEqual(response.status_code, 200)
  1200
+        self.assertEqual(response.status_code, 200)
1199 1201
 
1200 1202
     def test_inheritance_2(self):
1201 1203
         Vodcast.objects.create(name="This Week in Django", released=True)
1202 1204
         response = self.client.get('/test_admin/admin/admin_views/vodcast/')
1203  
-        self.failUnlessEqual(response.status_code, 200)
  1205
+        self.assertEqual(response.status_code, 200)
1204 1206
 
1205 1207
     def test_custom_pk(self):
1206 1208
         Language.objects.create(iso='en', name='English', english_name='English')
1207 1209
         response = self.client.get('/test_admin/admin/admin_views/language/')
1208  
-        self.failUnlessEqual(response.status_code, 200)
  1210
+        self.assertEqual(response.status_code, 200)
1209 1211
 
1210 1212
     def test_changelist_input_html(self):
1211 1213
         response = self.client.get('/test_admin/admin/admin_views/person/')
@@ -1217,9 +1219,9 @@ def test_changelist_input_html(self):
1217 1219
         # CSRF field = 1
1218 1220
         # field to track 'select all' across paginated views = 1
1219 1221
         # 6 + 3 + 4 + 1 + 2 + 1 + 1 = 18 inputs
1220  
-        self.failUnlessEqual(response.content.count("<input"), 18)
  1222
+        self.assertEqual(response.content.count("<input"), 18)
1221 1223
         # 1 select per object = 3 selects
1222  
-        self.failUnlessEqual(response.content.count("<select"), 4)
  1224
+        self.assertEqual(response.content.count("<select"), 4)
1223 1225
 
1224 1226
     def test_post_messages(self):
1225 1227
         # Ticket 12707: Saving inline editable should not show admin
@@ -1265,8 +1267,8 @@ def test_post_submission(self):
1265 1267
         }
1266 1268
         self.client.post('/test_admin/admin/admin_views/person/', data)
1267 1269
 
1268  
-        self.failUnlessEqual(Person.objects.get(name="John Mauchly").alive, False)
1269  
-        self.failUnlessEqual(Person.objects.get(name="Grace Hopper").gender, 2)
  1270
+        self.assertEqual(Person.objects.get(name="John Mauchly").alive, False)