Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 freakboy3742 authored
Showing with 1,198 additions and 1,198 deletions.
  1. +3 −3 django/contrib/auth/tests/basic.py
  2. +1 −1  django/contrib/auth/tests/decorators.py
  3. +4 −4 django/contrib/auth/tests/remote_user.py
  4. +57 −57 django/contrib/auth/tests/views.py
  5. +8 −8 django/contrib/flatpages/tests/csrf.py
  6. +6 −6 django/contrib/flatpages/tests/middleware.py
  7. +7 −7 django/contrib/flatpages/tests/templatetags.py
  8. +6 −6 django/contrib/flatpages/tests/views.py
  9. +8 −8 django/contrib/formtools/tests/__init__.py
  10. +2 −2 django/contrib/gis/gdal/tests/test_geom.py
  11. +9 −9 django/contrib/gis/geos/tests/test_geos.py
  12. +17 −17 django/contrib/gis/geos/tests/test_mutable_list.py
  13. +6 −6 django/contrib/gis/tests/geo3d/tests.py
  14. +5 −5 django/contrib/gis/tests/geoapp/tests.py
  15. +4 −4 django/contrib/gis/tests/relatedapp/tests.py
  16. +1 −1  django/contrib/gis/tests/test_geoforms.py
  17. +7 −7 django/contrib/gis/tests/test_measure.py
  18. +4 −4 django/contrib/messages/tests/base.py
  19. +1 −1  django/contrib/messages/tests/cookie.py
  20. +6 −6 django/contrib/sitemaps/tests/basic.py
  21. +3 −3 django/contrib/sites/tests.py
  22. +4 −4 django/utils/unittest/case.py
  23. +1 −1  docs/topics/testing.txt
  24. +1 −1  tests/modeltests/aggregation/tests.py
  25. +1 −1  tests/modeltests/model_formsets/tests.py
  26. +2 −2 tests/modeltests/model_inheritance_same_model_name/tests.py
  27. +2 −2 tests/modeltests/proxy_model_inheritance/tests.py
  28. +5 −5 tests/modeltests/raw_query/tests.py
  29. +1 −1  tests/modeltests/serializers/tests.py
  30. +3 −3 tests/modeltests/test_client/models.py
  31. +2 −2 tests/modeltests/unmanaged_models/tests.py
  32. +2 −2 tests/modeltests/user_commands/tests.py
  33. +2 −2 tests/modeltests/validation/__init__.py
  34. +6 −6 tests/modeltests/validators/tests.py
  35. +30 −30 tests/regressiontests/admin_filterspecs/tests.py
  36. +2 −2 tests/regressiontests/admin_scripts/tests.py
  37. +17 −17 tests/regressiontests/admin_util/tests.py
  38. +31 −31 tests/regressiontests/admin_views/tests.py
  39. +3 −3 tests/regressiontests/admin_widgets/tests.py
  40. +9 −9 tests/regressiontests/aggregation_regress/tests.py
  41. +1 −1  tests/regressiontests/app_loading/tests.py
  42. +1 −1  tests/regressiontests/builtin_server/tests.py
  43. +42 −42 tests/regressiontests/cache/tests.py
  44. +3 −3 tests/regressiontests/comment_tests/tests/comment_form_tests.py
  45. +6 −6 tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
  46. +3 −3 tests/regressiontests/comment_tests/tests/comment_view_tests.py
  47. +2 −2 tests/regressiontests/comment_tests/tests/feed_tests.py
  48. +3 −3 tests/regressiontests/comment_tests/tests/moderation_view_tests.py
  49. +5 −5 tests/regressiontests/comment_tests/tests/templatetag_tests.py
  50. +10 −10 tests/regressiontests/conditional_processing/models.py
  51. +13 −13 tests/regressiontests/csrf_tests/tests.py
  52. +3 −3 tests/regressiontests/datatypes/tests.py
  53. +3 −3 tests/regressiontests/decorators/tests.py
  54. +7 −7 tests/regressiontests/delete_regress/tests.py
  55. +1 −1  tests/regressiontests/dispatch/tests/test_dispatcher.py
  56. +6 −6 tests/regressiontests/dispatch/tests/test_saferef.py
  57. +12 −12 tests/regressiontests/file_storage/tests.py
  58. +5 −5 tests/regressiontests/file_uploads/tests.py
  59. +1 −1  tests/regressiontests/forms/localflavor/fi.py
  60. +1 −1  tests/regressiontests/forms/localflavor/us.py
  61. +4 −4 tests/regressiontests/forms/tests/formsets.py
  62. +4 −4 tests/regressiontests/forms/tests/models.py
  63. +11 −11 tests/regressiontests/generic_inline_admin/tests.py
  64. +11 −11 tests/regressiontests/generic_views/base.py
  65. +2 −2 tests/regressiontests/httpwrappers/tests.py
  66. +17 −17 tests/regressiontests/i18n/commands/extraction.py
  67. +1 −1  tests/regressiontests/i18n/tests.py
  68. +4 −4 tests/regressiontests/introspection/tests.py
  69. +1 −1  tests/regressiontests/mail/tests.py
  70. +1 −1  tests/regressiontests/max_lengths/tests.py
  71. +37 −37 tests/regressiontests/middleware/tests.py
  72. +2 −2 tests/regressiontests/middleware_exceptions/tests.py
  73. +2 −2 tests/regressiontests/model_fields/tests.py
  74. +19 −19 tests/regressiontests/model_forms_regress/tests.py
  75. +3 −3 tests/regressiontests/model_inheritance_regress/tests.py
  76. +1 −1  tests/regressiontests/modeladmin/tests.py
  77. +268 −268 tests/regressiontests/multiple_database/tests.py
  78. +2 −2 tests/regressiontests/null_fk/tests.py
  79. +1 −1  tests/regressiontests/null_queries/tests.py
  80. +2 −2 tests/regressiontests/one_to_one_regress/tests.py
  81. +5 −5 tests/regressiontests/queries/tests.py
  82. +2 −2 tests/regressiontests/reverse_single_related/tests.py
  83. +23 −23 tests/regressiontests/select_related_regress/tests.py
  84. +1 −1  tests/regressiontests/serializers_regress/tests.py
  85. +5 −5 tests/regressiontests/signals_regress/tests.py
  86. +5 −5 tests/regressiontests/staticfiles_tests/tests.py
  87. +9 −9 tests/regressiontests/string_lookup/tests.py
  88. +4 −4 tests/regressiontests/syndication/tests.py
  89. +8 −8 tests/regressiontests/templates/custom.py
  90. +7 −7 tests/regressiontests/templates/response.py
  91. +2 −2 tests/regressiontests/templates/smartif.py
  92. +2 −2 tests/regressiontests/templates/tests.py
  93. +20 −20 tests/regressiontests/test_client_regress/models.py
  94. +22 −22 tests/regressiontests/text/tests.py
  95. +1 −1  tests/regressiontests/transactions_regress/tests.py
  96. +40 −40 tests/regressiontests/urlpatterns_reverse/tests.py
  97. +48 −48 tests/regressiontests/utils/datastructures.py
  98. +45 −45 tests/regressiontests/utils/dateformat.py
  99. +8 −8 tests/regressiontests/utils/datetime_safe.py
  100. +1 −1  tests/regressiontests/utils/simplelazyobject.py
  101. +42 −42 tests/regressiontests/utils/termcolors.py
  102. +31 −31 tests/regressiontests/utils/timesince.py
  103. +11 −11 tests/regressiontests/utils/tzinfo.py
  104. +2 −2 tests/regressiontests/views/tests/debug.py
  105. +7 −7 tests/regressiontests/views/tests/defaults.py
  106. +2 −2 tests/regressiontests/views/tests/generic/create_update.py
  107. +1 −1  tests/regressiontests/views/tests/i18n.py
  108. +22 −22 tests/regressiontests/views/tests/shortcuts.py
  109. +10 −10 tests/regressiontests/views/tests/static.py
  110. +2 −2 tests/runtests.py
6 django/contrib/auth/tests/basic.py
View
@@ -61,7 +61,7 @@ def test_createsuperuser_management_command(self):
command_output = new_io.getvalue().strip()
self.assertEqual(command_output, 'Superuser created successfully.')
u = User.objects.get(username="joe")
- self.assertEquals(u.email, 'joe@somewhere.org')
+ self.assertEqual(u.email, 'joe@somewhere.org')
# created password should be unusable
self.assertFalse(u.has_usable_password())
@@ -78,7 +78,7 @@ def test_createsuperuser_management_command(self):
command_output = new_io.getvalue().strip()
self.assertEqual(command_output, '')
u = User.objects.get(username="joe2")
- self.assertEquals(u.email, 'joe2@somewhere.org')
+ self.assertEqual(u.email, 'joe2@somewhere.org')
self.assertFalse(u.has_usable_password())
@@ -90,6 +90,6 @@ def test_createsuperuser_management_command(self):
stdout=new_io
)
u = User.objects.get(username="joe+admin@somewhere.org")
- self.assertEquals(u.email, 'joe@somewhere.org')
+ self.assertEqual(u.email, 'joe@somewhere.org')
self.assertFalse(u.has_usable_password())
2  django/contrib/auth/tests/decorators.py
View
@@ -32,7 +32,7 @@ def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGI
"""
response = self.client.get(view_url)
self.assertEqual(response.status_code, 302)
- self.assert_(login_url in response['Location'])
+ self.assertTrue(login_url in response['Location'])
self.login()
response = self.client.get(view_url)
self.assertEqual(response.status_code, 200)
8 django/contrib/auth/tests/remote_user.py
View
@@ -30,15 +30,15 @@ def test_no_remote_user(self):
num_users = User.objects.count()
response = self.client.get('/remote_user/')
- self.assert_(response.context['user'].is_anonymous())
+ self.assertTrue(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
response = self.client.get('/remote_user/', REMOTE_USER=None)
- self.assert_(response.context['user'].is_anonymous())
+ self.assertTrue(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
response = self.client.get('/remote_user/', REMOTE_USER='')
- self.assert_(response.context['user'].is_anonymous())
+ self.assertTrue(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
def test_unknown_user(self):
@@ -115,7 +115,7 @@ class that doesn't create unknown users.
def test_unknown_user(self):
num_users = User.objects.count()
response = self.client.get('/remote_user/', REMOTE_USER='newuser')
- self.assert_(response.context['user'].is_anonymous())
+ self.assertTrue(response.context['user'].is_anonymous())
self.assertEqual(User.objects.count(), num_users)
114 django/contrib/auth/tests/views.py
View
@@ -40,53 +40,53 @@ def login(self, password='password'):
'password': password
}
)
- self.assertEquals(response.status_code, 302)
- self.assert_(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))
- self.assert_(SESSION_KEY in self.client.session)
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue(response['Location'].endswith(settings.LOGIN_REDIRECT_URL))
+ self.assertTrue(SESSION_KEY in self.client.session)
class PasswordResetTest(AuthViewsTestCase):
def test_email_not_found(self):
"Error is raised if the provided email address isn't currently registered"
response = self.client.get('/password_reset/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'})
self.assertContains(response, "That e-mail address doesn't have an associated user account")
- self.assertEquals(len(mail.outbox), 0)
+ self.assertEqual(len(mail.outbox), 0)
def test_email_found(self):
"Email is sent if a valid email address is provided for password reset"
response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
- self.assertEquals(response.status_code, 302)
- self.assertEquals(len(mail.outbox), 1)
- self.assert_("http://" in mail.outbox[0].body)
- self.assertEquals(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertTrue("http://" in mail.outbox[0].body)
+ self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
def test_email_found_custom_from(self):
"Email is sent if a valid email address is provided for password reset when a custom from_email is provided."
response = self.client.post('/password_reset_from_email/', {'email': 'staffmember@example.com'})
- self.assertEquals(response.status_code, 302)
- self.assertEquals(len(mail.outbox), 1)
- self.assertEquals("staffmember@example.com", mail.outbox[0].from_email)
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual("staffmember@example.com", mail.outbox[0].from_email)
def _test_confirm_start(self):
# Start by creating the email
response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
- self.assertEquals(response.status_code, 302)
- self.assertEquals(len(mail.outbox), 1)
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(len(mail.outbox), 1)
return self._read_signup_email(mail.outbox[0])
def _read_signup_email(self, email):
urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body)
- self.assert_(urlmatch is not None, "No URL found in sent email")
+ self.assertTrue(urlmatch is not None, "No URL found in sent email")
return urlmatch.group(), urlmatch.groups()[0]
def test_confirm_valid(self):
url, path = self._test_confirm_start()
response = self.client.get(path)
# redirect to a 'complete' page:
- self.assertEquals(response.status_code, 200)
- self.assert_("Please enter your new password" in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("Please enter your new password" in response.content)
def test_confirm_invalid(self):
url, path = self._test_confirm_start()
@@ -95,20 +95,20 @@ def test_confirm_invalid(self):
path = path[:-5] + ("0"*4) + path[-1]
response = self.client.get(path)
- self.assertEquals(response.status_code, 200)
- self.assert_("The password reset link was invalid" in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("The password reset link was invalid" in response.content)
def test_confirm_invalid_user(self):
# Ensure that we get a 200 response for a non-existant user, not a 404
response = self.client.get('/reset/123456-1-1/')
- self.assertEquals(response.status_code, 200)
- self.assert_("The password reset link was invalid" in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("The password reset link was invalid" in response.content)
def test_confirm_overflow_user(self):
# Ensure that we get a 200 response for a base36 user id that overflows int
response = self.client.get('/reset/zzzzzzzzzzzzz-1-1/')
- self.assertEquals(response.status_code, 200)
- self.assert_("The password reset link was invalid" in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("The password reset link was invalid" in response.content)
def test_confirm_invalid_post(self):
# Same as test_confirm_invalid, but trying
@@ -120,29 +120,29 @@ def test_confirm_invalid_post(self):
'new_password2':' anewpassword'})
# Check the password has not been changed
u = User.objects.get(email='staffmember@example.com')
- self.assert_(not u.check_password("anewpassword"))
+ self.assertTrue(not u.check_password("anewpassword"))
def test_confirm_complete(self):
url, path = self._test_confirm_start()
response = self.client.post(path, {'new_password1': 'anewpassword',
'new_password2': 'anewpassword'})
# It redirects us to a 'complete' page:
- self.assertEquals(response.status_code, 302)
+ self.assertEqual(response.status_code, 302)
# Check the password has been changed
u = User.objects.get(email='staffmember@example.com')
- self.assert_(u.check_password("anewpassword"))
+ self.assertTrue(u.check_password("anewpassword"))
# Check we can't use the link again
response = self.client.get(path)
- self.assertEquals(response.status_code, 200)
- self.assert_("The password reset link was invalid" in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("The password reset link was invalid" in response.content)
def test_confirm_different_passwords(self):
url, path = self._test_confirm_start()
response = self.client.post(path, {'new_password1': 'anewpassword',
'new_password2':' x'})
- self.assertEquals(response.status_code, 200)
- self.assert_("The two password fields didn't match" in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("The two password fields didn't match" in response.content)
class ChangePasswordTest(AuthViewsTestCase):
@@ -152,8 +152,8 @@ def fail_login(self, password='password'):
'password': password
}
)
- self.assertEquals(response.status_code, 200)
- self.assert_("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content)
def logout(self):
response = self.client.get('/logout/')
@@ -166,8 +166,8 @@ def test_password_change_fails_with_invalid_old_password(self):
'new_password2': 'password1',
}
)
- self.assertEquals(response.status_code, 200)
- self.assert_("Your old password was entered incorrectly. Please enter it again." in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("Your old password was entered incorrectly. Please enter it again." in response.content)
def test_password_change_fails_with_mismatched_passwords(self):
self.login()
@@ -177,8 +177,8 @@ def test_password_change_fails_with_mismatched_passwords(self):
'new_password2': 'donuts',
}
)
- self.assertEquals(response.status_code, 200)
- self.assert_("The two password fields didn't match." in response.content)
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue("The two password fields didn't match." in response.content)
def test_password_change_succeeds(self):
self.login()
@@ -188,8 +188,8 @@ def test_password_change_succeeds(self):
'new_password2': 'password1',
}
)
- self.assertEquals(response.status_code, 302)
- self.assert_(response['Location'].endswith('/password_change/done/'))
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue(response['Location'].endswith('/password_change/done/'))
self.fail_login()
self.login(password='password1')
@@ -197,14 +197,14 @@ class LoginTest(AuthViewsTestCase):
def test_current_site_in_context_after_login(self):
response = self.client.get(reverse('django.contrib.auth.views.login'))
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
if Site._meta.installed:
site = Site.objects.get_current()
- self.assertEquals(response.context['site'], site)
- self.assertEquals(response.context['site_name'], site.name)
+ self.assertEqual(response.context['site'], site)
+ self.assertEqual(response.context['site_name'], site.name)
else:
self.assertIsInstance(response.context['site'], RequestSite)
- self.assert_(isinstance(response.context['form'], AuthenticationForm),
+ self.assertTrue(isinstance(response.context['form'], AuthenticationForm),
'Login form is not an AuthenticationForm')
def test_security_check(self, password='password'):
@@ -226,7 +226,7 @@ def test_security_check(self, password='password'):
'password': password,
}
)
- self.assertEquals(response.status_code, 302)
+ self.assertEqual(response.status_code, 302)
self.assertFalse(bad_url in response['Location'],
"%s should be blocked" % bad_url)
@@ -249,14 +249,14 @@ def test_security_check(self, password='password'):
'password': password,
}
)
- self.assertEquals(response.status_code, 302)
+ self.assertEqual(response.status_code, 302)
self.assertTrue(good_url in response['Location'],
"%s should be allowed" % good_url)
class LoginURLSettings(AuthViewsTestCase):
urls = 'django.contrib.auth.tests.urls'
-
+
def setUp(self):
super(LoginURLSettings, self).setUp()
self.old_LOGIN_URL = settings.LOGIN_URL
@@ -268,7 +268,7 @@ def tearDown(self):
def get_login_required_url(self, login_url):
settings.LOGIN_URL = login_url
response = self.client.get('/login_required/')
- self.assertEquals(response.status_code, 302)
+ self.assertEqual(response.status_code, 302)
return response['Location']
def test_standard_login_url(self):
@@ -317,14 +317,14 @@ class LogoutTest(AuthViewsTestCase):
urls = 'django.contrib.auth.tests.urls'
def confirm_logged_out(self):
- self.assert_(SESSION_KEY not in self.client.session)
+ self.assertTrue(SESSION_KEY not in self.client.session)
def test_logout_default(self):
"Logout without next_page option renders the default template"
self.login()
response = self.client.get('/logout/')
- self.assertEquals(200, response.status_code)
- self.assert_('Logged out' in response.content)
+ self.assertEqual(200, response.status_code)
+ self.assertTrue('Logged out' in response.content)
self.confirm_logged_out()
def test_14377(self):
@@ -338,20 +338,20 @@ def test_logout_with_overridden_redirect_url(self):
self.login()
response = self.client.get('/logout/next_page/')
self.assertEqual(response.status_code, 302)
- self.assert_(response['Location'].endswith('/somewhere/'))
+ self.assertTrue(response['Location'].endswith('/somewhere/'))
response = self.client.get('/logout/next_page/?next=/login/')
self.assertEqual(response.status_code, 302)
- self.assert_(response['Location'].endswith('/login/'))
+ self.assertTrue(response['Location'].endswith('/login/'))
self.confirm_logged_out()
- def test_logout_with_next_page_specified(self):
+ def test_logout_with_next_page_specified(self):
"Logout with next_page option given redirects to specified resource"
self.login()
response = self.client.get('/logout/next_page/')
self.assertEqual(response.status_code, 302)
- self.assert_(response['Location'].endswith('/somewhere/'))
+ self.assertTrue(response['Location'].endswith('/somewhere/'))
self.confirm_logged_out()
def test_logout_with_redirect_argument(self):
@@ -359,7 +359,7 @@ def test_logout_with_redirect_argument(self):
self.login()
response = self.client.get('/logout/?next=/login/')
self.assertEqual(response.status_code, 302)
- self.assert_(response['Location'].endswith('/login/'))
+ self.assertTrue(response['Location'].endswith('/login/'))
self.confirm_logged_out()
def test_logout_with_custom_redirect_argument(self):
@@ -367,7 +367,7 @@ def test_logout_with_custom_redirect_argument(self):
self.login()
response = self.client.get('/logout/custom_query/?follow=/somewhere/')
self.assertEqual(response.status_code, 302)
- self.assert_(response['Location'].endswith('/somewhere/'))
+ self.assertTrue(response['Location'].endswith('/somewhere/'))
self.confirm_logged_out()
def test_security_check(self, password='password'):
@@ -386,7 +386,7 @@ def test_security_check(self, password='password'):
}
self.login()
response = self.client.get(nasty_url)
- self.assertEquals(response.status_code, 302)
+ self.assertEqual(response.status_code, 302)
self.assertFalse(bad_url in response['Location'],
"%s should be blocked" % bad_url)
self.confirm_logged_out()
@@ -407,7 +407,7 @@ def test_security_check(self, password='password'):
}
self.login()
response = self.client.get(safe_url)
- self.assertEquals(response.status_code, 302)
+ self.assertEqual(response.status_code, 302)
self.assertTrue(good_url in response['Location'],
"%s should be allowed" % good_url)
self.confirm_logged_out()
16 django/contrib/flatpages/tests/csrf.py
View
@@ -34,13 +34,13 @@ def tearDown(self):
def test_view_flatpage(self):
"A flatpage can be served through a view, even when the middleware is in use"
response = self.client.get('/flatpage_root/flatpage/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it flat!</p>")
def test_view_non_existent_flatpage(self):
"A non-existent flatpage raises 404 when served through a view, even when the middleware is in use"
response = self.client.get('/flatpage_root/no_such_flatpage/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
def test_view_authenticated_flatpage(self):
"A flatpage served through a view can require authentication"
@@ -49,31 +49,31 @@ def test_view_authenticated_flatpage(self):
User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit')
response = self.client.get('/flatpage_root/sekrit/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
def test_fallback_flatpage(self):
"A flatpage can be served by the fallback middlware"
response = self.client.get('/flatpage/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it flat!</p>")
def test_fallback_non_existent_flatpage(self):
"A non-existent flatpage raises a 404 when served by the fallback middlware"
response = self.client.get('/no_such_flatpage/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
def test_post_view_flatpage(self):
"POSTing to a flatpage served through a view will raise a CSRF error if no token is provided (Refs #14156)"
response = self.client.post('/flatpage_root/flatpage/')
- self.assertEquals(response.status_code, 403)
+ self.assertEqual(response.status_code, 403)
def test_post_fallback_flatpage(self):
"POSTing to a flatpage served by the middleware will raise a CSRF error if no token is provided (Refs #14156)"
response = self.client.post('/flatpage/')
- self.assertEquals(response.status_code, 403)
+ self.assertEqual(response.status_code, 403)
def test_post_unknown_page(self):
"POSTing to an unknown page isn't caught as a 403 CSRF error"
response = self.client.post('/no_such_page/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
12 django/contrib/flatpages/tests/middleware.py
View
@@ -30,13 +30,13 @@ def tearDown(self):
def test_view_flatpage(self):
"A flatpage can be served through a view, even when the middleware is in use"
response = self.client.get('/flatpage_root/flatpage/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it flat!</p>")
def test_view_non_existent_flatpage(self):
"A non-existent flatpage raises 404 when served through a view, even when the middleware is in use"
response = self.client.get('/flatpage_root/no_such_flatpage/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
def test_view_authenticated_flatpage(self):
"A flatpage served through a view can require authentication"
@@ -45,19 +45,19 @@ def test_view_authenticated_flatpage(self):
User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit')
response = self.client.get('/flatpage_root/sekrit/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
def test_fallback_flatpage(self):
"A flatpage can be served by the fallback middlware"
response = self.client.get('/flatpage/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it flat!</p>")
def test_fallback_non_existent_flatpage(self):
"A non-existent flatpage raises a 404 when served by the fallback middlware"
response = self.client.get('/no_such_flatpage/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
def test_fallback_authenticated_flatpage(self):
"A flatpage served by the middleware can require authentication"
@@ -66,5 +66,5 @@ def test_fallback_authenticated_flatpage(self):
User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit')
response = self.client.get('/sekrit/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
14 django/contrib/flatpages/tests/templatetags.py
View
@@ -35,7 +35,7 @@ def test_get_flatpages_tag(self):
"{{ page.title }},"
"{% endfor %}"
).render(Context())
- self.assertEquals(out, "A Flatpage,A Nested Flatpage,")
+ self.assertEqual(out, "A Flatpage,A Nested Flatpage,")
def test_get_flatpages_tag_for_anon_user(self):
"The flatpage template tag retrives unregistered flatpages for an anonymous user"
@@ -48,7 +48,7 @@ def test_get_flatpages_tag_for_anon_user(self):
).render(Context({
'anonuser': AnonymousUser()
}))
- self.assertEquals(out, "A Flatpage,A Nested Flatpage,")
+ self.assertEqual(out, "A Flatpage,A Nested Flatpage,")
def test_get_flatpages_tag_for_user(self):
"The flatpage template tag retrives all flatpages for an authenticated user"
@@ -61,7 +61,7 @@ def test_get_flatpages_tag_for_user(self):
).render(Context({
'me': self.me
}))
- self.assertEquals(out, "A Flatpage,A Nested Flatpage,Sekrit Nested Flatpage,Sekrit Flatpage,")
+ self.assertEqual(out, "A Flatpage,A Nested Flatpage,Sekrit Nested Flatpage,Sekrit Flatpage,")
def test_get_flatpages_with_prefix(self):
"The flatpage template tag retrives unregistered prefixed flatpages by default"
@@ -72,7 +72,7 @@ def test_get_flatpages_with_prefix(self):
"{{ page.title }},"
"{% endfor %}"
).render(Context())
- self.assertEquals(out, "A Nested Flatpage,")
+ self.assertEqual(out, "A Nested Flatpage,")
def test_get_flatpages_with_prefix_for_anon_user(self):
"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):
).render(Context({
'anonuser': AnonymousUser()
}))
- self.assertEquals(out, "A Nested Flatpage,")
+ self.assertEqual(out, "A Nested Flatpage,")
def test_get_flatpages_with_prefix_for_user(self):
"The flatpage template tag retrive prefixed flatpages for an authenticated user"
@@ -98,7 +98,7 @@ def test_get_flatpages_with_prefix_for_user(self):
).render(Context({
'me': self.me
}))
- self.assertEquals(out, "A Nested Flatpage,Sekrit Nested Flatpage,")
+ self.assertEqual(out, "A Nested Flatpage,Sekrit Nested Flatpage,")
def test_get_flatpages_with_variable_prefix(self):
"The prefix for the flatpage template tag can be a template variable"
@@ -111,7 +111,7 @@ def test_get_flatpages_with_variable_prefix(self):
).render(Context({
'location_prefix': '/location/'
}))
- self.assertEquals(out, "A Nested Flatpage,")
+ self.assertEqual(out, "A Nested Flatpage,")
def test_parsing_errors(self):
"There are various ways that the flatpages template tag won't parse"
12 django/contrib/flatpages/tests/views.py
View
@@ -31,13 +31,13 @@ def tearDown(self):
def test_view_flatpage(self):
"A flatpage can be served through a view"
response = self.client.get('/flatpage_root/flatpage/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it flat!</p>")
def test_view_non_existent_flatpage(self):
"A non-existent flatpage raises 404 when served through a view"
response = self.client.get('/flatpage_root/no_such_flatpage/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
def test_view_authenticated_flatpage(self):
"A flatpage served through a view can require authentication"
@@ -46,18 +46,18 @@ def test_view_authenticated_flatpage(self):
User.objects.create_user('testuser', 'test@example.com', 's3krit')
self.client.login(username='testuser',password='s3krit')
response = self.client.get('/flatpage_root/sekrit/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it sekrit!</p>")
def test_fallback_flatpage(self):
"A fallback flatpage won't be served if the middleware is disabled"
response = self.client.get('/flatpage/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
def test_fallback_non_existent_flatpage(self):
"A non-existent flatpage won't be served if the fallback middlware is disabled"
response = self.client.get('/no_such_flatpage/')
- self.assertEquals(response.status_code, 404)
+ self.assertEqual(response.status_code, 404)
def test_view_flatpage_special_chars(self):
"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):
fp.sites.add(1)
response = self.client.get('/flatpage_root/some.very_special~chars-here/')
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>Isn't it special!</p>")
16 django/contrib/formtools/tests/__init__.py
View
@@ -65,8 +65,8 @@ def test_form_get(self):
response = self.client.get('/test1/')
stage = self.input % 1
self.assertContains(response, stage, 1)
- self.assertEquals(response.context['custom_context'], True)
- self.assertEquals(response.context['form'].initial, {'field1': 'Works!'})
+ self.assertEqual(response.context['custom_context'], True)
+ self.assertEqual(response.context['form'].initial, {'field1': 'Works!'})
def test_form_preview(self):
"""
@@ -291,14 +291,14 @@ def test_step_starts_at_zero(self):
step should be zero for the first form
"""
response = self.client.get('/wizard/')
- self.assertEquals(0, response.context['step0'])
+ self.assertEqual(0, response.context['step0'])
def test_step_increments(self):
"""
step should be incremented when we go to the next page
"""
response = self.client.post('/wizard/', {"0-field":"test", "wizard_step":"0"})
- self.assertEquals(1, response.context['step0'])
+ self.assertEqual(1, response.context['step0'])
def test_bad_hash(self):
"""
@@ -308,7 +308,7 @@ def test_bad_hash(self):
{"0-field":"test",
"1-field":"test2",
"wizard_step": "1"})
- self.assertEquals(0, response.context['step0'])
+ self.assertEqual(0, response.context['step0'])
def test_good_hash_django12(self):
"""
@@ -322,7 +322,7 @@ def test_good_hash_django12(self):
"hash_0": "2fdbefd4c0cad51509478fbacddf8b13",
"wizard_step": "1"}
response = self.client.post('/wizard/', data)
- self.assertEquals(2, response.context['step0'])
+ self.assertEqual(2, response.context['step0'])
def test_good_hash_django12_subclass(self):
"""
@@ -337,7 +337,7 @@ def test_good_hash_django12_subclass(self):
"hash_0": "2fdbefd4c0cad51509478fbacddf8b13",
"wizard_step": "1"}
response = self.client.post('/wizard2/', data)
- self.assertEquals(0, response.context['step0'])
+ self.assertEqual(0, response.context['step0'])
def test_good_hash_current(self):
"""
@@ -349,7 +349,7 @@ def test_good_hash_current(self):
"hash_0": "7e9cea465f6a10a6fb47fcea65cb9a76350c9a5c",
"wizard_step": "1"}
response = self.client.post('/wizard/', data)
- self.assertEquals(2, response.context['step0'])
+ self.assertEqual(2, response.context['step0'])
def test_14498(self):
"""
4 django/contrib/gis/gdal/tests/test_geom.py
View
@@ -49,8 +49,8 @@ def test00a_geomtype(self):
def test00b_geomtype_25d(self):
"Testing OGRGeomType object with 25D types."
wkb25bit = OGRGeomType.wkb25bit
- self.failUnless(OGRGeomType(wkb25bit + 1) == 'Point25D')
- self.failUnless(OGRGeomType('MultiLineString25D') == (5 + wkb25bit))
+ self.assertTrue(OGRGeomType(wkb25bit + 1) == 'Point25D')
+ self.assertTrue(OGRGeomType('MultiLineString25D') == (5 + wkb25bit))
self.assertEqual('GeometryCollectionField', OGRGeomType('GeometryCollection25D').django)
def test01a_wkt(self):
18 django/contrib/gis/geos/tests/test_geos.py
View
@@ -867,7 +867,7 @@ def test23_transform_noop(self):
g1 = g.transform(4326, clone=True)
self.assertEqual(g1.tuple, g.tuple)
self.assertEqual(g1.srid, 4326)
- self.assert_(g1 is not g, "Clone didn't happen")
+ self.assertTrue(g1 is not g, "Clone didn't happen")
old_has_gdal = gdal.HAS_GDAL
try:
@@ -883,7 +883,7 @@ def test23_transform_noop(self):
g1 = g.transform(4326, clone=True)
self.assertEqual(g1.tuple, g.tuple)
self.assertEqual(g1.srid, 4326)
- self.assert_(g1 is not g, "Clone didn't happen")
+ self.assertTrue(g1 is not g, "Clone didn't happen")
finally:
gdal.HAS_GDAL = old_has_gdal
@@ -907,7 +907,7 @@ def test23_transform_nosrid(self):
g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
g1 = g.transform(2774, clone=True)
- self.assert_(g1 is None)
+ self.assertTrue(g1 is None)
g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
g.transform(2774)
@@ -916,7 +916,7 @@ def test23_transform_nosrid(self):
g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
g1 = g.transform(2774, clone=True)
- self.assert_(g1 is None)
+ self.assertTrue(g1 is None)
finally:
warnings.simplefilter('default', UserWarning)
@@ -1032,17 +1032,17 @@ def test27_valid_reason(self):
if not GEOS_PREPARE: return
g = GEOSGeometry("POINT(0 0)")
- self.assert_(g.valid)
- self.assert_(isinstance(g.valid_reason, basestring))
+ self.assertTrue(g.valid)
+ self.assertTrue(isinstance(g.valid_reason, basestring))
self.assertEqual(g.valid_reason, "Valid Geometry")
print "\nBEGIN - expecting GEOS_NOTICE; safe to ignore.\n"
g = GEOSGeometry("LINESTRING(0 0, 0 0)")
- self.assert_(not g.valid)
- self.assert_(isinstance(g.valid_reason, basestring))
- self.assert_(g.valid_reason.startswith("Too few points in geometry component"))
+ self.assertTrue(not g.valid)
+ self.assertTrue(isinstance(g.valid_reason, basestring))
+ self.assertTrue(g.valid_reason.startswith("Too few points in geometry component"))
print "\nEND - expecting GEOS_NOTICE; safe to ignore.\n"
34 django/contrib/gis/geos/tests/test_mutable_list.py
View
@@ -362,26 +362,26 @@ def test_12_arithmetic(self):
pl, ul = self.lists_of_len()
self.assertEqual(pl, ul, 'cmp for equal')
- self.assert_(pl >= ul, 'cmp for gte self')
- self.assert_(pl <= ul, 'cmp for lte self')
- self.assert_(ul >= pl, 'cmp for self gte')
- self.assert_(ul <= pl, 'cmp for self lte')
-
- self.assert_(pl + [5] > ul, 'cmp')
- self.assert_(pl + [5] >= ul, 'cmp')
- self.assert_(pl < ul + [2], 'cmp')
- self.assert_(pl <= ul + [2], 'cmp')
- self.assert_(ul + [5] > pl, 'cmp')
- self.assert_(ul + [5] >= pl, 'cmp')
- self.assert_(ul < pl + [2], 'cmp')
- self.assert_(ul <= pl + [2], 'cmp')
+ self.assertTrue(pl >= ul, 'cmp for gte self')
+ self.assertTrue(pl <= ul, 'cmp for lte self')
+ self.assertTrue(ul >= pl, 'cmp for self gte')
+ self.assertTrue(ul <= pl, 'cmp for self lte')
+
+ self.assertTrue(pl + [5] > ul, 'cmp')
+ self.assertTrue(pl + [5] >= ul, 'cmp')
+ self.assertTrue(pl < ul + [2], 'cmp')
+ self.assertTrue(pl <= ul + [2], 'cmp')
+ self.assertTrue(ul + [5] > pl, 'cmp')
+ self.assertTrue(ul + [5] >= pl, 'cmp')
+ self.assertTrue(ul < pl + [2], 'cmp')
+ self.assertTrue(ul <= pl + [2], 'cmp')
pl[1] = 20
- self.assert_(pl > ul, 'cmp for gt self')
- self.assert_(ul < pl, 'cmp for self lt')
+ self.assertTrue(pl > ul, 'cmp for gt self')
+ self.assertTrue(ul < pl, 'cmp for self lt')
pl[1] = -20
- self.assert_(pl < ul, 'cmp for lt self')
- self.assert_(pl < ul, 'cmp for lt self')
+ self.assertTrue(pl < ul, 'cmp for lt self')
+ self.assertTrue(pl < ul, 'cmp for lt self')
class ListMixinTestSingle(ListMixinTest):
listType = UserListB
12 django/contrib/gis/tests/geo3d/tests.py
View
@@ -72,7 +72,7 @@ def test01_3d(self):
pnt = Point(x, y, z, srid=4326)
City3D.objects.create(name=name, point=pnt)
city = City3D.objects.get(name=name)
- self.failUnless(city.point.hasz)
+ self.assertTrue(city.point.hasz)
self.assertEqual(z, city.point.z)
# Interstate (2D / 3D and Geographic/Projected variants)
@@ -93,7 +93,7 @@ def test01_3d(self):
interstate = Interstate3D.objects.get(name=name)
interstate_proj = InterstateProj3D.objects.get(name=name)
for i in [interstate, interstate_proj]:
- self.failUnless(i.line.hasz)
+ self.assertTrue(i.line.hasz)
self.assertEqual(exp_z, tuple(i.line.z))
# Creating 3D Polygon.
@@ -101,7 +101,7 @@ def test01_3d(self):
Polygon2D.objects.create(name='2D BBox', poly=bbox2d)
Polygon3D.objects.create(name='3D BBox', poly=bbox3d)
p3d = Polygon3D.objects.get(name='3D BBox')
- self.failUnless(p3d.poly.hasz)
+ self.assertTrue(p3d.poly.hasz)
self.assertEqual(bbox3d, p3d.poly)
def test01a_3d_layermapping(self):
@@ -138,7 +138,7 @@ def test02a_kml(self):
# KML should be 3D.
# `SELECT ST_AsKML(point, 6) FROM geo3d_city3d WHERE name = 'Houston';`
ref_kml_regex = re.compile(r'^<Point><coordinates>-95.363\d+,29.763\d+,18</coordinates></Point>$')
- self.failUnless(ref_kml_regex.match(h.kml))
+ self.assertTrue(ref_kml_regex.match(h.kml))
def test02b_geojson(self):
"Test GeoQuerySet.geojson() with Z values."
@@ -146,7 +146,7 @@ def test02b_geojson(self):
# GeoJSON should be 3D
# `SELECT ST_AsGeoJSON(point, 6) FROM geo3d_city3d WHERE name='Houston';`
ref_json_regex = re.compile(r'^{"type":"Point","coordinates":\[-95.363151,29.763374,18(\.0+)?\]}$')
- self.failUnless(ref_json_regex.match(h.geojson))
+ self.assertTrue(ref_json_regex.match(h.geojson))
def test03a_union(self):
"Testing the Union aggregate of 3D models."
@@ -155,7 +155,7 @@ def test03a_union(self):
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)'
ref_union = GEOSGeometry(ref_ewkt)
union = City3D.objects.aggregate(Union('point'))['point__union']
- self.failUnless(union.hasz)
+ self.assertTrue(union.hasz)
self.assertEqual(ref_union, union)
def test03b_extent(self):
10 django/contrib/gis/tests/geoapp/tests.py
View
@@ -133,11 +133,11 @@ def test03b_gml(self):
# No precision parameter for Oracle :-/
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>')
for ptown in [ptown1, ptown2]:
- self.failUnless(gml_regex.match(ptown.gml))
+ self.assertTrue(gml_regex.match(ptown.gml))
else:
gml_regex = re.compile(r'^<gml:Point srsName="EPSG:4326"><gml:coordinates>-104\.60925\d+,38\.255001</gml:coordinates></gml:Point>')
for ptown in [ptown1, ptown2]:
- self.failUnless(gml_regex.match(ptown.gml))
+ self.assertTrue(gml_regex.match(ptown.gml))
def test03c_geojson(self):
"Testing GeoJSON output from the database using GeoQuerySet.geojson()."
@@ -678,15 +678,15 @@ def test27_snap_to_grid(self):
# SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.1)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr('MULTIPOLYGON(((12.4 44,12.5 44,12.5 43.9,12.4 43.9,12.4 44)))')
- self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.1).get(name='San Marino').snap_to_grid, tol))
+ self.assertTrue(ref.equals_exact(Country.objects.snap_to_grid(0.1).get(name='San Marino').snap_to_grid, tol))
# SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.05, 0.23)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr('MULTIPOLYGON(((12.4 43.93,12.45 43.93,12.5 43.93,12.45 43.93,12.4 43.93)))')
- self.failUnless(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23).get(name='San Marino').snap_to_grid, tol))
+ self.assertTrue(ref.equals_exact(Country.objects.snap_to_grid(0.05, 0.23).get(name='San Marino').snap_to_grid, tol))
# SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.5, 0.17, 0.05, 0.23)) FROM "geoapp_country" WHERE "geoapp_country"."name" = 'San Marino';
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)))')
- 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))
+ 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))
@no_mysql
@no_spatialite
8 django/contrib/gis/tests/relatedapp/tests.py
View
@@ -173,8 +173,8 @@ def test07_values(self):
for m, d, t in zip(gqs, gvqs, gvlqs):
# The values should be Geometry objects and not raw strings returned
# by the spatial database.
- self.failUnless(isinstance(d['point'], Geometry))
- self.failUnless(isinstance(t[1], Geometry))
+ self.assertTrue(isinstance(d['point'], Geometry))
+ self.assertTrue(isinstance(t[1], Geometry))
self.assertEqual(m.point, d['point'])
self.assertEqual(m.point, t[1])
@@ -207,8 +207,8 @@ def test10_combine(self):
combined = qs1 | qs2
names = [c.name for c in combined]
self.assertEqual(2, len(names))
- self.failUnless('Aurora' in names)
- self.failUnless('Kecksburg' in names)
+ self.assertTrue('Aurora' in names)
+ self.assertTrue('Kecksburg' in names)
def test11_geoquery_pickle(self):
"Ensuring GeoQuery objects are unpickled correctly. See #10839."
2  django/contrib/gis/tests/test_geoforms.py
View
@@ -26,7 +26,7 @@ def test01_srid(self):
xform_geom = GEOSGeometry('POINT (951640.547328465 4219369.26171664)', srid=32140)
# The cleaned geometry should be transformed to 32140.
cleaned_geom = fld.clean('SRID=4326;POINT (-95.363151 29.763374)')
- self.failUnless(xform_geom.equals_exact(cleaned_geom, tol))
+ self.assertTrue(xform_geom.equals_exact(cleaned_geom, tol))
def test02_null(self):
"Testing GeometryField's handling of null (None) geometries."
14 django/contrib/gis/tests/test_measure.py
View
@@ -107,7 +107,7 @@ def testMultiplication(self):
self.assertEqual(d4.m, 10)
a5 = d1 * D(m=10)
- self.assert_(isinstance(a5, Area))
+ self.assertTrue(isinstance(a5, Area))
self.assertEqual(a5.sq_m, 100*10)
try:
@@ -151,9 +151,9 @@ def testComparisons(self):
d2 = D(km=1)
d3 = D(km=0)
- self.assert_(d2 > d1)
- self.assert_(d1 == d1)
- self.assert_(d1 < d2)
+ self.assertTrue(d2 > d1)
+ self.assertTrue(d1 == d1)
+ self.assertTrue(d1 < d2)
self.failIf(d3)
def testUnitsStr(self):
@@ -309,9 +309,9 @@ def testComparisons(self):
a2 = A(sq_km=1)
a3 = A(sq_km=0)
- self.assert_(a2 > a1)
- self.assert_(a1 == a1)
- self.assert_(a1 < a2)
+ self.assertTrue(a2 > a1)
+ self.assertTrue(a1 == a1)
+ self.assertTrue(a1 < a2)
self.failIf(a3)
def testUnitsStr(self):
8 django/contrib/messages/tests/base.py
View
@@ -349,7 +349,7 @@ def test_existing_read(self):
self.assertFalse(storage.used)
# After iterating the storage engine directly, the used flag is set.
data = list(storage)
- self.assert_(storage.used)
+ self.assertTrue(storage.used)
# The data does not disappear because it has been iterated.
self.assertEqual(data, list(storage))
@@ -357,7 +357,7 @@ def test_existing_add(self):
storage = self.get_existing_storage()
self.assertFalse(storage.added_new)
storage.add(constants.INFO, 'Test message 3')
- self.assert_(storage.added_new)
+ self.assertTrue(storage.added_new)
def test_default_level(self):
# get_level works even with no storage on the request.
@@ -378,7 +378,7 @@ def test_low_level(self):
storage = self.storage_class(request)
request._messages = storage
- self.assert_(set_level(request, 5))
+ self.assertTrue(set_level(request, 5))
self.assertEqual(get_level(request), 5)
add_level_messages(storage)
@@ -389,7 +389,7 @@ def test_high_level(self):
storage = self.storage_class(request)
request._messages = storage
- self.assert_(set_level(request, 30))
+ self.assertTrue(set_level(request, 30))
self.assertEqual(get_level(request), 30)
add_level_messages(storage)
2  django/contrib/messages/tests/cookie.py
View
@@ -83,7 +83,7 @@ def test_max_cookie_length(self):
self.assertEqual(cookie_storing, 4)
self.assertEqual(len(unstored_messages), 1)
- self.assert_(unstored_messages[0].message == '0' * msg_size)
+ self.assertTrue(unstored_messages[0].message == '0' * msg_size)
def test_json_encoder_decoder(self):
"""
12 django/contrib/sitemaps/tests/basic.py
View
@@ -40,7 +40,7 @@ def test_simple_sitemap_index(self):
# Retrieve the sitemap.
response = self.client.get('/simple/index.xml')
# Check for all the important bits:
- self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
+ self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
@@ -51,7 +51,7 @@ def test_simple_sitemap_custom_index(self):
# Retrieve the sitemap.
response = self.client.get('/simple/custom-index.xml')
# Check for all the important bits:
- self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
+ self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
@@ -63,7 +63,7 @@ def test_simple_sitemap(self):
# Retrieve the sitemap.
response = self.client.get('/simple/sitemap.xml')
# Check for all the important bits:
- self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
+ self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
@@ -74,7 +74,7 @@ def test_simple_custom_sitemap(self):
# Retrieve the sitemap.
response = self.client.get('/simple/custom-sitemap.xml')
# Check for all the important bits:
- self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
+ self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
@@ -105,7 +105,7 @@ def test_generic_sitemap(self):
for username in User.objects.values_list("username", flat=True):
expected += "<url><loc>%s/users/%s/</loc></url>" % (self.base_url, username)
# Check for all the important bits:
- self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
+ self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
%s
</urlset>
@@ -148,7 +148,7 @@ def test_requestsite_sitemap(self):
# Retrieve the sitemap.
response = self.client.get('/simple/sitemap.xml')
# Check for all the important bits:
- self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
+ self.assertEqual(response.content, """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
6 django/contrib/sites/tests.py
View
@@ -18,7 +18,7 @@ def tearDown(self):
def test_site_manager(self):
# Make sure that get_current() does not return a deleted Site object.
s = Site.objects.get_current()
- self.assert_(isinstance(s, Site))
+ self.assertTrue(isinstance(s, Site))
s.delete()
self.assertRaises(ObjectDoesNotExist, Site.objects.get_current)
@@ -41,7 +41,7 @@ def test_get_current_site(self):
"SERVER_PORT": "80",
}
site = get_current_site(request)
- self.assert_(isinstance(site, Site))
+ self.assertTrue(isinstance(site, Site))
self.assertEqual(site.id, settings.SITE_ID)
# Test that an exception is raised if the sites framework is installed
@@ -52,5 +52,5 @@ def test_get_current_site(self):
# A RequestSite is returned if the sites framework is not installed
Site._meta.installed = False
site = get_current_site(request)
- self.assert_(isinstance(site, RequestSite))
+ self.assertTrue(isinstance(site, RequestSite))
self.assertEqual(site.name, u"example.com")
8 django/utils/unittest/case.py
View
@@ -831,8 +831,8 @@ def assertIsNot(self, expr1, expr2, msg=None):
self.fail(self._formatMessage(msg, standardMsg))
def assertDictEqual(self, d1, d2, msg=None):
- self.assert_(isinstance(d1, dict), 'First argument is not a dictionary')
- self.assert_(isinstance(d2, dict), 'Second argument is not a dictionary')
+ self.assertTrue(isinstance(d1, dict), 'First argument is not a dictionary')
+ self.assertTrue(isinstance(d2, dict), 'Second argument is not a dictionary')
if d1 != d2:
standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
@@ -909,9 +909,9 @@ def assertItemsEqual(self, expected_seq, actual_seq, msg=None):
def assertMultiLineEqual(self, first, second, msg=None):
"""Assert that two multi-line strings are equal."""
- self.assert_(isinstance(first, basestring), (
+ self.assertTrue(isinstance(first, basestring), (
'First argument is not a string'))
- self.assert_(isinstance(second, basestring), (
+ self.assertTrue(isinstance(second, basestring), (
'Second argument is not a string'))
if first != second:
2  docs/topics/testing.txt
View
@@ -1079,7 +1079,7 @@ The following is a simple unit test using the request factory::
# Test my_view() as if it were deployed at /customer/details
response = my_view(request)
- self.assertEquals(response.status_code, 200)
+ self.assertEqual(response.status_code, 200)
TestCase
--------
2  tests/modeltests/aggregation/tests.py
View
@@ -41,7 +41,7 @@ def test_related_aggregate(self):
vals = Book.objects.aggregate(Sum("publisher__num_awards"))
self.assertEqual(len(vals), 1)
- self.assertEquals(vals["publisher__num_awards__sum"], 30)
+ self.assertEqual(vals["publisher__num_awards__sum"], 30)
vals = Publisher.objects.aggregate(Sum("book__price"))
self.assertEqual(len(vals), 1)
2  tests/modeltests/model_formsets/tests.py
View
@@ -946,7 +946,7 @@ def test_callable_defaults(self):
# default. This is required to ensure the value is tested for change correctly
# when determine what extra forms have changed to save.
- self.assertEquals(len(formset.forms), 1) # this formset only has one form
+ self.assertEqual(len(formset.forms), 1) # this formset only has one form
form = formset.forms[0]
now = form.fields['date_joined'].initial()
result = form.as_p()
4 tests/modeltests/model_inheritance_same_model_name/tests.py
View
@@ -11,7 +11,7 @@ def setUp(self):
def test_inheritance_related_name(self):
from modeltests.model_inheritance.models import Copy
- self.assertEquals(
+ self.assertEqual(
self.title.attached_model_inheritance_copy_set.create(
content='Save $ on V1agr@',
url='http://v1agra.com/',
@@ -20,7 +20,7 @@ def test_inheritance_related_name(self):
def test_inheritance_with_same_model_name(self):
from modeltests.model_inheritance_same_model_name.models import Copy
- self.assertEquals(
+ self.assertEqual(
self.title.attached_model_inheritance_same_model_name_copy_set.create(
content='The Web framework for perfectionists with deadlines.',
url='http://www.djangoproject.com/',
4 tests/modeltests/proxy_model_inheritance/tests.py
View
@@ -32,5 +32,5 @@ def tearDown(self):
sys.path = self.old_sys_path
def test_table_exists(self):
- self.assertEquals(NiceModel.objects.all().count(), 0)
- self.assertEquals(ProxyModel.objects.all().count(), 0)
+ self.assertEqual(NiceModel.objects.all().count(), 0)
+ self.assertEqual(ProxyModel.objects.all().count(), 0)
10 tests/modeltests/raw_query/tests.py
View
@@ -30,10 +30,10 @@ def assertProcessed(self, model, results, orig, expected_annotations=()):
for field in model._meta.fields:
# Check that all values on the model are equal
- self.assertEquals(getattr(item,field.attname),
+ self.assertEqual(getattr(item,field.attname),
getattr(orig_item,field.attname))
# This includes checking that they are the same type
- self.assertEquals(type(getattr(item,field.attname)),
+ self.assertEqual(type(getattr(item,field.attname)),
type(getattr(orig_item,field.attname)))
def assertNoAnnotations(self, results):
@@ -67,9 +67,9 @@ def testRawQueryLazy(self):
iterated over.
"""
q = Author.objects.raw('SELECT * FROM raw_query_author')
- self.assert_(q.query.cursor is None)
+ self.assertTrue(q.query.cursor is None)
list(q)
- self.assert_(q.query.cursor is not None)
+ self.assertTrue(q.query.cursor is not None)
def testFkeyRawQuery(self):
"""
@@ -204,7 +204,7 @@ def testGetItem(self):
self.assertEqual(third_author.first_name, 'Bob')
first_two = Author.objects.raw(query)[0:2]
- self.assertEquals(len(first_two), 2)
+ self.assertEqual(len(first_two), 2)
self.assertRaises(TypeError, lambda: Author.objects.raw(query)['test'])
2  tests/modeltests/serializers/tests.py
View
@@ -225,7 +225,7 @@ def test_pre_1000ad_date(self):
serial_str = serializers.serialize(self.serializer_name, [a])
date_values = self._get_field_values(serial_str, "pub_date")
- self.assertEquals(date_values[0], "0001-02-03 04:05:06")
+ self.assertEqual(date_values[0], "0001-02-03 04:05:06")
def test_pkless_serialized_strings(self):
"""
6 tests/modeltests/test_client/models.py
View
@@ -79,7 +79,7 @@ def test_response_headers(self):
"Check the value of HTTP headers returned in a response"
response = self.client.get("/test_client/header_view/")
- self.assertEquals(response['X-DJANGO-TEST'], 'Slartibartfast')
+ self.assertEqual(response['X-DJANGO-TEST'], 'Slartibartfast')
def test_raw_post(self):
"POST raw data (with a content type) to a view"
@@ -140,7 +140,7 @@ def test_follow_redirect(self):
"A URL that redirects can be followed to termination."
response = self.client.get('/test_client/double_redirect_view/', follow=True)
self.assertRedirects(response, 'http://testserver/test_client/get_view/', status_code=302, target_status_code=200)
- self.assertEquals(len(response.redirect_chain), 2)
+ self.assertEqual(len(response.redirect_chain), 2)
def test_redirect_http(self):
"GET a URL that redirects to an http URI"
@@ -400,7 +400,7 @@ def test_session_modifying_view(self):
response = self.client.post('/test_client/session_view/')
# Check that the session was modified
- self.assertEquals(self.client.session['tobacconist'], 'hovercraft')
+ self.assertEqual(self.client.session['tobacconist'], 'hovercraft')
def test_view_with_exception(self):
"Request a page that is known to throw an error"
4 tests/modeltests/unmanaged_models/tests.py
View
@@ -47,7 +47,7 @@ def test_many_to_many_between_unmanaged(self):
"""
table = Unmanaged2._meta.get_field('mm').m2m_db_table()
tables = connection.introspection.table_names()
- self.assert_(table not in tables, "Table '%s' should not exist, but it does." % table)
+ self.assertTrue(table not in tables, "Table '%s' should not exist, but it does." % table)
def test_many_to_many_between_unmanaged_and_managed(self):
"""
@@ -55,4 +55,4 @@ def test_many_to_many_between_unmanaged_and_managed(self):
"""
table = Managed1._meta.get_field('mm').m2m_db_table()
tables = connection.introspection.table_names()
- self.assert_(table in tables, "Table '%s' does not exist." % table)
+ self.assertTrue(table in tables, "Table '%s' does not exist." % table)
4 tests/modeltests/user_commands/tests.py
View
@@ -8,13 +8,13 @@ class CommandTests(TestCase):
def test_command(self):
out = StringIO()
management.call_command('dance', stdout=out)
- self.assertEquals(out.getvalue(),
+ self.assertEqual(out.getvalue(),
"I don't feel like dancing Rock'n'Roll.")
def test_command_style(self):
out = StringIO()
management.call_command('dance', style='Jive', stdout=out)
- self.assertEquals(out.getvalue(),
+ self.assertEqual(out.getvalue(),
"I don't feel like dancing Jive.")
def test_explode(self):
4 tests/modeltests/validation/__init__.py
View
@@ -8,7 +8,7 @@ def assertFailsValidation(self, clean, failed_fields):
try:
clean()
except ValidationError, e:
- self.assertEquals(sorted(failed_fields), sorted(e.message_dict.keys()))
+ self.assertEqual(sorted(failed_fields), sorted(e.message_dict.keys()))
def assertFieldFailsValidationWithMessage(self, clean, field_name, message):
self.assertRaises(ValidationError, clean)
@@ -16,6 +16,6 @@ def assertFieldFailsValidationWithMessage(self, clean, field_name, message):
clean()
except ValidationError, e:
self.assertTrue(field_name in e.message_dict)
- self.assertEquals(message, e.message_dict[field_name])
+ self.assertEqual(message, e.message_dict[field_name])
12 tests/modeltests/validators/tests.py
View
@@ -141,18 +141,18 @@ def test_func(self):
class TestSimpleValidators(TestCase):
def test_single_message(self):
v = ValidationError('Not Valid')
- self.assertEquals(str(v), "[u'Not Valid']")
- self.assertEquals(repr(v), "ValidationError([u'Not Valid'])")
+ self.assertEqual(str(v), "[u'Not Valid']")
+ self.assertEqual(repr(v), "ValidationError([u'Not Valid'])")
def test_message_list(self):
v = ValidationError(['First Problem', 'Second Problem'])
- self.assertEquals(str(v), "[u'First Problem', u'Second Problem']")
- self.assertEquals(repr(v), "ValidationError([u'First Problem', u'Second Problem'])")
+ self.assertEqual(str(v), "[u'First Problem', u'Second Problem']")
+ self.assertEqual(repr(v), "ValidationError([u'First Problem', u'Second Problem'])")
def test_message_dict(self):
v = ValidationError({'first': 'First Problem'})
- self.assertEquals(str(v), "{'first': 'First Problem'}")
- self.assertEquals(repr(v), "ValidationError({'first': 'First Problem'})")
+ self.assertEqual(str(v), "{'first': 'First Problem'}")
+ self.assertEqual(repr(v), "ValidationError({'first': 'First Problem'})")
test_counter = 0
for validator, value, expected in TEST_DATA:
60 tests/regressiontests/admin_filterspecs/tests.py
View
@@ -42,20 +42,20 @@ def test_AllValuesFilterSpec(self):
# Make sure the last choice is None and is selected
filterspec = changelist.get_filters(request)[0][0]
- self.assertEquals(force_unicode(filterspec.title()), u'year')
+ self.assertEqual(force_unicode(filterspec.title()), u'year')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[-1]['selected'], True)
- self.assertEquals(choices[-1]['query_string'], '?year__isnull=True')
+ self.assertEqual(choices[-1]['selected'], True)
+ self.assertEqual(choices[-1]['query_string'], '?year__isnull=True')
request = self.request_factory.get('/', {'year': '2002'})
changelist = self.get_changelist(request, Book, modeladmin)
# Make sure the correct choice is selected
filterspec = changelist.get_filters(request)[0][0]
- self.assertEquals(force_unicode(filterspec.title()), u'year')
+ self.assertEqual(force_unicode(filterspec.title()), u'year')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[2]['selected'], True)
- self.assertEquals(choices[2]['query_string'], '?year=2002')
+ self.assertEqual(choices[2]['selected'], True)
+ self.assertEqual(choices[2]['query_string'], '?year=2002')
def test_RelatedFilterSpec_ForeignKey(self):
modeladmin = BookAdmin(Book, admin.site)
@@ -70,20 +70,20 @@ def test_RelatedFilterSpec_ForeignKey(self):
# Make sure the last choice is None and is selected
filterspec = changelist.get_filters(request)[0][1]
- self.assertEquals(force_unicode(filterspec.title()), u'author')
+ self.assertEqual(force_unicode(filterspec.title()), u'author')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[-1]['selected'], True)
- self.assertEquals(choices[-1]['query_string'], '?author__isnull=True')
+ self.assertEqual(choices[-1]['selected'], True)
+ self.assertEqual(choices[-1]['query_string'], '?author__isnull=True')
request = self.request_factory.get('/', {'author__id__exact': '1'})
changelist = self.get_changelist(request, Book, modeladmin)
# Make sure the correct choice is selected
filterspec = changelist.get_filters(request)[0][1]
- self.assertEquals(force_unicode(filterspec.title()), u'author')
+ self.assertEqual(force_unicode(filterspec.title()), u'author')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[1]['selected'], True)
- self.assertEquals(choices[1]['query_string'], '?author__id__exact=1')
+ self.assertEqual(choices[1]['selected'], True)
+ self.assertEqual(choices[1]['query_string'], '?author__id__exact=1')
def test_RelatedFilterSpec_ManyToMany(self):
modeladmin = BookAdmin(Book, admin.site)
@@ -96,20 +96,20 @@ def test_RelatedFilterSpec_ManyToMany(self):
# Make sure the last choice is None and is selected
filterspec = changelist.get_filters(request)[0][2]
- self.assertEquals(force_unicode(filterspec.title()), u'user')
+ self.assertEqual(force_unicode(filterspec.title()), u'user')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[-1]['selected'], True)
- self.assertEquals(choices[-1]['query_string'], '?contributors__isnull=True')
+ self.assertEqual(choices[-1]['selected'], True)
+ self.assertEqual(choices[-1]['query_string'], '?contributors__isnull=True')
request = self.request_factory.get('/', {'contributors__id__exact': '2'})
changelist = self.get_changelist(request, Book, modeladmin)
# Make sure the correct choice is selected
filterspec = changelist.get_filters(request)[0][2]
- self.assertEquals(force_unicode(filterspec.title()), u'user')
+ self.assertEqual(force_unicode(filterspec.title()), u'user')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[2]['selected'], True)
- self.assertEquals(choices[2]['query_string'], '?contributors__id__exact=2')
+ self.assertEqual(choices[2]['selected'], True)
+ self.assertEqual(choices[2]['query_string'], '?contributors__id__exact=2')
def test_RelatedFilterSpec_reverse_relationships(self):
@@ -124,20 +124,20 @@ def test_RelatedFilterSpec_reverse_relationships(self):
# Make sure the last choice is None and is selected
filterspec = changelist.get_filters(request)[0][0]
- self.assertEquals(force_unicode(filterspec.title()), u'book')
+ self.assertEqual(force_unicode(filterspec.title()), u'book')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[-1]['selected'], True)
- self.assertEquals(choices[-1]['query_string'], '?books_authored__isnull=True')
+ self.assertEqual(choices[-1]['selected'], True)
+ self.assertEqual(choices[-1]['query_string'], '?books_authored__isnull=True')
request = self.request_factory.get('/', {'books_authored__id__exact': '1'})
changelist = self.get_changelist(request, User, modeladmin)
# Make sure the correct choice is selected
filterspec = changelist.get_filters(request)[0][0]
- self.assertEquals(force_unicode(filterspec.title()), u'book')
+ self.assertEqual(force_unicode(filterspec.title()), u'book')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[1]['selected'], True)
- self.assertEquals(choices[1]['query_string'], '?books_authored__id__exact=1')
+ self.assertEqual(choices[1]['selected'], True)
+ self.assertEqual(choices[1]['query_string'], '?books_authored__id__exact=1')
# M2M relationship -----
request = self.request_factory.get('/', {'books_contributed__isnull': 'True'})
@@ -148,20 +148,20 @@ def test_RelatedFilterSpec_reverse_relationships(self):
# Make sure the last choice is None and is selected
filterspec = changelist.get_filters(request)[0][1]
- self.assertEquals(force_unicode(filterspec.title()), u'book')
+ self.assertEqual(force_unicode(filterspec.title()), u'book')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[-1]['selected'], True)
- self.assertEquals(choices[-1]['query_string'], '?books_contributed__isnull=True')
+ self.assertEqual(choices[-1]['selected'], True)
+ self.assertEqual(choices[-1]['query_string'], '?books_contributed__isnull=True')
request = self.request_factory.get('/', {'books_contributed__id__exact': '2'})
changelist = self.get_changelist(request, User, modeladmin)
# Make sure the correct choice is selected
filterspec = changelist.get_filters(request)[0][1]
- self.assertEquals(force_unicode(filterspec.title()), u'book')
+ self.assertEqual(force_unicode(filterspec.title()), u'book')
choices = list(filterspec.choices(changelist))
- self.assertEquals(choices[2]['selected'], True)
- self.assertEquals(choices[2]['query_string'], '?books_contributed__id__exact=2')
+ self.assertEqual(choices[2]['selected'], True)
+ self.assertEqual(choices[2]['query_string'], '?books_contributed__id__exact=2')
class CustomUserAdmin(UserAdmin):
list_filter = ('books_authored', 'books_contributed')
4 tests/regressiontests/admin_scripts/tests.py
View
@@ -155,7 +155,7 @@ def run_manage(self, args, settings_file=None):
def assertNoOutput(self, stream):
"Utility assertion: assert that the given stream is empty"
- self.assertEquals(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)
+ self.assertEqual(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)
def assertOutput(self, stream, msg):
"Utility assertion: assert that the given message exists in the output"
self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))
@@ -545,7 +545,7 @@ def test_setup_environ(self):
args = ['startapp','settings_test']
out, err = self.run_django_admin(args,'settings')
self.assertNoOutput(err)
- self.assert_(os.path.exists(os.path.join(test_dir, 'settings_test')))
+ self.assertTrue(os.path.exists(os.path.join(test_dir, 'settings_test')))
shutil.rmtree(os.path.join(test_dir, 'settings_test'))
def test_builtin_command(self):
34 tests/regressiontests/admin_util/tests.py
View
@@ -24,7 +24,7 @@ def setUp(self):
self.objs = [Count.objects.create(num=i) for i in range(5)]
def _check(self, target):
- self.assertEquals(self.n.nested(lambda obj: obj.num), target)
+ self.assertEqual(self.n.nested(lambda obj: obj.num), target)
def _connect(self, i, j):
self.objs[i].parent = self.objs[j]
@@ -146,24 +146,24 @@ def test_label_for_field(self):
"""
Tests for label_for_field
"""
- self.assertEquals(
+ self.assertEqual(
label_for_field("title", Article),
"title"
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("title2", Article),
"another name"
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("title2", Article, return_attr=True),
("another name", None)
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("__unicode__", Article),
"article"
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("__str__", Article),
"article"
)
@@ -175,29 +175,29 @@ def test_label_for_field(self):
def test_callable(obj):
return "nothing"
- self.assertEquals(
+ self.assertEqual(
label_for_field(test_callable, Article),
"Test callable"
)
- self.assertEquals(
+ self.assertEqual(
label_for_field(test_callable, Article, return_attr=True),
("Test callable", test_callable)
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("test_from_model", Article),
"Test from model"
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("test_from_model", Article, return_attr=True),
("Test from model", Article.test_from_model)
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("test_from_model_with_override", Article),
"not What you Expect"
)
- self.assertEquals(
+ self.assertEqual(
label_for_field(lambda x: "nothing", Article),
"--"
)
@@ -207,11 +207,11 @@ def test_from_model(self, obj):
return "nothing"
test_from_model.short_description = "not Really the Model"
- self.assertEquals(
+ self.assertEqual(
label_for_field("test_from_model", Article, model_admin=MockModelAdmin),
"not Really the Model"
)
- self.assertEquals(
+ self.assertEqual(
label_for_field("test_from_model", Article,
model_admin = MockModelAdmin,
return_attr = True
@@ -223,15 +223,15 @@ def test_related_name(self):
"""
Regression test for #13963
"""
- self.assertEquals(
+ self.assertEqual(
label_for_field('location', Event, return_attr=True),
('location', None),
)
- self.assertEquals(
+ self.assertEqual(
label_for_field('event', Location, return_attr=True),
('awesome event', None),
)
- self.assertEquals(
+ self.assertEqual(
label_for_field('guest', Event, return_attr=True),
('awesome guest', None),
)
62 tests/regressiontests/admin_views/tests.py
View
@@ -478,7 +478,7 @@ def test_save_as_display(self):
initial model.
"""
response = self.client.get('/test_admin/admin/admin_views/person/1/')
- self.assert_(response.context['save_as'])
+ self.assertTrue(response.context['save_as'])
post_data = {'_saveasnew':'', 'name':'John M', 'gender':3, 'alive':'checked'}
response = self.client.post('/test_admin/admin/admin_views/person/1/', post_data)
self.assertEqual(response.context['form_url'], '../add/')
@@ -503,32 +503,32 @@ def testCustomAdminSiteLoginTemplate(self):
self.client.logout()
request = self.client.get('/test_admin/admin2/')
self.assertTemplateUsed(request, 'custom_admin/login.html')
- self.assert_('Hello from a custom login template' in request.content)
+ self.assertTrue('Hello from a custom login template' in request.content)
def testCustomAdminSiteLogoutTemplate(self):
request = self.client.get('/test_admin/admin2/logout/')
self.assertTemplateUsed(request, 'custom_admin/logout.html')
- self.assert_('Hello from a custom logout template' in request.content)
+ self.assertTrue('Hello from a custom logout template' in request.content)
def testCustomAdminSiteIndexViewAndTemplate(self):
request = self.client.get('/test_admin/admin2/')
self.assertTemplateUsed(request, 'custom_admin/index.html')
- self.assert_('Hello from a custom index template *bar*' in request.content)
+ self.assertTrue('Hello from a custom index template *bar*' in request.content)
def testCustomAdminSitePasswordChangeTemplate(self):
request = self.client.get('/test_admin/admin2/password_change/')
self.assertTemplateUsed(request, 'custom_admin/password_change_form.html')
- self.assert_('Hello from a custom password change form template' in request.content)
+ self.assertTrue('Hello from a custom password change form template' in request.content)
def testCustomAdminSitePasswordChangeDoneTemplate(self):
request = self.client.get('/test_admin/admin2/password_change/done/')
self.assertTemplateUsed(request, 'custom_admin/password_change_done.html')
- self.assert_('Hello from a custom password change done template' in request.content)
+ self.assertTrue('Hello from a custom password change done template' in request.content)
def testCustomAdminSiteView(self):
self.client.login(username='super', password='secret')
response = self.client.get('/test_admin/%s/my_view/' % self.urlbit)
- self.assert_(response.content == "Django is a magical pony!", response.content)
+ self.assertTrue(response.content == "Django is a magical pony!", response.content)
def get_perm(Model, perm):
"""Return the permission object, for the Model"""
@@ -725,8 +725,8 @@ def testAddView(self):
post = self.client.post('/test_admin/admin/admin_views/article/add/', add_dict)
self.assertRedirects(post, '/test_admin/admin/')
self.assertEqual(Article.objects.all().count(), 4)
- self.assertEquals(len(mail.outbox), 1)
- self.assertEquals(mail.outbox[0].subject, 'Greetings from a created object')
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].subject, 'Greetings from a created object')
self.client.get('/test_admin/admin/logout/')
# Super can add too, but is redirected to the change list view
@@ -801,12 +801,12 @@ def testChangeView(self):
request = self.client.get('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/')
self.assertEqual(request.status_code, 403)
request = self.client.post('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/', {'name': 'changed'})
- self.assertEquals(RowLevelChangePermissionModel.objects.get(id=1).name, 'odd id')
+ self.assertEqual(RowLevelChangePermissionModel.objects.get(id=1).name, 'odd id')
self.assertEqual(request.status_code, 403)
request = self.client.get('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/')
self.assertEqual(request.status_code, 200)
request = self.client.post('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/', {'name': 'changed'})
- self.assertEquals(RowLevelChangePermissionModel.objects.get(id=2).name, 'changed')
+ self.assertEqual(RowLevelChangePermissionModel.objects.get(id=2).name, 'changed')
self.assertRedirects(request, '/test_admin/admin/')
self.client.get('/test_admin/admin/logout/')
for login_dict in [self.joepublic_login, self.no_username_login]:
@@ -815,14 +815,14 @@ def testChangeView(self):
self.assertEqual(request.status_code, 200)
self.assertContains(request, 'login-form')
request = self.client.post('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/1/', {'name': 'changed'})
- self.assertEquals(RowLevelChangePermissionModel.objects.get(id=1).name, 'odd id')
+ self.assertEqual(RowLevelChangePermissionModel.objects.get(id=1).name, 'odd id')
self.assertEqual(request.status_code, 200)
self.assertContains(request, 'login-form')
request = self.client.get('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/')
self.assertEqual(request.status_code, 200)
self.assertContains(request, 'login-form')
request = self.client.post('/test_admin/admin/admin_views/rowlevelchangepermissionmodel/2/', {'name': 'changed again'})
- self.assertEquals(RowLevelChangePermissionModel.objects.get(id=2).name, 'changed')
+ self.assertEqual(RowLevelChangePermissionModel.objects.get(id=2).name, 'changed')
self.assertEqual(request.status_code, 200)
self.assertContains(request, 'login-form')
self.client.get('/test_admin/admin/logout/')
@@ -856,7 +856,7 @@ def testCustomModelAdminTemplates(self):
# Test custom change list template with custom extra context
request = self.client.get('/test_admin/admin/admin_views/customarticle/')
self.assertEqual(request.status_code, 200)
- self.assert_("var hello = 'Hello!';" in request.content)
+ self.assertTrue("var hello = 'Hello!';" in request.content)
self.assertTemplateUsed(request, 'custom_admin/change_list.html')
# Test custom add form template
@@ -916,8 +916,8 @@ def testDeleteView(self):
post = self.client.post('/test_admin/admin/admin_views/article/1/delete/', delete_dict)
self.assertRedirects(post, '/test_admin/admin/')
self.assertEqual(Article.objects.all().count(), 2)
- self.assertEquals(len(mail.outbox), 1)
- self.assertEquals(mail.outbox[0].subject, 'Greetings from a deleted object')
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].subject, 'Greetings from a deleted object')
article_ct = ContentType.objects.get_for_model(Article)
logged = LogEntry.objects.get(content_type=article_ct, action_flag=DELETION)
self.assertEqual(logged.object_id, u'1')
@@ -1108,7 +1108,7 @@ def test_recentactions_without_content_type(self):
counted_presence_before = response.content.count(should_contain)
response = self.client.get('/test_admin/admin/')
counted_presence_after = response.content.count(should_contain)
- self.assertEquals(counted_presence_before - 1,
+ self.assertEqual(counted_presence_before - 1,
counted_presence_after)