Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated test assertions that have been deprecated by the move to unit…

…test2. In summary, this means:

 assert_ -> assertTrue
 assertEquals -> assertEqual
 failUnless -> assertTrue

For full details, see http://www.voidspace.org.uk/python/articles/unittest2.shtml#deprecations

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15728 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit afd040d4d3a06fe92e3080870b2ff2095ce86a75 1 parent b7c41c1
Russell Keith-Magee authored March 03, 2011

Showing 110 changed files with 1,198 additions and 1,198 deletions. Show diff stats Hide diff stats

  1. 6  django/contrib/auth/tests/basic.py
  2. 2  django/contrib/auth/tests/decorators.py
  3. 8  django/contrib/auth/tests/remote_user.py
  4. 114  django/contrib/auth/tests/views.py
  5. 16  django/contrib/flatpages/tests/csrf.py
  6. 12  django/contrib/flatpages/tests/middleware.py
  7. 14  django/contrib/flatpages/tests/templatetags.py
  8. 12  django/contrib/flatpages/tests/views.py
  9. 16  django/contrib/formtools/tests/__init__.py
  10. 4  django/contrib/gis/gdal/tests/test_geom.py
  11. 18  django/contrib/gis/geos/tests/test_geos.py
  12. 34  django/contrib/gis/geos/tests/test_mutable_list.py
  13. 12  django/contrib/gis/tests/geo3d/tests.py
  14. 10  django/contrib/gis/tests/geoapp/tests.py
  15. 8  django/contrib/gis/tests/relatedapp/tests.py
  16. 2  django/contrib/gis/tests/test_geoforms.py
  17. 14  django/contrib/gis/tests/test_measure.py
  18. 8  django/contrib/messages/tests/base.py
  19. 2  django/contrib/messages/tests/cookie.py
  20. 12  django/contrib/sitemaps/tests/basic.py
  21. 6  django/contrib/sites/tests.py
  22. 8  django/utils/unittest/case.py
  23. 2  docs/topics/testing.txt
  24. 2  tests/modeltests/aggregation/tests.py
  25. 2  tests/modeltests/model_formsets/tests.py
  26. 4  tests/modeltests/model_inheritance_same_model_name/tests.py
  27. 4  tests/modeltests/proxy_model_inheritance/tests.py
  28. 10  tests/modeltests/raw_query/tests.py
  29. 2  tests/modeltests/serializers/tests.py
  30. 6  tests/modeltests/test_client/models.py
  31. 4  tests/modeltests/unmanaged_models/tests.py
  32. 4  tests/modeltests/user_commands/tests.py
  33. 4  tests/modeltests/validation/__init__.py
  34. 12  tests/modeltests/validators/tests.py
  35. 60  tests/regressiontests/admin_filterspecs/tests.py
  36. 4  tests/regressiontests/admin_scripts/tests.py
  37. 34  tests/regressiontests/admin_util/tests.py
  38. 62  tests/regressiontests/admin_views/tests.py
  39. 6  tests/regressiontests/admin_widgets/tests.py
  40. 18  tests/regressiontests/aggregation_regress/tests.py
  41. 2  tests/regressiontests/app_loading/tests.py
  42. 2  tests/regressiontests/builtin_server/tests.py
  43. 84  tests/regressiontests/cache/tests.py
  44. 6  tests/regressiontests/comment_tests/tests/comment_form_tests.py
  45. 12  tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
  46. 6  tests/regressiontests/comment_tests/tests/comment_view_tests.py
  47. 4  tests/regressiontests/comment_tests/tests/feed_tests.py
  48. 6  tests/regressiontests/comment_tests/tests/moderation_view_tests.py
  49. 10  tests/regressiontests/comment_tests/tests/templatetag_tests.py
  50. 20  tests/regressiontests/conditional_processing/models.py
  51. 26  tests/regressiontests/csrf_tests/tests.py
  52. 6  tests/regressiontests/datatypes/tests.py
  53. 6  tests/regressiontests/decorators/tests.py
  54. 14  tests/regressiontests/delete_regress/tests.py
  55. 2  tests/regressiontests/dispatch/tests/test_dispatcher.py
  56. 12  tests/regressiontests/dispatch/tests/test_saferef.py
  57. 24  tests/regressiontests/file_storage/tests.py
  58. 10  tests/regressiontests/file_uploads/tests.py
  59. 2  tests/regressiontests/forms/localflavor/fi.py
  60. 2  tests/regressiontests/forms/localflavor/us.py
  61. 8  tests/regressiontests/forms/tests/formsets.py
  62. 8  tests/regressiontests/forms/tests/models.py
  63. 22  tests/regressiontests/generic_inline_admin/tests.py
  64. 22  tests/regressiontests/generic_views/base.py
  65. 4  tests/regressiontests/httpwrappers/tests.py
  66. 34  tests/regressiontests/i18n/commands/extraction.py
  67. 2  tests/regressiontests/i18n/tests.py
  68. 8  tests/regressiontests/introspection/tests.py
  69. 2  tests/regressiontests/mail/tests.py
  70. 2  tests/regressiontests/max_lengths/tests.py
  71. 74  tests/regressiontests/middleware/tests.py
  72. 4  tests/regressiontests/middleware_exceptions/tests.py
  73. 4  tests/regressiontests/model_fields/tests.py
  74. 38  tests/regressiontests/model_forms_regress/tests.py
  75. 6  tests/regressiontests/model_inheritance_regress/tests.py
  76. 2  tests/regressiontests/modeladmin/tests.py
  77. 536  tests/regressiontests/multiple_database/tests.py
  78. 4  tests/regressiontests/null_fk/tests.py
  79. 2  tests/regressiontests/null_queries/tests.py
  80. 4  tests/regressiontests/one_to_one_regress/tests.py
  81. 10  tests/regressiontests/queries/tests.py
  82. 4  tests/regressiontests/reverse_single_related/tests.py
  83. 46  tests/regressiontests/select_related_regress/tests.py
  84. 2  tests/regressiontests/serializers_regress/tests.py
  85. 10  tests/regressiontests/signals_regress/tests.py
  86. 10  tests/regressiontests/staticfiles_tests/tests.py
  87. 18  tests/regressiontests/string_lookup/tests.py
  88. 8  tests/regressiontests/syndication/tests.py
  89. 16  tests/regressiontests/templates/custom.py
  90. 14  tests/regressiontests/templates/response.py
  91. 4  tests/regressiontests/templates/smartif.py
  92. 4  tests/regressiontests/templates/tests.py
  93. 40  tests/regressiontests/test_client_regress/models.py
  94. 44  tests/regressiontests/text/tests.py
  95. 2  tests/regressiontests/transactions_regress/tests.py
  96. 80  tests/regressiontests/urlpatterns_reverse/tests.py
  97. 96  tests/regressiontests/utils/datastructures.py
  98. 90  tests/regressiontests/utils/dateformat.py
  99. 16  tests/regressiontests/utils/datetime_safe.py
  100. 2  tests/regressiontests/utils/simplelazyobject.py
  101. 84  tests/regressiontests/utils/termcolors.py
  102. 62  tests/regressiontests/utils/timesince.py
  103. 22  tests/regressiontests/utils/tzinfo.py
  104. 4  tests/regressiontests/views/tests/debug.py
  105. 14  tests/regressiontests/views/tests/defaults.py
  106. 4  tests/regressiontests/views/tests/generic/create_update.py
  107. 2  tests/regressiontests/views/tests/i18n.py
  108. 44  tests/regressiontests/views/tests/shortcuts.py
  109. 20  tests/regressiontests/views/tests/static.py
  110. 4  tests/runtests.py
6  django/contrib/auth/tests/basic.py
@@ -61,7 +61,7 @@ def test_createsuperuser_management_command(self):
61 61
         command_output = new_io.getvalue().strip()
62 62
         self.assertEqual(command_output, 'Superuser created successfully.')
63 63
         u = User.objects.get(username="joe")
64  
-        self.assertEquals(u.email, 'joe@somewhere.org')
  64
+        self.assertEqual(u.email, 'joe@somewhere.org')
65 65
 
66 66
         # created password should be unusable
67 67
         self.assertFalse(u.has_usable_password())
@@ -78,7 +78,7 @@ def test_createsuperuser_management_command(self):
78 78
         command_output = new_io.getvalue().strip()
79 79
         self.assertEqual(command_output, '')
80 80
         u = User.objects.get(username="joe2")
81  
-        self.assertEquals(u.email, 'joe2@somewhere.org')
  81
+        self.assertEqual(u.email, 'joe2@somewhere.org')
82 82
         self.assertFalse(u.has_usable_password())
83 83
 
84 84
 
@@ -90,6 +90,6 @@ def test_createsuperuser_management_command(self):
90 90
             stdout=new_io
91 91
         )
92 92
         u = User.objects.get(username="joe+admin@somewhere.org")
93  
-        self.assertEquals(u.email, 'joe@somewhere.org')
  93
+        self.assertEqual(u.email, 'joe@somewhere.org')
94 94
         self.assertFalse(u.has_usable_password())
95 95
 
2  django/contrib/auth/tests/decorators.py
@@ -32,7 +32,7 @@ def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGI
32 32
         """
33 33
         response = self.client.get(view_url)
34 34
         self.assertEqual(response.status_code, 302)
35  
-        self.assert_(login_url in response['Location'])
  35
+        self.assertTrue(login_url in response['Location'])
36 36
         self.login()
37 37
         response = self.client.get(view_url)
38 38
         self.assertEqual(response.status_code, 200)
8  django/contrib/auth/tests/remote_user.py
@@ -30,15 +30,15 @@ def test_no_remote_user(self):
30 30
         num_users = User.objects.count()
31 31
 
32 32
         response = self.client.get('/remote_user/')
33  
-        self.assert_(response.context['user'].is_anonymous())
  33
+        self.assertTrue(response.context['user'].is_anonymous())
34 34
         self.assertEqual(User.objects.count(), num_users)
35 35
 
36 36
         response = self.client.get('/remote_user/', REMOTE_USER=None)
37  
-        self.assert_(response.context['user'].is_anonymous())
  37
+        self.assertTrue(response.context['user'].is_anonymous())
38 38
         self.assertEqual(User.objects.count(), num_users)
39 39
 
40 40
         response = self.client.get('/remote_user/', REMOTE_USER='')
41  
-        self.assert_(response.context['user'].is_anonymous())
  41
+        self.assertTrue(response.context['user'].is_anonymous())
42 42
         self.assertEqual(User.objects.count(), num_users)
43 43
 
44 44
     def test_unknown_user(self):
@@ -115,7 +115,7 @@ class that doesn't create unknown users.
115 115
     def test_unknown_user(self):
116 116
         num_users = User.objects.count()
117 117
         response = self.client.get('/remote_user/', REMOTE_USER='newuser')
118  
-        self.assert_(response.context['user'].is_anonymous())
  118
+        self.assertTrue(response.context['user'].is_anonymous())
119 119
         self.assertEqual(User.objects.count(), num_users)
120 120
 
121 121
 
114  django/contrib/auth/tests/views.py
@@ -40,53 +40,53 @@ def login(self, password='password'):
40 40
             'password': password
41 41
             }
42 42
         )
43  
-        self.assertEquals(response.status_code, 302)
44  
-        self.assert_(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))
45  
-        self.assert_(SESSION_KEY in self.client.session)
  43
+        self.assertEqual(response.status_code, 302)
  44
+        self.assertTrue(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))
  45
+        self.assertTrue(SESSION_KEY in self.client.session)
46 46
 
47 47
 class PasswordResetTest(AuthViewsTestCase):
48 48
 
49 49
     def test_email_not_found(self):
50 50
         "Error is raised if the provided email address isn't currently registered"
51 51
         response = self.client.get('/password_reset/')
52  
-        self.assertEquals(response.status_code, 200)
  52
+        self.assertEqual(response.status_code, 200)
53 53
         response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})
54 54
         self.assertContains(response, "That e-mail address doesn't have an associated user account")
55  
-        self.assertEquals(len(mail.outbox), 0)
  55
+        self.assertEqual(len(mail.outbox), 0)
56 56
 
57 57
     def test_email_found(self):
58 58
         "Email is sent if a valid email address is provided for password reset"
59 59
         response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
60  
-        self.assertEquals(response.status_code, 302)
61  
-        self.assertEquals(len(mail.outbox), 1)
62  
-        self.assert_("http://" in mail.outbox[0].body)
63  
-        self.assertEquals(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
  60
+        self.assertEqual(response.status_code, 302)
  61
+        self.assertEqual(len(mail.outbox), 1)
  62
+        self.assertTrue("http://" in mail.outbox[0].body)
  63
+        self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
64 64
 
65 65
     def test_email_found_custom_from(self):
66 66
         "Email is sent if a valid email address is provided for password reset when a custom from_email is provided."
67 67
         response = self.client.post('/password_reset_from_email/', {'email': 'staffmember@example.com'})
68  
-        self.assertEquals(response.status_code, 302)
69  
-        self.assertEquals(len(mail.outbox), 1)
70  
-        self.assertEquals("staffmember@example.com", mail.outbox[0].from_email)
  68
+        self.assertEqual(response.status_code, 302)
  69
+        self.assertEqual(len(mail.outbox), 1)
  70
+        self.assertEqual("staffmember@example.com", mail.outbox[0].from_email)
71 71
 
72 72
     def _test_confirm_start(self):
73 73
         # Start by creating the email
74 74
         response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
75  
-        self.assertEquals(response.status_code, 302)
76  
-        self.assertEquals(len(mail.outbox), 1)
  75
+        self.assertEqual(response.status_code, 302)
  76
+        self.assertEqual(len(mail.outbox), 1)
77 77
         return self._read_signup_email(mail.outbox[0])
78 78
 
79 79
     def _read_signup_email(self, email):
80 80
         urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body)
81  
-        self.assert_(urlmatch is not None, "No URL found in sent email")
  81
+        self.assertTrue(urlmatch is not None, "No URL found in sent email")
82 82
         return urlmatch.group(), urlmatch.groups()[0]
83 83
 
84 84
     def test_confirm_valid(self):
85 85
         url, path = self._test_confirm_start()
86 86
         response = self.client.get(path)
87 87
         # redirect to a 'complete' page:
88  
-        self.assertEquals(response.status_code, 200)
89  
-        self.assert_("Please enter your new password" in response.content)
  88
+        self.assertEqual(response.status_code, 200)
  89
+        self.assertTrue("Please enter your new password" in response.content)
90 90
 
91 91
     def test_confirm_invalid(self):
92 92
         url, path = self._test_confirm_start()
@@ -95,20 +95,20 @@ def test_confirm_invalid(self):
95 95
         path = path[:-5] + ("0"*4) + path[-1]
96 96
 
97 97
         response = self.client.get(path)
98  
-        self.assertEquals(response.status_code, 200)
99  
-        self.assert_("The password reset link was invalid" in response.content)
  98
+        self.assertEqual(response.status_code, 200)
  99
+        self.assertTrue("The password reset link was invalid" in response.content)
100 100
 
101 101
     def test_confirm_invalid_user(self):
102 102
         # Ensure that we get a 200 response for a non-existant user, not a 404
103 103
         response = self.client.get('/reset/123456-1-1/')
104  
-        self.assertEquals(response.status_code, 200)
105  
-        self.assert_("The password reset link was invalid" in response.content)
  104
+        self.assertEqual(response.status_code, 200)
  105
+        self.assertTrue("The password reset link was invalid" in response.content)
106 106
 
107 107
     def test_confirm_overflow_user(self):
108 108
         # Ensure that we get a 200 response for a base36 user id that overflows int
109 109
         response = self.client.get('/reset/zzzzzzzzzzzzz-1-1/')
110  
-        self.assertEquals(response.status_code, 200)
111  
-        self.assert_("The password reset link was invalid" in response.content)
  110
+        self.assertEqual(response.status_code, 200)
  111
+        self.assertTrue("The password reset link was invalid" in response.content)
112 112
 
113 113
     def test_confirm_invalid_post(self):
114 114
         # Same as test_confirm_invalid, but trying
@@ -120,29 +120,29 @@ def test_confirm_invalid_post(self):
120 120
                                            'new_password2':' anewpassword'})
121 121
         # Check the password has not been changed
122 122
         u = User.objects.get(email='staffmember@example.com')
123  
-        self.assert_(not u.check_password("anewpassword"))
  123
+        self.assertTrue(not u.check_password("anewpassword"))
124 124
 
125 125
     def test_confirm_complete(self):
126 126
         url, path = self._test_confirm_start()
127 127
         response = self.client.post(path, {'new_password1': 'anewpassword',
128 128
                                            'new_password2': 'anewpassword'})
129 129
         # It redirects us to a 'complete' page:
130  
-        self.assertEquals(response.status_code, 302)
  130
+        self.assertEqual(response.status_code, 302)
131 131
         # Check the password has been changed
132 132
         u = User.objects.get(email='staffmember@example.com')
133  
-        self.assert_(u.check_password("anewpassword"))
  133
+        self.assertTrue(u.check_password("anewpassword"))
134 134
 
135 135
         # Check we can't use the link again
136 136
         response = self.client.get(path)
137  
-        self.assertEquals(response.status_code, 200)
138  
-        self.assert_("The password reset link was invalid" in response.content)
  137
+        self.assertEqual(response.status_code, 200)
  138
+        self.assertTrue("The password reset link was invalid" in response.content)
139 139
 
140 140
     def test_confirm_different_passwords(self):
141 141
         url, path = self._test_confirm_start()
142 142
         response = self.client.post(path, {'new_password1': 'anewpassword',
143 143
                                            'new_password2':' x'})
144  
-        self.assertEquals(response.status_code, 200)
145  
-        self.assert_("The two password fields didn't match" in response.content)
  144
+        self.assertEqual(response.status_code, 200)
  145
+        self.assertTrue("The two password fields didn't match" in response.content)
146 146
 
147 147
 class ChangePasswordTest(AuthViewsTestCase):
148 148
 
@@ -152,8 +152,8 @@ def fail_login(self, password='password'):
152 152
             'password': password
153 153
             }
154 154
         )
155  
-        self.assertEquals(response.status_code, 200)
156  
-        self.assert_("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content)
  155
+        self.assertEqual(response.status_code, 200)
  156
+        self.assertTrue("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content)
157 157
 
158 158
     def logout(self):
159 159
         response = self.client.get('/logout/')
@@ -166,8 +166,8 @@ def test_password_change_fails_with_invalid_old_password(self):
166 166
             'new_password2': 'password1',
167 167
             }
168 168
         )
169  
-        self.assertEquals(response.status_code, 200)
170  
-        self.assert_("Your old password was entered incorrectly. Please enter it again." in response.content)
  169
+        self.assertEqual(response.status_code, 200)
  170
+        self.assertTrue("Your old password was entered incorrectly. Please enter it again." in response.content)
171 171
 
172 172
     def test_password_change_fails_with_mismatched_passwords(self):
173 173
         self.login()
@@ -177,8 +177,8 @@ def test_password_change_fails_with_mismatched_passwords(self):
177 177
             'new_password2': 'donuts',
178 178
             }
179 179
         )
180  
-        self.assertEquals(response.status_code, 200)
181  
-        self.assert_("The two password fields didn't match." in response.content)
  180
+        self.assertEqual(response.status_code, 200)
  181
+        self.assertTrue("The two password fields didn't match." in response.content)
182 182
 
183 183
     def test_password_change_succeeds(self):
184 184
         self.login()
@@ -188,8 +188,8 @@ def test_password_change_succeeds(self):
188 188
             'new_password2': 'password1',
189 189
             }
190 190
         )
191  
-        self.assertEquals(response.status_code, 302)
192  
-        self.assert_(response['Location'].endswith('/password_change/done/'))
  191
+        self.assertEqual(response.status_code, 302)
  192
+        self.assertTrue(response['Location'].endswith('/password_change/done/'))
193 193
         self.fail_login()
194 194
         self.login(password='password1')
195 195
 
@@ -197,14 +197,14 @@ class LoginTest(AuthViewsTestCase):
197 197
 
198 198
     def test_current_site_in_context_after_login(self):
199 199
         response = self.client.get(reverse('django.contrib.auth.views.login'))
200  
-        self.assertEquals(response.status_code, 200)
  200
+        self.assertEqual(response.status_code, 200)
201 201
         if Site._meta.installed:
202 202
             site = Site.objects.get_current()
203  
-            self.assertEquals(response.context['site'], site)
204  
-            self.assertEquals(response.context['site_name'], site.name)
  203
+            self.assertEqual(response.context['site'], site)
  204
+            self.assertEqual(response.context['site_name'], site.name)
205 205
         else:
206 206
             self.assertIsInstance(response.context['site'], RequestSite)
207  
-        self.assert_(isinstance(response.context['form'], AuthenticationForm), 
  207
+        self.assertTrue(isinstance(response.context['form'], AuthenticationForm),
208 208
                      'Login form is not an AuthenticationForm')
209 209
 
210 210
     def test_security_check(self, password='password'):
@@ -226,7 +226,7 @@ def test_security_check(self, password='password'):
226 226
                 'password': password,
227 227
                 }
228 228
             )
229  
-            self.assertEquals(response.status_code, 302)
  229
+            self.assertEqual(response.status_code, 302)
230 230
             self.assertFalse(bad_url in response['Location'],
231 231
                              "%s should be blocked" % bad_url)
232 232
 
@@ -249,14 +249,14 @@ def test_security_check(self, password='password'):
249 249
                     'password': password,
250 250
                 }
251 251
             )
252  
-            self.assertEquals(response.status_code, 302)
  252
+            self.assertEqual(response.status_code, 302)
253 253
             self.assertTrue(good_url in response['Location'],
254 254
                             "%s should be allowed" % good_url)
255 255
 
256 256
 
257 257
 class LoginURLSettings(AuthViewsTestCase):
258 258
     urls = 'django.contrib.auth.tests.urls'
259  
-    
  259
+
260 260
     def setUp(self):
261 261
         super(LoginURLSettings, self).setUp()
262 262
         self.old_LOGIN_URL = settings.LOGIN_URL
@@ -268,7 +268,7 @@ def tearDown(self):
268 268
     def get_login_required_url(self, login_url):
269 269
         settings.LOGIN_URL = login_url
270 270
         response = self.client.get('/login_required/')
271  
-        self.assertEquals(response.status_code, 302)
  271
+        self.assertEqual(response.status_code, 302)
272 272
         return response['Location']
273 273
 
274 274
     def test_standard_login_url(self):
@@ -317,14 +317,14 @@ class LogoutTest(AuthViewsTestCase):
317 317
     urls = 'django.contrib.auth.tests.urls'
318 318
 
319 319
     def confirm_logged_out(self):
320  
-        self.assert_(SESSION_KEY not in self.client.session)
  320
+        self.assertTrue(SESSION_KEY not in self.client.session)
321 321
 
322 322
     def test_logout_default(self):
323 323
         "Logout without next_page option renders the default template"
324 324
         self.login()
325 325
         response = self.client.get('/logout/')
326  
-        self.assertEquals(200, response.status_code)
327  
-        self.assert_('Logged out' in response.content)
  326
+        self.assertEqual(200, response.status_code)
  327
+        self.assertTrue('Logged out' in response.content)
328 328
         self.confirm_logged_out()
329 329
 
330 330
     def test_14377(self):
@@ -338,20 +338,20 @@ def test_logout_with_overridden_redirect_url(self):
338 338
         self.login()
339 339
         response = self.client.get('/logout/next_page/')
340 340
         self.assertEqual(response.status_code, 302)
341  
-        self.assert_(response['Location'].endswith('/somewhere/'))
  341
+        self.assertTrue(response['Location'].endswith('/somewhere/'))
342 342
 
343 343
         response = self.client.get('/logout/next_page/?next=/login/')
344 344
         self.assertEqual(response.status_code, 302)
345  
-        self.assert_(response['Location'].endswith('/login/'))
  345
+        self.assertTrue(response['Location'].endswith('/login/'))
346 346
 
347 347
         self.confirm_logged_out()
348 348
 
349  
-    def test_logout_with_next_page_specified(self): 
  349
+    def test_logout_with_next_page_specified(self):
350 350
         "Logout with next_page option given redirects to specified resource"
351 351
         self.login()
352 352
         response = self.client.get('/logout/next_page/')
353 353
         self.assertEqual(response.status_code, 302)
354  
-        self.assert_(response['Location'].endswith('/somewhere/'))
  354
+        self.assertTrue(response['Location'].endswith('/somewhere/'))
355 355
         self.confirm_logged_out()
356 356
 
357 357
     def test_logout_with_redirect_argument(self):
@@ -359,7 +359,7 @@ def test_logout_with_redirect_argument(self):
359 359
         self.login()
360 360
         response = self.client.get('/logout/?next=/login/')
361 361
         self.assertEqual(response.status_code, 302)
362  
-        self.assert_(response['Location'].endswith('/login/'))
  362
+        self.assertTrue(response['Location'].endswith('/login/'))
363 363
         self.confirm_logged_out()
364 364
 
365 365
     def test_logout_with_custom_redirect_argument(self):
@@ -367,7 +367,7 @@ def test_logout_with_custom_redirect_argument(self):
367 367
         self.login()
368 368
         response = self.client.get('/logout/custom_query/?follow=/somewhere/')
369 369
         self.assertEqual(response.status_code, 302)
370  
-        self.assert_(response['Location'].endswith('/somewhere/'))
  370
+        self.assertTrue(response['Location'].endswith('/somewhere/'))
371 371
         self.confirm_logged_out()
372 372
 
373 373
     def test_security_check(self, password='password'):
@@ -386,7 +386,7 @@ def test_security_check(self, password='password'):
386 386
             }
387 387
             self.login()
388 388
             response = self.client.get(nasty_url)
389  
-            self.assertEquals(response.status_code, 302)
  389
+            self.assertEqual(response.status_code, 302)
390 390
             self.assertFalse(bad_url in response['Location'],
391 391
                              "%s should be blocked" % bad_url)
392 392
             self.confirm_logged_out()
@@ -407,7 +407,7 @@ def test_security_check(self, password='password'):
407 407
             }
408 408
             self.login()
409 409
             response = self.client.get(safe_url)
410  
-            self.assertEquals(response.status_code, 302)
  410
+            self.assertEqual(response.status_code, 302)
411 411
             self.assertTrue(good_url in response['Location'],
412 412
                             "%s should be allowed" % good_url)
413 413
             self.confirm_logged_out()
16  django/contrib/flatpages/tests/csrf.py
@@ -34,13 +34,13 @@ def tearDown(self):
34 34
     def test_view_flatpage(self):
35 35
         "A flatpage can be served through a view, even when the middleware is in use"
36 36
         response = self.client.get('/flatpage_root/flatpage/')
37  
-        self.assertEquals(response.status_code, 200)
  37
+        self.assertEqual(response.status_code, 200)
38 38
         self.assertContains(response, "<p>Isn't it flat!</p>")
39 39
 
40 40
     def test_view_non_existent_flatpage(self):
41 41
         "A non-existent flatpage raises 404 when served through a view, even when the middleware is in use"
42 42
         response = self.client.get('/flatpage_root/no_such_flatpage/')
43  
-        self.assertEquals(response.status_code, 404)
  43
+        self.assertEqual(response.status_code, 404)
44 44
 
45 45
     def test_view_authenticated_flatpage(self):
46 46
         "A flatpage served through a view can require authentication"
@@ -49,31 +49,31 @@ def test_view_authenticated_flatpage(self):
49 49
         User.objects.create_user('testuser', 'test@example.com', 's3krit')
50 50
         self.client.login(username='testuser',password='s3krit')
51 51
         response = self.client.get('/flatpage_root/sekrit/')
52  
-        self.assertEquals(response.status_code, 200)
  52
+        self.assertEqual(response.status_code, 200)
53 53
         self.assertContains(response, "<p>Isn't it sekrit!</p>")
54 54
 
55 55
     def test_fallback_flatpage(self):
56 56
         "A flatpage can be served by the fallback middlware"
57 57
         response = self.client.get('/flatpage/')
58  
-        self.assertEquals(response.status_code, 200)
  58
+        self.assertEqual(response.status_code, 200)
59 59
         self.assertContains(response, "<p>Isn't it flat!</p>")
60 60
 
61 61
     def test_fallback_non_existent_flatpage(self):
62 62
         "A non-existent flatpage raises a 404 when served by the fallback middlware"
63 63
         response = self.client.get('/no_such_flatpage/')
64  
-        self.assertEquals(response.status_code, 404)
  64
+        self.assertEqual(response.status_code, 404)
65 65
 
66 66
     def test_post_view_flatpage(self):
67 67
         "POSTing to a flatpage served through a view will raise a CSRF error if no token is provided (Refs #14156)"
68 68
         response = self.client.post('/flatpage_root/flatpage/')
69  
-        self.assertEquals(response.status_code, 403)
  69
+        self.assertEqual(response.status_code, 403)
70 70
 
71 71
     def test_post_fallback_flatpage(self):
72 72
         "POSTing to a flatpage served by the middleware will raise a CSRF error if no token is provided (Refs #14156)"
73 73
         response = self.client.post('/flatpage/')
74  
-        self.assertEquals(response.status_code, 403)
  74
+        self.assertEqual(response.status_code, 403)
75 75
 
76 76
     def test_post_unknown_page(self):
77 77
         "POSTing to an unknown page isn't caught as a 403 CSRF error"
78 78
         response = self.client.post('/no_such_page/')
79  
-        self.assertEquals(response.status_code, 404)
  79
+        self.assertEqual(response.status_code, 404)
12  django/contrib/flatpages/tests/middleware.py
@@ -30,13 +30,13 @@ def tearDown(self):
30 30
     def test_view_flatpage(self):
31 31
         "A flatpage can be served through a view, even when the middleware is in use"
32 32
         response = self.client.get('/flatpage_root/flatpage/')
33  
-        self.assertEquals(response.status_code, 200)
  33
+        self.assertEqual(response.status_code, 200)
34 34
         self.assertContains(response, "<p>Isn't it flat!</p>")
35 35
 
36 36
     def test_view_non_existent_flatpage(self):
37 37
         "A non-existent flatpage raises 404 when served through a view, even when the middleware is in use"
38 38
         response = self.client.get('/flatpage_root/no_such_flatpage/')
39  
-        self.assertEquals(response.status_code, 404)
  39
+        self.assertEqual(response.status_code, 404)
40 40
 
41 41
     def test_view_authenticated_flatpage(self):
42 42
         "A flatpage served through a view can require authentication"
@@ -45,19 +45,19 @@ def test_view_authenticated_flatpage(self):
45 45
         User.objects.create_user('testuser', 'test@example.com', 's3krit')
46 46
         self.client.login(username='testuser',password='s3krit')
47 47
         response = self.client.get('/flatpage_root/sekrit/')
48  
-        self.assertEquals(response.status_code, 200)
  48
+        self.assertEqual(response.status_code, 200)
49 49
         self.assertContains(response, "<p>Isn't it sekrit!</p>")
50 50
 
51 51
     def test_fallback_flatpage(self):
52 52
         "A flatpage can be served by the fallback middlware"
53 53
         response = self.client.get('/flatpage/')
54  
-        self.assertEquals(response.status_code, 200)
  54
+        self.assertEqual(response.status_code, 200)
55 55
         self.assertContains(response, "<p>Isn't it flat!</p>")
56 56
 
57 57
     def test_fallback_non_existent_flatpage(self):
58 58
         "A non-existent flatpage raises a 404 when served by the fallback middlware"
59 59
         response = self.client.get('/no_such_flatpage/')
60  
-        self.assertEquals(response.status_code, 404)
  60
+        self.assertEqual(response.status_code, 404)
61 61
 
62 62
     def test_fallback_authenticated_flatpage(self):
63 63
         "A flatpage served by the middleware can require authentication"
@@ -66,5 +66,5 @@ def test_fallback_authenticated_flatpage(self):
66 66
         User.objects.create_user('testuser', 'test@example.com', 's3krit')
67 67
         self.client.login(username='testuser',password='s3krit')
68 68
         response = self.client.get('/sekrit/')
69  
-        self.assertEquals(response.status_code, 200)
  69
+        self.assertEqual(response.status_code, 200)
70 70
         self.assertContains(response, "<p>Isn't it sekrit!</p>")
14  django/contrib/flatpages/tests/templatetags.py
@@ -35,7 +35,7 @@ def test_get_flatpages_tag(self):
35 35
                 "{{ page.title }},"
36 36
                 "{% endfor %}"
37 37
             ).render(Context())
38  
-        self.assertEquals(out, "A Flatpage,A Nested Flatpage,")
  38
+        self.assertEqual(out, "A Flatpage,A Nested Flatpage,")
39 39
 
40 40
     def test_get_flatpages_tag_for_anon_user(self):
41 41
         "The flatpage template tag retrives unregistered flatpages for an anonymous user"
@@ -48,7 +48,7 @@ def test_get_flatpages_tag_for_anon_user(self):
48 48
             ).render(Context({
49 49
                 'anonuser': AnonymousUser()
50 50
             }))
51  
-        self.assertEquals(out, "A Flatpage,A Nested Flatpage,")
  51
+        self.assertEqual(out, "A Flatpage,A Nested Flatpage,")
52 52
 
53 53
     def test_get_flatpages_tag_for_user(self):
54 54
         "The flatpage template tag retrives all flatpages for an authenticated user"
@@ -61,7 +61,7 @@ def test_get_flatpages_tag_for_user(self):
61 61
             ).render(Context({
62 62
                 'me': self.me
63 63
             }))
64  
-        self.assertEquals(out, "A Flatpage,A Nested Flatpage,Sekrit Nested Flatpage,Sekrit Flatpage,")
  64
+        self.assertEqual(out, "A Flatpage,A Nested Flatpage,Sekrit Nested Flatpage,Sekrit Flatpage,")
65 65
 
66 66
     def test_get_flatpages_with_prefix(self):
67 67
         "The flatpage template tag retrives unregistered prefixed flatpages by default"
@@ -72,7 +72,7 @@ def test_get_flatpages_with_prefix(self):
72 72
                 "{{ page.title }},"
73 73
                 "{% endfor %}"
74 74
             ).render(Context())
75  
-        self.assertEquals(out, "A Nested Flatpage,")
  75
+        self.assertEqual(out, "A Nested Flatpage,")
76 76
 
77 77
     def test_get_flatpages_with_prefix_for_anon_user(self):
78 78
         "The flatpage template tag retrives unregistered prefixed flatpages for an anonymous user"
@@ -85,7 +85,7 @@ def test_get_flatpages_with_prefix_for_anon_user(self):
85 85
             ).render(Context({
86 86
                 'anonuser': AnonymousUser()
87 87
             }))
88  
-        self.assertEquals(out, "A Nested Flatpage,")
  88
+        self.assertEqual(out, "A Nested Flatpage,")
89 89
 
90 90
     def test_get_flatpages_with_prefix_for_user(self):
91 91
         "The flatpage template tag retrive prefixed flatpages for an authenticated user"
@@ -98,7 +98,7 @@ def test_get_flatpages_with_prefix_for_user(self):
98 98
             ).render(Context({
99 99
                 'me': self.me
100 100
             }))
101  
-        self.assertEquals(out, "A Nested Flatpage,Sekrit Nested Flatpage,")
  101
+        self.assertEqual(out, "A Nested Flatpage,Sekrit Nested Flatpage,")
102 102
 
103 103
     def test_get_flatpages_with_variable_prefix(self):
104 104
         "The prefix for the flatpage template tag can be a template variable"
@@ -111,7 +111,7 @@ def test_get_flatpages_with_variable_prefix(self):
111 111
             ).render(Context({
112 112
                 'location_prefix': '/location/'
113 113
             }))
114  
-        self.assertEquals(out, "A Nested Flatpage,")
  114
+        self.assertEqual(out, "A Nested Flatpage,")
115 115
 
116 116
     def test_parsing_errors(self):
117 117
         "There are various ways that the flatpages template tag won't parse"
12  django/contrib/flatpages/tests/views.py
@@ -31,13 +31,13 @@ def tearDown(self):
31 31
     def test_view_flatpage(self):
32 32
         "A flatpage can be served through a view"
33 33
         response = self.client.get('/flatpage_root/flatpage/')
34  
-        self.assertEquals(response.status_code, 200)
  34
+        self.assertEqual(response.status_code, 200)
35 35
         self.assertContains(response, "<p>Isn't it flat!</p>")
36 36
 
37 37
     def test_view_non_existent_flatpage(self):
38 38
         "A non-existent flatpage raises 404 when served through a view"
39 39
         response = self.client.get('/flatpage_root/no_such_flatpage/')
40  
-        self.assertEquals(response.status_code, 404)
  40
+        self.assertEqual(response.status_code, 404)
41 41
 
42 42
     def test_view_authenticated_flatpage(self):
43 43
         "A flatpage served through a view can require authentication"
@@ -46,18 +46,18 @@ def test_view_authenticated_flatpage(self):
46 46
         User.objects.create_user('testuser', 'test@example.com', 's3krit')
47 47
         self.client.login(username='testuser',password='s3krit')
48 48
         response = self.client.get('/flatpage_root/sekrit/')
49  
-        self.assertEquals(response.status_code, 200)
  49
+        self.assertEqual(response.status_code, 200)
50 50
         self.assertContains(response, "<p>Isn't it sekrit!</p>")
51 51
 
52 52
     def test_fallback_flatpage(self):
53 53
         "A fallback flatpage won't be served if the middleware is disabled"
54 54
         response = self.client.get('/flatpage/')
55  
-        self.assertEquals(response.status_code, 404)
  55
+        self.assertEqual(response.status_code, 404)
56 56
 
57 57
     def test_fallback_non_existent_flatpage(self):
58 58
         "A non-existent flatpage won't be served if the fallback middlware is disabled"
59 59
         response = self.client.get('/no_such_flatpage/')
60  
-        self.assertEquals(response.status_code, 404)
  60
+        self.assertEqual(response.status_code, 404)
61 61
 
62 62
     def test_view_flatpage_special_chars(self):
63 63
         "A flatpage with special chars in the URL can be served through a view"
@@ -71,5 +71,5 @@ def test_view_flatpage_special_chars(self):
71 71
         fp.sites.add(1)
72 72
 
73 73
         response = self.client.get('/flatpage_root/some.very_special~chars-here/')
74  
-        self.assertEquals(response.status_code, 200)
  74
+        self.assertEqual(response.status_code, 200)
75 75
         self.assertContains(response, "<p>Isn't it special!</p>")
16  django/contrib/formtools/tests/__init__.py
@@ -65,8 +65,8 @@ def test_form_get(self):
65 65
         response = self.client.get('/test1/')
66 66
         stage = self.input % 1
67 67
         self.assertContains(response, stage, 1)
68  
-        self.assertEquals(response.context['custom_context'], True)
69  
-        self.assertEquals(response.context['form'].initial, {'field1': 'Works!'})
  68
+        self.assertEqual(response.context['custom_context'], True)
  69
+        self.assertEqual(response.context['form'].initial, {'field1': 'Works!'})
70 70
 
71 71
     def test_form_preview(self):
72 72
         """
@@ -291,14 +291,14 @@ def test_step_starts_at_zero(self):
291 291
         step should be zero for the first form
292 292
         """
293 293
         response = self.client.get('/wizard/')
294  
-        self.assertEquals(0, response.context['step0'])
  294
+        self.assertEqual(0, response.context['step0'])
295 295
 
296 296
     def test_step_increments(self):
297 297
         """
298 298
         step should be incremented when we go to the next page
299 299
         """
300 300
         response = self.client.post('/wizard/', {"0-field":"test", "wizard_step":"0"})
301  
-        self.assertEquals(1, response.context['step0'])
  301
+        self.assertEqual(1, response.context['step0'])
302 302
 
303 303
     def test_bad_hash(self):
304 304
         """
@@ -308,7 +308,7 @@ def test_bad_hash(self):
308 308
                                     {"0-field":"test",
309 309
                                      "1-field":"test2",
310 310
                                      "wizard_step": "1"})
311  
-        self.assertEquals(0, response.context['step0'])
  311
+        self.assertEqual(0, response.context['step0'])
312 312
 
313 313
     def test_good_hash_django12(self):
314 314
         """
@@ -322,7 +322,7 @@ def test_good_hash_django12(self):
322 322
                 "hash_0": "2fdbefd4c0cad51509478fbacddf8b13",
323 323
                 "wizard_step": "1"}
324 324
         response = self.client.post('/wizard/', data)
325  
-        self.assertEquals(2, response.context['step0'])
  325
+        self.assertEqual(2, response.context['step0'])
326 326
 
327 327
     def test_good_hash_django12_subclass(self):
328 328
         """
@@ -337,7 +337,7 @@ def test_good_hash_django12_subclass(self):
337 337
                 "hash_0": "2fdbefd4c0cad51509478fbacddf8b13",
338 338
                 "wizard_step": "1"}
339 339
         response = self.client.post('/wizard2/', data)
340  
-        self.assertEquals(0, response.context['step0'])
  340
+        self.assertEqual(0, response.context['step0'])
341 341
 
342 342
     def test_good_hash_current(self):
343 343
         """
@@ -349,7 +349,7 @@ def test_good_hash_current(self):
349 349
                 "hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
350 350
                 "wizard_step": "1"}
351 351
         response = self.client.post('/wizard/', data)
352  
-        self.assertEquals(2, response.context['step0'])
  352
+        self.assertEqual(2, response.context['step0'])
353 353
 
354 354
     def test_14498(self):
355 355
         """
4  django/contrib/gis/gdal/tests/test_geom.py
@@ -49,8 +49,8 @@ def test00a_geomtype(self):
49 49
     def test00b_geomtype_25d(self):
50 50
         "Testing OGRGeomType object with 25D types."
51 51
         wkb25bit = OGRGeomType.wkb25bit
52  
-        self.failUnless(OGRGeomType(wkb25bit + 1) == 'Point25D')
53  
-        self.failUnless(OGRGeomType('MultiLineString25D') == (5 + wkb25bit))
  52
+        self.assertTrue(OGRGeomType(wkb25bit + 1) == 'Point25D')
  53
+        self.assertTrue(OGRGeomType('MultiLineString25D') == (5 + wkb25bit))
54 54
         self.assertEqual('GeometryCollectionField', OGRGeomType('GeometryCollection25D').django)
55 55
 
56 56
     def test01a_wkt(self):
18  django/contrib/gis/geos/tests/test_geos.py
@@ -867,7 +867,7 @@ def test23_transform_noop(self):
867 867
             g1 = g.transform(4326, clone=True)
868 868
             self.assertEqual(g1.tuple, g.tuple)
869 869
             self.assertEqual(g1.srid, 4326)
870  
-            self.assert_(g1 is not g, "Clone didn't happen")
  870
+            self.assertTrue(g1 is not g, "Clone didn't happen")
871 871
 
872 872
         old_has_gdal = gdal.HAS_GDAL
873 873
         try:
@@ -883,7 +883,7 @@ def test23_transform_noop(self):
883 883
             g1 = g.transform(4326, clone=True)
884 884
             self.assertEqual(g1.tuple, g.tuple)
885 885
             self.assertEqual(g1.srid, 4326)
886  
-            self.assert_(g1 is not g, "Clone didn't happen")
  886
+            self.assertTrue(g1 is not g, "Clone didn't happen")
887 887
         finally:
888 888
             gdal.HAS_GDAL = old_has_gdal
889 889
 
@@ -907,7 +907,7 @@ def test23_transform_nosrid(self):
907 907
 
908 908
             g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
909 909
             g1 = g.transform(2774, clone=True)
910  
-            self.assert_(g1 is None)
  910
+            self.assertTrue(g1 is None)
911 911
 
912 912
             g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
913 913
             g.transform(2774)
@@ -916,7 +916,7 @@ def test23_transform_nosrid(self):
916 916
 
917 917
             g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
918 918
             g1 = g.transform(2774, clone=True)
919  
-            self.assert_(g1 is None)
  919
+            self.assertTrue(g1 is None)
920 920
 
921 921
         finally:
922 922
             warnings.simplefilter('default', UserWarning)
@@ -1032,17 +1032,17 @@ def test27_valid_reason(self):
1032 1032
         if not GEOS_PREPARE: return
1033 1033
 
1034 1034
         g = GEOSGeometry("POINT(0 0)")
1035  
-        self.assert_(g.valid)
1036  
-        self.assert_(isinstance(g.valid_reason, basestring))
  1035
+        self.assertTrue(g.valid)
  1036
+        self.assertTrue(isinstance(g.valid_reason, basestring))
1037 1037
         self.assertEqual(g.valid_reason, "Valid Geometry")
1038 1038
 
1039 1039
         print "\nBEGIN - expecting GEOS_NOTICE; safe to ignore.\n"
1040 1040
 
1041 1041
         g = GEOSGeometry("LINESTRING(0 0, 0 0)")
1042 1042
 
1043  
-        self.assert_(not g.valid)
1044  
-        self.assert_(isinstance(g.valid_reason, basestring))
1045  
-        self.assert_(g.valid_reason.startswith("Too few points in geometry component"))
  1043
+        self.assertTrue(not g.valid)
  1044
+        self.assertTrue(isinstance(g.valid_reason, basestring))
  1045
+        self.assertTrue(g.valid_reason.startswith("Too few points in geometry component"))
1046 1046
 
1047 1047
         print "\nEND - expecting GEOS_NOTICE; safe to ignore.\n"
1048 1048
 
34  django/contrib/gis/geos/tests/test_mutable_list.py
@@ -362,26 +362,26 @@ def test_12_arithmetic(self):
362 362
 
363 363
         pl, ul = self.lists_of_len()
364 364
         self.assertEqual(pl, ul, 'cmp for equal')
365  
-        self.assert_(pl >= ul, 'cmp for gte self')
366  
-        self.assert_(pl <= ul, 'cmp for lte self')
367  
-        self.assert_(ul >= pl, 'cmp for self gte')
368  
-        self.assert_(ul <= pl, 'cmp for self lte')
369  
-
370  
-        self.assert_(pl + [5] > ul, 'cmp')
371  
-        self.assert_(pl + [5] >= ul, 'cmp')
372  
-        self.assert_(pl < ul + [2], 'cmp')
373  
-        self.assert_(pl <= ul + [2], 'cmp')
374  
-        self.assert_(ul + [5] > pl, 'cmp')
375  
-        self.assert_(ul + [5] >= pl, 'cmp')
376  
-        self.assert_(ul < pl + [2], 'cmp')
377  
-        self.assert_(ul <= pl + [2], 'cmp')
  365
+        self.assertTrue(pl >= ul, 'cmp for gte self')
  366
+        self.assertTrue(pl <= ul, 'cmp for lte self')
  367
+        self.assertTrue(ul >= pl, 'cmp for self gte')
  368
+        self.assertTrue(ul <= pl, 'cmp for self lte')
  369
+
  370
+        self.assertTrue(pl + [5] > ul, 'cmp')
  371
+        self.assertTrue(pl + [5] >= ul, 'cmp')
  372
+        self.assertTrue(pl < ul + [2], 'cmp')
  373
+        self.assertTrue(pl <= ul + [2], 'cmp')
  374
+        self.assertTrue(ul + [5] > pl, 'cmp')
  375
+        self.assertTrue(ul + [5] >= pl, 'cmp')
  376
+        self.assertTrue(ul < pl + [2], 'cmp')
  377
+        self.assertTrue(ul <= pl + [2], 'cmp')
378 378
 
379 379
         pl[1] = 20
380  
-        self.assert_(pl > ul, 'cmp for gt self')
381  
-        self.assert_(ul < pl, 'cmp for self lt')
  380
+        self.assertTrue(pl > ul, 'cmp for gt self')
  381
+        self.assertTrue(ul < pl, 'cmp for self lt')
382 382
         pl[1] = -20
383  
-        self.assert_(pl < ul, 'cmp for lt self')
384  
-        self.assert_(pl < ul, 'cmp for lt self')
  383
+        self.assertTrue(pl < ul, 'cmp for lt self')
  384
+        self.assertTrue(pl < ul, 'cmp for lt self')
385 385
 
386 386
 class ListMixinTestSingle(ListMixinTest):
387 387
     listType = UserListB
12  django/contrib/gis/tests/geo3d/tests.py
@@ -72,7 +72,7 @@ def test01_3d(self):
72 72
             pnt = Point(x, y, z, srid=4326)
73 73
             City3D.objects.create(name=name, point=pnt)
74 74
             city = City3D.objects.get(name=name)
75  
-            self.failUnless(city.point.hasz)
  75
+            self.assertTrue(city.point.hasz)
76 76
             self.assertEqual(z, city.point.z)
77 77
 
78 78
         # Interstate (2D / 3D and Geographic/Projected variants)
@@ -93,7 +93,7 @@ def test01_3d(self):
93 93
             interstate = Interstate3D.objects.get(name=name)
94 94
             interstate_proj = InterstateProj3D.objects.get(name=name)
95 95
             for i in [interstate, interstate_proj]:
96  
-                self.failUnless(i.line.hasz)
  96
+                self.assertTrue(i.line.hasz)
97 97
                 self.assertEqual(exp_z, tuple(i.line.z))
98 98
 
99 99
         # Creating 3D Polygon.
@@ -101,7 +101,7 @@ def test01_3d(self):
101 101
         Polygon2D.objects.create(name='2D BBox', poly=bbox2d)
102 102
         Polygon3D.objects.create(name='3D BBox', poly=bbox3d)
103 103
         p3d = Polygon3D.objects.get(name='3D BBox')
104  
-        self.failUnless(p3d.poly.hasz)
  104
+        self.assertTrue(p3d.poly.hasz)
105 105
         self.assertEqual(bbox3d, p3d.poly)
106 106
 
107 107
     def test01a_3d_layermapping(self):
@@ -138,7 +138,7 @@ def test02a_kml(self):
138 138
         # KML should be 3D.
139 139
         # `SELECT ST_AsKML(point, 6) FROM geo3d_city3d WHERE name = 'Houston';`
140 140
         ref_kml_regex = re.compile(r'^<Point><coordinates>-95.363\d+,29.763\d+,18</coordinates></Point>$')
141  
-        self.failUnless(ref_kml_regex.match(h.kml))
  141
+        self.assertTrue(ref_kml_regex.match(h.kml))
142 142
 
143 143
     def test02b_geojson(self):
144 144
         "Test GeoQuerySet.geojson() with Z values."
@@ -146,7 +146,7 @@ def test02b_geojson(self):
146 146
         # GeoJSON should be 3D
147 147
         # `SELECT ST_AsGeoJSON(point, 6) FROM geo3d_city3d WHERE name='Houston';`
148 148
         ref_json_regex = re.compile(r'^{"type":"Point","coordinates":\[-95.363151,29.763374,18(\.0+)?\]}$')
149  
-        self.failUnless(ref_json_regex.match(h.geojson))
  149
+        self.assertTrue(ref_json_regex.match(h.geojson))
150 150
 
151 151
     def test03a_union(self):
152 152
         "Testing the Union aggregate of 3D models."
@@ -155,7 +155,7 @@ def test03a_union(self):
155 155
         ref_ewkt = 'SRID=4326;MULTIPOINT(-123.305196 48.462611 15,-104.609252 38.255001 1433,-97.521157 34.464642 380,-96.801611 32.782057 147,-95.363151 29.763374 18,-95.23506 38.971823 251,-87.650175 41.850385 181,174.783117 -41.315268 14)'
156 156
         ref_union = GEOSGeometry(ref_ewkt)
157 157
         union = City3D.objects.aggregate(Union('point'))['point__union']
158  
-        self.failUnless(union.hasz)
  158
+        self.assertTrue(union.hasz)
159 159
         self.assertEqual(ref_union, union)
160 160
 
161 161
     def test03b_extent(self):
10  django/contrib/gis/tests/geoapp/tests.py
@@ -133,11 +133,11 @@ def test03b_gml(self):
133 133
             # No precision parameter for Oracle :-/
134 134
             gml_regex = re.compile(r'^<gml:Point srsName="SDO:4326" xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="\." cs="," ts=" ">-104.60925\d+,38.25500\d+ </gml:coordinates></gml:Point>')
135 135
             for ptown in [ptown1, ptown2]:
136  
-                self.failUnless(gml_regex.match(ptown.gml))
  136
+                self.assertTrue(gml_regex.match(ptown.gml))
137 137
         else:
138 138
             gml_regex = re.compile(r'^<gml:Point srsName="EPSG:4326"><gml:coordinates>-104\.60925\d+,38\.255001</gml:coordinates></gml:Point>')
139 139
             for ptown in [ptown1, ptown2]:
140  
-                self.failUnless(gml_regex.match(ptown.gml))
  140
+                self.assertTrue(gml_regex.match(ptown.gml))
141 141
 
142 142
     def test03c_geojson(self):
143 143
         "Testing GeoJSON output from the database using GeoQuerySet.geojson()."
@@ -678,15 +678,15 @@ def test27_snap_to_grid(self):
678 678
 
679 679
         # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.1)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
680 680
         ref = fromstr('MULTIPOLYGON(((12.4 44,12.5 44,12.5 43.9,12.4 43.9,12.4 44)))')
681  
-        self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.1).get(name='San Marino').snap_to_grid, tol))
  681
+        self.assertTrue(ref.equals_exact(Country.objects.snap_to_grid(0.1).get(name='San Marino').snap_to_grid, tol))
682 682
 
683 683
         # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.05, 0.23)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
684 684
         ref = fromstr('MULTIPOLYGON(((12.4 43.93,12.45 43.93,12.5 43.93,12.45 43.93,12.4 43.93)))')
685  
-        self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23).get(name='San Marino').snap_to_grid, tol))
  685
+        self.assertTrue(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23).get(name='San Marino').snap_to_grid, tol))
686 686
 
687 687
         # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.5, 0.17, 0.05, 0.23)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
688 688
         ref = fromstr('MULTIPOLYGON(((12.4 43.87,12.45 43.87,12.45 44.1,12.5 44.1,12.5 43.87,12.45 43.87,12.4 43.87)))')
689  
-        self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23, 0.5, 0.17).get(name='San Marino').snap_to_grid, tol))
  689
+        self.assertTrue(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23, 0.5, 0.17).get(name='San Marino').snap_to_grid, tol))
690 690
 
691 691
     @no_mysql
692 692
     @no_spatialite
8  django/contrib/gis/tests/relatedapp/tests.py
@@ -173,8 +173,8 @@ def test07_values(self):
173 173
         for m, d, t in zip(gqs, gvqs, gvlqs):
174 174
             # The values should be Geometry objects and not raw strings returned
175 175
             # by the spatial database.
176  
-            self.failUnless(isinstance(d['point'], Geometry))
177  
-            self.failUnless(isinstance(t[1], Geometry))
  176
+            self.assertTrue(isinstance(d['point'], Geometry))
  177
+            self.assertTrue(isinstance(t[1], Geometry))
178 178
             self.assertEqual(m.point, d['point'])
179 179
             self.assertEqual(m.point, t[1])
180 180
 
@@ -207,8 +207,8 @@ def test10_combine(self):
207 207
         combined = qs1 | qs2
208 208
         names = [c.name for c in combined]
209 209
         self.assertEqual(2, len(names))
210  
-        self.failUnless('Aurora' in names)
211  
-        self.failUnless('Kecksburg' in names)
  210
+        self.assertTrue('Aurora' in names)
  211
+        self.assertTrue('Kecksburg' in names)
212 212
 
213 213
     def test11_geoquery_pickle(self):
214 214
         "Ensuring GeoQuery objects are unpickled correctly.  See #10839."
2  django/contrib/gis/tests/test_geoforms.py
@@ -26,7 +26,7 @@ def test01_srid(self):
26 26
         xform_geom = GEOSGeometry('POINT (951640.547328465 4219369.26171664)', srid=32140)
27 27
         # The cleaned geometry should be transformed to 32140.
28 28
         cleaned_geom = fld.clean('SRID=4326;POINT (-95.363151 29.763374)')
29  
-        self.failUnless(xform_geom.equals_exact(cleaned_geom, tol))
  29
+        self.assertTrue(xform_geom.equals_exact(cleaned_geom, tol))
30 30
 
31 31
     def test02_null(self):
32 32
         "Testing GeometryField's handling of null (None) geometries."
14  django/contrib/gis/tests/test_measure.py
@@ -107,7 +107,7 @@ def testMultiplication(self):
107 107
         self.assertEqual(d4.m, 10)
108 108
 
109 109
         a5 = d1 * D(m=10)
110  
-        self.assert_(isinstance(a5, Area))
  110
+        self.assertTrue(isinstance(a5, Area))
111 111
         self.assertEqual(a5.sq_m, 100*10)
112 112
 
113 113
         try:
@@ -151,9 +151,9 @@ def testComparisons(self):
151 151
         d2 = D(km=1)
152 152
         d3 = D(km=0)
153 153
 
154  
-        self.assert_(d2 > d1)
155  
-        self.assert_(d1 == d1)
156  
-        self.assert_(d1 < d2)
  154
+        self.assertTrue(d2 > d1)
  155
+        self.assertTrue(d1 == d1)
  156
+        self.assertTrue(d1 < d2)
157 157
         self.failIf(d3)
158 158
 
159 159
     def testUnitsStr(self):
@@ -309,9 +309,9 @@ def testComparisons(self):
309 309
         a2 = A(sq_km=1)
310 310
         a3 = A(sq_km=0)
311 311
 
312  
-        self.assert_(a2 > a1)
313  
-        self.assert_(a1 == a1)
314  
-        self.assert_(a1 < a2)
  312
+        self.assertTrue(a2 > a1)
  313
+        self.assertTrue(a1 == a1)
  314
+        self.assertTrue(a1 < a2)
315 315
         self.failIf(a3)
316 316
 
317 317
     def testUnitsStr(self):
8  django/contrib/messages/tests/base.py
@@ -349,7 +349,7 @@ def test_existing_read(self):
349 349
         self.assertFalse(storage.used)
350 350
         # After iterating the storage engine directly, the used flag is set.
351 351
         data = list(storage)
352  
-        self.assert_(storage.used)
  352
+        self.assertTrue(storage.used)
353 353
         # The data does not disappear because it has been iterated.
354 354
         self.assertEqual(data, list(storage))
355 355
 
@@ -357,7 +357,7 @@ def test_existing_add(self):
357 357
         storage = self.get_existing_storage()
358 358
         self.assertFalse(storage.added_new)
359 359
         storage.add(constants.INFO, 'Test message 3')
360  
-        self.assert_(storage.added_new)
  360
+        self.assertTrue(storage.added_new)
361 361
 
362 362
     def test_default_level(self):
363 363
         # get_level works even with no storage on the request.
@@ -378,7 +378,7 @@ def test_low_level(self):
378 378
         storage = self.storage_class(request)
379 379
         request._messages = storage
380 380
 
381  
-        self.assert_(set_level(request, 5))
  381
+        self.assertTrue(set_level(request, 5))
382 382
         self.assertEqual(get_level(request), 5)
383 383
 
384 384
         add_level_messages(storage)
@@ -389,7 +389,7 @@ def test_high_level(self):
389 389
         storage = self.storage_class(request)
390 390
         request._messages = storage
391 391
 
392  
-        self.assert_(set_level(request, 30))
  392
+        self.assertTrue(set_level(request, 30))
393 393
         self.assertEqual(get_level(request), 30)
394 394
 
395 395
         add_level_messages(storage)
2  django/contrib/messages/tests/cookie.py
@@ -83,7 +83,7 @@ def test_max_cookie_length(self):
12  django/contrib/sitemaps/tests/basic.py
@@ -40,7 +40,7 @@ def test_simple_sitemap_index(self):
40 40
         # Retrieve the sitemap.
41 41
         response = self.client.get('/simple/index.xml')
42 42
         # Check for all the important bits:
43  
-        self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
  43
+        self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
44 44
 <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
45 45
 <sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
46 46
 </sitemapindex>
@@ -51,7 +51,7 @@ def test_simple_sitemap_custom_index(self):
51 51
         # Retrieve the sitemap.
52 52
         response = self.client.get('/simple/custom-index.xml')
53 53
         # Check for all the important bits:
54  
-        self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
  54
+        self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
55 55
 <!-- This is a customised template -->
56 56
 <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
57 57
 <sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
@@ -63,7 +63,7 @@ def test_simple_sitemap(self):
63 63
         # Retrieve the sitemap.
64 64
         response = self.client.get('/simple/sitemap.xml')
65 65
         # Check for all the important bits:
66  
-        self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
  66
+        self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
67 67
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
68 68
 <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
69 69
 </urlset>
@@ -74,7 +74,7 @@ def test_simple_custom_sitemap(self):
74 74
         # Retrieve the sitemap.
75 75
         response = self.client.get('/simple/custom-sitemap.xml')
76 76
         # Check for all the important bits:
77