diff --git a/django/contrib/auth/tests/basic.py b/django/contrib/auth/tests/basic.py index 132e7f77f9..6a3b656850 100644 --- a/django/contrib/auth/tests/basic.py +++ b/django/contrib/auth/tests/basic.py @@ -61,7 +61,7 @@ class BasicTestCase(TestCase): 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 @@ class BasicTestCase(TestCase): 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 @@ class BasicTestCase(TestCase): 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()) diff --git a/django/contrib/auth/tests/decorators.py b/django/contrib/auth/tests/decorators.py index 2aafeaac16..bd3f0115f5 100644 --- a/django/contrib/auth/tests/decorators.py +++ b/django/contrib/auth/tests/decorators.py @@ -32,7 +32,7 @@ class LoginRequiredTestCase(AuthViewsTestCase): """ 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) diff --git a/django/contrib/auth/tests/remote_user.py b/django/contrib/auth/tests/remote_user.py index 6115edcfd0..ad8733fb60 100644 --- a/django/contrib/auth/tests/remote_user.py +++ b/django/contrib/auth/tests/remote_user.py @@ -30,15 +30,15 @@ class RemoteUserTest(TestCase): 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 RemoteUserNoCreateTest(RemoteUserTest): 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) diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py index baea1fc95f..b03489c7d2 100644 --- a/django/contrib/auth/tests/views.py +++ b/django/contrib/auth/tests/views.py @@ -40,53 +40,53 @@ class AuthViewsTestCase(TestCase): '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 @@ class PasswordResetTest(AuthViewsTestCase): 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 @@ class PasswordResetTest(AuthViewsTestCase): '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 @@ class ChangePasswordTest(AuthViewsTestCase): '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 @@ class ChangePasswordTest(AuthViewsTestCase): '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 @@ class ChangePasswordTest(AuthViewsTestCase): '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 @@ class ChangePasswordTest(AuthViewsTestCase): '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 @@ class LoginTest(AuthViewsTestCase): '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 @@ class LoginTest(AuthViewsTestCase): '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 @@ class LoginURLSettings(AuthViewsTestCase): 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 @@ class LogoutTest(AuthViewsTestCase): 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 @@ class LogoutTest(AuthViewsTestCase): 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 @@ class LogoutTest(AuthViewsTestCase): 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 @@ class LogoutTest(AuthViewsTestCase): } 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 @@ class LogoutTest(AuthViewsTestCase): } 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() diff --git a/django/contrib/flatpages/tests/csrf.py b/django/contrib/flatpages/tests/csrf.py index 36b915317f..969ae8d7e9 100644 --- a/django/contrib/flatpages/tests/csrf.py +++ b/django/contrib/flatpages/tests/csrf.py @@ -34,13 +34,13 @@ class FlatpageCSRFTests(TestCase): 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, "

Isn't it flat!

") 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 @@ class FlatpageCSRFTests(TestCase): 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, "

Isn't it sekrit!

") 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, "

Isn't it flat!

") 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) diff --git a/django/contrib/flatpages/tests/middleware.py b/django/contrib/flatpages/tests/middleware.py index b971aab458..e01ca33d6d 100644 --- a/django/contrib/flatpages/tests/middleware.py +++ b/django/contrib/flatpages/tests/middleware.py @@ -30,13 +30,13 @@ class FlatpageMiddlewareTests(TestCase): 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, "

Isn't it flat!

") 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 @@ class FlatpageMiddlewareTests(TestCase): 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, "

Isn't it sekrit!

") 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, "

Isn't it flat!

") 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 @@ class FlatpageMiddlewareTests(TestCase): 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, "

Isn't it sekrit!

") diff --git a/django/contrib/flatpages/tests/templatetags.py b/django/contrib/flatpages/tests/templatetags.py index 9f42381c29..282041cee9 100644 --- a/django/contrib/flatpages/tests/templatetags.py +++ b/django/contrib/flatpages/tests/templatetags.py @@ -35,7 +35,7 @@ class FlatpageTemplateTagTests(TestCase): "{{ 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 @@ class FlatpageTemplateTagTests(TestCase): ).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 @@ class FlatpageTemplateTagTests(TestCase): ).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 @@ class FlatpageTemplateTagTests(TestCase): "{{ 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 @@ class FlatpageTemplateTagTests(TestCase): ).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 @@ class FlatpageTemplateTagTests(TestCase): ).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 @@ class FlatpageTemplateTagTests(TestCase): ).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" diff --git a/django/contrib/flatpages/tests/views.py b/django/contrib/flatpages/tests/views.py index 4a54e5697e..a8853bc883 100644 --- a/django/contrib/flatpages/tests/views.py +++ b/django/contrib/flatpages/tests/views.py @@ -31,13 +31,13 @@ class FlatpageViewTests(TestCase): 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, "

Isn't it flat!

") 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 @@ class FlatpageViewTests(TestCase): 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, "

Isn't it sekrit!

") 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 @@ class FlatpageViewTests(TestCase): 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, "

Isn't it special!

") diff --git a/django/contrib/formtools/tests/__init__.py b/django/contrib/formtools/tests/__init__.py index 4ad039a537..cc38546866 100644 --- a/django/contrib/formtools/tests/__init__.py +++ b/django/contrib/formtools/tests/__init__.py @@ -65,8 +65,8 @@ class PreviewTests(TestCase): 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 @@ class WizardTests(TestCase): 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 @@ class WizardTests(TestCase): {"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 @@ class WizardTests(TestCase): "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 @@ class WizardTests(TestCase): "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 @@ class WizardTests(TestCase): "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): """ diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py index 1a1f2b9f34..18ee21ce95 100644 --- a/django/contrib/gis/gdal/tests/test_geom.py +++ b/django/contrib/gis/gdal/tests/test_geom.py @@ -49,8 +49,8 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin): 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): diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index cc54becd3f..8342b580ed 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -867,7 +867,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin): 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 @@ class GEOSTest(unittest.TestCase, TestDataMixin): 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 @@ class GEOSTest(unittest.TestCase, TestDataMixin): 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 @@ class GEOSTest(unittest.TestCase, TestDataMixin): 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 @@ class GEOSTest(unittest.TestCase, TestDataMixin): 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" diff --git a/django/contrib/gis/geos/tests/test_mutable_list.py b/django/contrib/gis/geos/tests/test_mutable_list.py index 7fb0fce5ea..3e63a25e95 100644 --- a/django/contrib/gis/geos/tests/test_mutable_list.py +++ b/django/contrib/gis/geos/tests/test_mutable_list.py @@ -362,26 +362,26 @@ class ListMixinTest(unittest.TestCase): 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.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.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 + [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 diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py index f57445c4eb..324002e1d7 100644 --- a/django/contrib/gis/tests/geo3d/tests.py +++ b/django/contrib/gis/tests/geo3d/tests.py @@ -72,7 +72,7 @@ class Geo3DTest(TestCase): 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 @@ class Geo3DTest(TestCase): 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 @@ class Geo3DTest(TestCase): 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 @@ class Geo3DTest(TestCase): # KML should be 3D. # `SELECT ST_AsKML(point, 6) FROM geo3d_city3d WHERE name = 'Houston';` ref_kml_regex = re.compile(r'^-95.363\d+,29.763\d+,18$') - 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 @@ class Geo3DTest(TestCase): # 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 @@ class Geo3DTest(TestCase): 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): diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index a1f251ddda..296f128834 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -133,11 +133,11 @@ class GeoModelTest(TestCase): # No precision parameter for Oracle :-/ gml_regex = re.compile(r'^-104.60925\d+,38.25500\d+ ') 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'^-104\.60925\d+,38\.255001') 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 @@ class GeoModelTest(TestCase): # 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 diff --git a/django/contrib/gis/tests/relatedapp/tests.py b/django/contrib/gis/tests/relatedapp/tests.py index c8aeb28d2a..250783b2de 100644 --- a/django/contrib/gis/tests/relatedapp/tests.py +++ b/django/contrib/gis/tests/relatedapp/tests.py @@ -173,8 +173,8 @@ class RelatedGeoModelTest(TestCase): 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 @@ class RelatedGeoModelTest(TestCase): 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." diff --git a/django/contrib/gis/tests/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py index 4d55bf5274..59fab0166e 100644 --- a/django/contrib/gis/tests/test_geoforms.py +++ b/django/contrib/gis/tests/test_geoforms.py @@ -26,7 +26,7 @@ class GeometryFieldTest(unittest.TestCase): 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." diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py index 5e5e27c381..8ca6be1c40 100644 --- a/django/contrib/gis/tests/test_measure.py +++ b/django/contrib/gis/tests/test_measure.py @@ -107,7 +107,7 @@ class DistanceTest(unittest.TestCase): 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 @@ class DistanceTest(unittest.TestCase): 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 @@ class AreaTest(unittest.TestCase): 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): diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py index b1fe04f430..28fde7050d 100644 --- a/django/contrib/messages/tests/base.py +++ b/django/contrib/messages/tests/base.py @@ -349,7 +349,7 @@ class BaseTest(TestCase): 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 @@ class BaseTest(TestCase): 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 @@ class BaseTest(TestCase): 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 @@ class BaseTest(TestCase): 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) diff --git a/django/contrib/messages/tests/cookie.py b/django/contrib/messages/tests/cookie.py index 9aadcf47b2..d5671755f2 100644 --- a/django/contrib/messages/tests/cookie.py +++ b/django/contrib/messages/tests/cookie.py @@ -83,7 +83,7 @@ class CookieTest(BaseTest): 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): """ diff --git a/django/contrib/sitemaps/tests/basic.py b/django/contrib/sitemaps/tests/basic.py index 39d02262e9..cbc5c49872 100644 --- a/django/contrib/sitemaps/tests/basic.py +++ b/django/contrib/sitemaps/tests/basic.py @@ -40,7 +40,7 @@ class SitemapTests(TestCase): # Retrieve the sitemap. response = self.client.get('/simple/index.xml') # Check for all the important bits: - self.assertEquals(response.content, """ + self.assertEqual(response.content, """ %s/simple/sitemap-simple.xml @@ -51,7 +51,7 @@ class SitemapTests(TestCase): # Retrieve the sitemap. response = self.client.get('/simple/custom-index.xml') # Check for all the important bits: - self.assertEquals(response.content, """ + self.assertEqual(response.content, """ %s/simple/sitemap-simple.xml @@ -63,7 +63,7 @@ class SitemapTests(TestCase): # Retrieve the sitemap. response = self.client.get('/simple/sitemap.xml') # Check for all the important bits: - self.assertEquals(response.content, """ + self.assertEqual(response.content, """ %s/location/%snever0.5 @@ -74,7 +74,7 @@ class SitemapTests(TestCase): # Retrieve the sitemap. response = self.client.get('/simple/custom-sitemap.xml') # Check for all the important bits: - self.assertEquals(response.content, """ + self.assertEqual(response.content, """ %s/location/%snever0.5 @@ -105,7 +105,7 @@ class SitemapTests(TestCase): for username in User.objects.values_list("username", flat=True): expected += "%s/users/%s/" % (self.base_url, username) # Check for all the important bits: - self.assertEquals(response.content, """ + self.assertEqual(response.content, """ %s @@ -148,7 +148,7 @@ class SitemapTests(TestCase): # Retrieve the sitemap. response = self.client.get('/simple/sitemap.xml') # Check for all the important bits: - self.assertEquals(response.content, """ + self.assertEqual(response.content, """ http://testserver/location/%snever0.5 diff --git a/django/contrib/sites/tests.py b/django/contrib/sites/tests.py index 85cb53c403..17ab1f2a7c 100644 --- a/django/contrib/sites/tests.py +++ b/django/contrib/sites/tests.py @@ -18,7 +18,7 @@ class SitesFrameworkTests(TestCase): 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 @@ class SitesFrameworkTests(TestCase): "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 @@ class SitesFrameworkTests(TestCase): # 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") diff --git a/django/utils/unittest/case.py b/django/utils/unittest/case.py index fd5623b03c..5ae602957b 100644 --- a/django/utils/unittest/case.py +++ b/django/utils/unittest/case.py @@ -831,8 +831,8 @@ class TestCase(unittest.TestCase): 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 @@ class TestCase(unittest.TestCase): 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: diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index 795f041fb9..41768576af 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -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 -------- diff --git a/tests/modeltests/aggregation/tests.py b/tests/modeltests/aggregation/tests.py index c830368b9d..6f68800ad2 100644 --- a/tests/modeltests/aggregation/tests.py +++ b/tests/modeltests/aggregation/tests.py @@ -41,7 +41,7 @@ class BaseAggregateTestCase(TestCase): 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) diff --git a/tests/modeltests/model_formsets/tests.py b/tests/modeltests/model_formsets/tests.py index 91c9043e75..5e6d88ebe8 100644 --- a/tests/modeltests/model_formsets/tests.py +++ b/tests/modeltests/model_formsets/tests.py @@ -946,7 +946,7 @@ class ModelFormsetTest(TestCase): # 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() diff --git a/tests/modeltests/model_inheritance_same_model_name/tests.py b/tests/modeltests/model_inheritance_same_model_name/tests.py index 3f1e3458e6..3d173e62a6 100644 --- a/tests/modeltests/model_inheritance_same_model_name/tests.py +++ b/tests/modeltests/model_inheritance_same_model_name/tests.py @@ -11,7 +11,7 @@ class InheritanceSameModelNameTests(TestCase): 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 @@ class InheritanceSameModelNameTests(TestCase): 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/', diff --git a/tests/modeltests/proxy_model_inheritance/tests.py b/tests/modeltests/proxy_model_inheritance/tests.py index b6828515ab..7426f41de5 100644 --- a/tests/modeltests/proxy_model_inheritance/tests.py +++ b/tests/modeltests/proxy_model_inheritance/tests.py @@ -32,5 +32,5 @@ class ProxyModelInheritanceTests(TransactionTestCase): 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) diff --git a/tests/modeltests/raw_query/tests.py b/tests/modeltests/raw_query/tests.py index e7cadfae8c..5334412680 100644 --- a/tests/modeltests/raw_query/tests.py +++ b/tests/modeltests/raw_query/tests.py @@ -30,10 +30,10 @@ class RawQueryTests(TestCase): 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 @@ class RawQueryTests(TestCase): 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 @@ class RawQueryTests(TestCase): 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']) diff --git a/tests/modeltests/serializers/tests.py b/tests/modeltests/serializers/tests.py index 01b4b68ac2..013438ed29 100644 --- a/tests/modeltests/serializers/tests.py +++ b/tests/modeltests/serializers/tests.py @@ -225,7 +225,7 @@ class SerializersTestBase(object): 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): """ diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py index 0960929004..16bdd2d29a 100644 --- a/tests/modeltests/test_client/models.py +++ b/tests/modeltests/test_client/models.py @@ -79,7 +79,7 @@ class ClientTest(TestCase): "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 @@ class ClientTest(TestCase): "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 @@ class ClientTest(TestCase): 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" diff --git a/tests/modeltests/unmanaged_models/tests.py b/tests/modeltests/unmanaged_models/tests.py index dbbe848cce..dee3799234 100644 --- a/tests/modeltests/unmanaged_models/tests.py +++ b/tests/modeltests/unmanaged_models/tests.py @@ -47,7 +47,7 @@ class ManyToManyUnmanagedTests(TestCase): """ 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 @@ class ManyToManyUnmanagedTests(TestCase): """ 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) diff --git a/tests/modeltests/user_commands/tests.py b/tests/modeltests/user_commands/tests.py index 84aa7a53d5..aa1398f50f 100644 --- a/tests/modeltests/user_commands/tests.py +++ b/tests/modeltests/user_commands/tests.py @@ -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): diff --git a/tests/modeltests/validation/__init__.py b/tests/modeltests/validation/__init__.py index ca18c1bd68..c8a89cd36f 100644 --- a/tests/modeltests/validation/__init__.py +++ b/tests/modeltests/validation/__init__.py @@ -8,7 +8,7 @@ class ValidationTestCase(unittest.TestCase): 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 @@ class ValidationTestCase(unittest.TestCase): 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]) diff --git a/tests/modeltests/validators/tests.py b/tests/modeltests/validators/tests.py index 6fe154288d..e58526285b 100644 --- a/tests/modeltests/validators/tests.py +++ b/tests/modeltests/validators/tests.py @@ -141,18 +141,18 @@ def create_simple_test_method(validator, expected, value, num): 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: diff --git a/tests/regressiontests/admin_filterspecs/tests.py b/tests/regressiontests/admin_filterspecs/tests.py index 64a6ac700e..b4b3056805 100644 --- a/tests/regressiontests/admin_filterspecs/tests.py +++ b/tests/regressiontests/admin_filterspecs/tests.py @@ -42,20 +42,20 @@ class FilterSpecsTests(TestCase): # 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 @@ class FilterSpecsTests(TestCase): # 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 @@ class FilterSpecsTests(TestCase): # 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 @@ class FilterSpecsTests(TestCase): # 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 @@ class FilterSpecsTests(TestCase): # 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') diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py index 76cecc0842..ed4bd356ba 100644 --- a/tests/regressiontests/admin_scripts/tests.py +++ b/tests/regressiontests/admin_scripts/tests.py @@ -155,7 +155,7 @@ class AdminScriptTestCase(unittest.TestCase): 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 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase): 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): diff --git a/tests/regressiontests/admin_util/tests.py b/tests/regressiontests/admin_util/tests.py index 24dde41c25..f4b3dd935d 100644 --- a/tests/regressiontests/admin_util/tests.py +++ b/tests/regressiontests/admin_util/tests.py @@ -24,7 +24,7 @@ class NestedObjectsTests(TestCase): 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 @@ class UtilTests(unittest.TestCase): """ 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 @@ class UtilTests(unittest.TestCase): 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 @@ class UtilTests(unittest.TestCase): 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 @@ class UtilTests(unittest.TestCase): """ 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), ) diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index eca8adedc9..127dd685b2 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -478,7 +478,7 @@ class SaveAsTests(TestCase): 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 @@ class CustomModelAdminTest(AdminViewBasicTest): 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 @@ class AdminViewPermissionsTest(TestCase): 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 @@ class AdminViewPermissionsTest(TestCase): 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 @@ class AdminViewPermissionsTest(TestCase): 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 @@ class AdminViewPermissionsTest(TestCase): # 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 @@ class AdminViewPermissionsTest(TestCase): 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 @@ class AdminViewStringPrimaryKeyTest(TestCase): 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) def test_deleteconfirmation_link(self): @@ -1568,7 +1568,7 @@ class AdminViewListEditable(TestCase): } response = self.client.post('/test_admin/admin/admin_views/person/', data) non_form_errors = response.context['cl'].formset.non_form_errors() - self.assert_(isinstance(non_form_errors, ErrorList)) + self.assertTrue(isinstance(non_form_errors, ErrorList)) self.assertEqual(str(non_form_errors), str(ErrorList(["Grace is not a Zombie"]))) def test_list_editable_ordering(self): @@ -1853,8 +1853,8 @@ class AdminActionsTest(TestCase): 'index': 0, } response = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data) - self.assertEquals(len(mail.outbox), 1) - self.assertEquals(mail.outbox[0].subject, 'Greetings from a ModelAdmin action') + self.assertEqual(len(mail.outbox), 1) + self.assertEqual(mail.outbox[0].subject, 'Greetings from a ModelAdmin action') def test_model_admin_default_delete_action(self): "Tests the default delete action defined as a ModelAdmin method" @@ -1927,8 +1927,8 @@ class AdminActionsTest(TestCase): 'index': 0, } response = self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data) - self.assertEquals(len(mail.outbox), 1) - self.assertEquals(mail.outbox[0].subject, 'Greetings from a function action') + self.assertEqual(len(mail.outbox), 1) + self.assertEqual(mail.outbox[0].subject, 'Greetings from a function action') def test_custom_function_action_with_redirect(self): "Tests a custom action defined in a function" @@ -1958,19 +1958,19 @@ class AdminActionsTest(TestCase): def test_model_without_action(self): "Tests a ModelAdmin without any action" response = self.client.get('/test_admin/admin/admin_views/oldsubscriber/') - self.assertEquals(response.context["action_form"], None) - self.assert_( + self.assertEqual(response.context["action_form"], None) + self.assertTrue( '') self.assertContains(response, 'example.com comments') self.assertContains(response, 'http://example.com/') diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py index e5094ab0cc..c9be06a340 100644 --- a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py +++ b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py @@ -182,14 +182,14 @@ class AdminActionsTests(CommentTestCase): comments = self.createSomeComments() self.client.login(username="normaluser", password="normaluser") response = self.client.get("/admin/comments/comment/") - self.assertEquals("approve_comments" in response.content, False) + self.assertEqual("approve_comments" in response.content, False) def testActionsModerator(self): comments = self.createSomeComments() makeModerator("normaluser") self.client.login(username="normaluser", password="normaluser") response = self.client.get("/admin/comments/comment/") - self.assertEquals("approve_comments" in response.content, True) + self.assertEqual("approve_comments" in response.content, True) def testActionsDisabledDelete(self): "Tests a CommentAdmin where 'delete_selected' has been disabled." @@ -197,7 +197,7 @@ class AdminActionsTests(CommentTestCase): self.client.login(username="normaluser", password="normaluser") response = self.client.get('/admin2/comments/comment/') self.assertEqual(response.status_code, 200) - self.assert_( + self.assertTrue( '