From b52672d77822e88752cb178c8a359adde83ff0ba Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Thu, 3 May 2012 16:39:16 +0200 Subject: [PATCH] Replaced deprecated TestCase methods. Refs #17049. --- django/contrib/auth/tests/management.py | 2 +- django/contrib/auth/tests/models.py | 22 +++++----- .../tests/wizard/wizardtests/tests.py | 6 +-- django/contrib/gis/geoip/tests.py | 2 +- django/contrib/gis/tests/test_measure.py | 8 ++-- tests/modeltests/prefetch_related/tests.py | 12 ++--- tests/modeltests/select_for_update/tests.py | 4 +- tests/modeltests/test_client/models.py | 4 +- tests/regressiontests/admin_filters/tests.py | 10 ++--- tests/regressiontests/admin_inlines/tests.py | 44 +++++++++---------- tests/regressiontests/admin_views/tests.py | 2 +- tests/regressiontests/backends/tests.py | 4 +- .../regressiontests/createsuperuser/tests.py | 2 +- tests/regressiontests/file_uploads/tests.py | 6 +-- tests/regressiontests/servers/tests.py | 10 ++--- tests/regressiontests/settings_tests/tests.py | 4 +- .../test_client_regress/models.py | 10 ++--- tests/regressiontests/test_runner/tests.py | 4 +- tests/regressiontests/utils/feedgenerator.py | 4 +- 19 files changed, 80 insertions(+), 80 deletions(-) diff --git a/django/contrib/auth/tests/management.py b/django/contrib/auth/tests/management.py index 3708cc8bd0..5d31bd70a4 100644 --- a/django/contrib/auth/tests/management.py +++ b/django/contrib/auth/tests/management.py @@ -50,7 +50,7 @@ class ChangepasswordManagementCommandTestCase(TestCase): command.execute("joe", stdout=self.stdout) command_output = self.stdout.getvalue().strip() - self.assertEquals(command_output, "Changing password for user 'joe'\nPassword changed successfully for user 'joe'") + self.assertEqual(command_output, "Changing password for user 'joe'\nPassword changed successfully for user 'joe'") self.assertTrue(models.User.objects.get(username="joe").check_password("not qwerty")) def test_that_max_tries_exits_1(self): diff --git a/django/contrib/auth/tests/models.py b/django/contrib/auth/tests/models.py index 324f433df6..b9565922a2 100644 --- a/django/contrib/auth/tests/models.py +++ b/django/contrib/auth/tests/models.py @@ -46,12 +46,12 @@ class NaturalKeysTestCase(TestCase): def test_user_natural_key(self): staff_user = User.objects.get(username='staff') - self.assertEquals(User.objects.get_by_natural_key('staff'), staff_user) - self.assertEquals(staff_user.natural_key(), ('staff',)) + self.assertEqual(User.objects.get_by_natural_key('staff'), staff_user) + self.assertEqual(staff_user.natural_key(), ('staff',)) def test_group_natural_key(self): users_group = Group.objects.create(name='users') - self.assertEquals(Group.objects.get_by_natural_key('users'), users_group) + self.assertEqual(Group.objects.get_by_natural_key('users'), users_group) @override_settings(USE_TZ=False) @@ -61,7 +61,7 @@ class LoadDataWithoutNaturalKeysTestCase(TestCase): def test_user_is_created_and_added_to_group(self): user = User.objects.get(username='my_username') group = Group.objects.get(name='my_group') - self.assertEquals(group, user.groups.get()) + self.assertEqual(group, user.groups.get()) @override_settings(USE_TZ=False) @@ -71,7 +71,7 @@ class LoadDataWithNaturalKeysTestCase(TestCase): def test_user_is_created_and_added_to_group(self): user = User.objects.get(username='my_username') group = Group.objects.get(name='my_group') - self.assertEquals(group, user.groups.get()) + self.assertEqual(group, user.groups.get()) class UserManagerTestCase(TestCase): @@ -79,23 +79,23 @@ class UserManagerTestCase(TestCase): def test_create_user(self): email_lowercase = 'normal@normal.com' user = User.objects.create_user('user', email_lowercase) - self.assertEquals(user.email, email_lowercase) - self.assertEquals(user.username, 'user') - self.assertEquals(user.password, '!') + self.assertEqual(user.email, email_lowercase) + self.assertEqual(user.username, 'user') + self.assertEqual(user.password, '!') def test_create_user_email_domain_normalize_rfc3696(self): # According to http://tools.ietf.org/html/rfc3696#section-3 # the "@" symbol can be part of the local part of an email address returned = UserManager.normalize_email(r'Abc\@DEF@EXAMPLE.com') - self.assertEquals(returned, r'Abc\@DEF@example.com') + self.assertEqual(returned, r'Abc\@DEF@example.com') def test_create_user_email_domain_normalize(self): returned = UserManager.normalize_email('normal@DOMAIN.COM') - self.assertEquals(returned, 'normal@domain.com') + self.assertEqual(returned, 'normal@domain.com') def test_create_user_email_domain_normalize_with_whitespace(self): returned = UserManager.normalize_email('email\ with_whitespace@D.COM') - self.assertEquals(returned, 'email\ with_whitespace@d.com') + self.assertEqual(returned, 'email\ with_whitespace@d.com') def test_empty_username(self): self.assertRaisesMessage(ValueError, diff --git a/django/contrib/formtools/tests/wizard/wizardtests/tests.py b/django/contrib/formtools/tests/wizard/wizardtests/tests.py index 24234e442f..7afaf51f13 100644 --- a/django/contrib/formtools/tests/wizard/wizardtests/tests.py +++ b/django/contrib/formtools/tests/wizard/wizardtests/tests.py @@ -303,7 +303,7 @@ class WizardTestGenericViewInterface(TestCase): view = TestWizard.as_view([forms.Form]) response = view(factory.get('/')) - self.assertEquals(response.context_data['test_key'], 'test_value') + self.assertEqual(response.context_data['test_key'], 'test_value') def test_get_context_data_with_mixin(self): class AnotherMixin(object): @@ -329,8 +329,8 @@ class WizardTestGenericViewInterface(TestCase): view = TestWizard.as_view([forms.Form]) response = view(factory.get('/')) - self.assertEquals(response.context_data['test_key'], 'test_value') - self.assertEquals(response.context_data['another_key'], 'another_value') + self.assertEqual(response.context_data['test_key'], 'test_value') + self.assertEqual(response.context_data['another_key'], 'another_value') class WizardFormKwargsOverrideTests(TestCase): diff --git a/django/contrib/gis/geoip/tests.py b/django/contrib/gis/geoip/tests.py index 6e1f1579a7..a629d86bbf 100644 --- a/django/contrib/gis/geoip/tests.py +++ b/django/contrib/gis/geoip/tests.py @@ -87,7 +87,7 @@ class GeoIPTest(unittest.TestCase): self.assertEqual('TX', d['region']) self.assertEqual(713, d['area_code']) geom = g.geos(query) - self.failIf(not isinstance(geom, GEOSGeometry)) + self.assertTrue(isinstance(geom, GEOSGeometry)) lon, lat = (-95.4010, 29.7079) lat_lon = g.lat_lon(query) lat_lon = (lat_lon[1], lat_lon[0]) diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py index 72482da353..f3325628b6 100644 --- a/django/contrib/gis/tests/test_measure.py +++ b/django/contrib/gis/tests/test_measure.py @@ -45,7 +45,7 @@ class DistanceTest(unittest.TestCase): def testAccessInvalid(self): "Testing access in invalid units" d = D(m=100) - self.failIf(hasattr(d, 'banana')) + self.assertFalse(hasattr(d, 'banana')) def testAddition(self): "Test addition & subtraction" @@ -133,7 +133,7 @@ class DistanceTest(unittest.TestCase): self.assertTrue(d2 > d1) self.assertTrue(d1 == d1) self.assertTrue(d1 < d2) - self.failIf(d3) + self.assertFalse(d3) def testUnitsStr(self): "Testing conversion to strings" @@ -179,7 +179,7 @@ class AreaTest(unittest.TestCase): def testAccessInvaliA(self): "Testing access in invalid units" a = A(sq_m=100) - self.failIf(hasattr(a, 'banana')) + self.assertFalse(hasattr(a, 'banana')) def testAddition(self): "Test addition & subtraction" @@ -267,7 +267,7 @@ class AreaTest(unittest.TestCase): self.assertTrue(a2 > a1) self.assertTrue(a1 == a1) self.assertTrue(a1 < a2) - self.failIf(a3) + self.assertFalse(a3) def testUnitsStr(self): "Testing conversion to strings" diff --git a/tests/modeltests/prefetch_related/tests.py b/tests/modeltests/prefetch_related/tests.py index 51a9b698f6..5cd42a75c0 100644 --- a/tests/modeltests/prefetch_related/tests.py +++ b/tests/modeltests/prefetch_related/tests.py @@ -341,7 +341,7 @@ class MultiTableInheritanceTest(TestCase): qs = AuthorWithAge.objects.prefetch_related('addresses') addresses = [[unicode(address) for address in obj.addresses.all()] for obj in qs] - self.assertEquals(addresses, [[unicode(self.authorAddress)], [], []]) + self.assertEqual(addresses, [[unicode(self.authorAddress)], [], []]) def test_m2m_to_inheriting_model(self): qs = AuthorWithAge.objects.prefetch_related('books_with_year') @@ -351,7 +351,7 @@ class MultiTableInheritanceTest(TestCase): qs = AuthorWithAge.objects.all() lst2 = [[unicode(book) for book in author.books_with_year.all()] for author in qs] - self.assertEquals(lst, lst2) + self.assertEqual(lst, lst2) qs = BookWithYear.objects.prefetch_related('aged_authors') with self.assertNumQueries(2): @@ -360,7 +360,7 @@ class MultiTableInheritanceTest(TestCase): qs = BookWithYear.objects.all() lst2 = [[unicode(author) for author in book.aged_authors.all()] for book in qs] - self.assertEquals(lst, lst2) + self.assertEqual(lst, lst2) def test_parent_link_prefetch(self): with self.assertNumQueries(2): @@ -402,7 +402,7 @@ class ForeignKeyToFieldTest(TestCase): qs = Author.objects.prefetch_related('addresses') addresses = [[unicode(address) for address in obj.addresses.all()] for obj in qs] - self.assertEquals(addresses, [[unicode(self.authorAddress)], [], []]) + self.assertEqual(addresses, [[unicode(self.authorAddress)], [], []]) def test_m2m(self): with self.assertNumQueries(3): @@ -411,7 +411,7 @@ class ForeignKeyToFieldTest(TestCase): [unicode(i_like) for i_like in author.favorite_authors.all()], [unicode(likes_me) for likes_me in author.favors_me.all()] ) for author in qs] - self.assertEquals( + self.assertEqual( favorites, [ ([unicode(self.author2)],[unicode(self.author3)]), @@ -549,7 +549,7 @@ class MultiDbTests(TestCase): authors = "".join(["%s: %s\n" % (author.name, ", ".join(b.title for b in author.books.all())) for author in qs2]) - self.assertEquals(authors, + self.assertEqual(authors, "Charlotte: Poems, Jane Eyre\n" "Anne: Poems\n" "Emily: Poems, Wuthering Heights\n" diff --git a/tests/modeltests/select_for_update/tests.py b/tests/modeltests/select_for_update/tests.py index 0587e11a3a..243f6b50e7 100644 --- a/tests/modeltests/select_for_update/tests.py +++ b/tests/modeltests/select_for_update/tests.py @@ -80,7 +80,7 @@ class SelectForUpdateTests(TransactionTestCase): return bool(sql.find(for_update_sql) > -1) def check_exc(self, exc): - self.failUnless(isinstance(exc, DatabaseError)) + self.assertTrue(isinstance(exc, DatabaseError)) @skipUnlessDBFeature('has_select_for_update') def test_for_update_sql_generated(self): @@ -217,7 +217,7 @@ class SelectForUpdateTests(TransactionTestCase): # Check the thread has finished. Assuming it has, we should # find that it has updated the person's name. - self.failIf(thread.isAlive()) + self.assertFalse(thread.isAlive()) # We must commit the transaction to ensure that MySQL gets a fresh read, # since by default it runs in REPEATABLE READ mode diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py index cfbb4fba7a..a533d6a280 100644 --- a/tests/modeltests/test_client/models.py +++ b/tests/modeltests/test_client/models.py @@ -378,7 +378,7 @@ class ClientTest(TestCase): # Get the page without logging in. Should result in 403. response = self.client.get('/test_client/permission_protected_view_exception/') - self.assertEquals(response.status_code, 403) + self.assertEqual(response.status_code, 403) # Log in login = self.client.login(username='testclient', password='password') @@ -386,7 +386,7 @@ class ClientTest(TestCase): # Log in with wrong permissions. Should result in 403. response = self.client.get('/test_client/permission_protected_view_exception/') - self.assertEquals(response.status_code, 403) + self.assertEqual(response.status_code, 403) def test_view_with_method_permissions(self): "Request a page that is protected with a @permission_required method" diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py index e2a12c9663..8c9788b985 100644 --- a/tests/regressiontests/admin_filters/tests.py +++ b/tests/regressiontests/admin_filters/tests.py @@ -270,7 +270,7 @@ class ListFiltersTests(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'Verbose Author') + self.assertEqual(force_unicode(filterspec.title), u'Verbose Author') choices = list(filterspec.choices(changelist)) self.assertEqual(choices[-1]['selected'], True) self.assertEqual(choices[-1]['query_string'], '?author__isnull=True') @@ -280,7 +280,7 @@ class ListFiltersTests(TestCase): # Make sure the correct choice is selected filterspec = changelist.get_filters(request)[0][1] - self.assertEquals(force_unicode(filterspec.title), u'Verbose Author') + self.assertEqual(force_unicode(filterspec.title), u'Verbose Author') # order of choices depends on User model, which has no order choice = select_by(filterspec.choices(changelist), "display", "alfred") self.assertEqual(choice['selected'], True) @@ -298,7 +298,7 @@ class ListFiltersTests(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'Verbose Contributors') + self.assertEqual(force_unicode(filterspec.title), u'Verbose Contributors') choices = list(filterspec.choices(changelist)) self.assertEqual(choices[-1]['selected'], True) self.assertEqual(choices[-1]['query_string'], '?contributors__isnull=True') @@ -308,7 +308,7 @@ class ListFiltersTests(TestCase): # Make sure the correct choice is selected filterspec = changelist.get_filters(request)[0][2] - self.assertEquals(force_unicode(filterspec.title), u'Verbose Contributors') + self.assertEqual(force_unicode(filterspec.title), u'Verbose Contributors') choice = select_by(filterspec.choices(changelist), "display", "bob") self.assertEqual(choice['selected'], True) self.assertEqual(choice['query_string'], '?contributors__id__exact=%d' % self.bob.pk) @@ -509,7 +509,7 @@ class ListFiltersTests(TestCase): self.assertEqual(choices[3]['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk) filterspec = changelist.get_filters(request)[0][0] - self.assertEquals(force_unicode(filterspec.title), u'Verbose Author') + self.assertEqual(force_unicode(filterspec.title), u'Verbose Author') choice = select_by(filterspec.choices(changelist), "display", "alfred") self.assertEqual(choice['selected'], True) self.assertEqual(choice['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk) diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py index d6d02edb91..2cca67012f 100644 --- a/tests/regressiontests/admin_inlines/tests.py +++ b/tests/regressiontests/admin_inlines/tests.py @@ -405,14 +405,14 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): # Check that there's only one inline to start with and that it has the # correct ID. - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set')), 1) - self.failUnlessEqual(self.selenium.find_elements_by_css_selector( + self.assertEqual(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set')[0].get_attribute('id'), 'profile_set-0') - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set#profile_set-0 input[name=profile_set-0-first_name]')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set#profile_set-0 input[name=profile_set-0-last_name]')), 1) # Add an inline @@ -420,24 +420,24 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): # Check that the inline has been added, that it has the right id, and # that it contains the right fields. - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set')), 2) - self.failUnlessEqual(self.selenium.find_elements_by_css_selector( + self.assertEqual(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set')[1].get_attribute('id'), 'profile_set-1') - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set#profile_set-1 input[name=profile_set-1-first_name]')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set#profile_set-1 input[name=profile_set-1-last_name]')), 1) # Let's add another one to be sure self.selenium.find_element_by_link_text('Add another Profile').click() - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set')), 3) - self.failUnlessEqual(self.selenium.find_elements_by_css_selector( + self.assertEqual(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set')[2].get_attribute('id'), 'profile_set-2') - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set#profile_set-2 input[name=profile_set-2-first_name]')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '.dynamic-profile_set#profile_set-2 input[name=profile_set-2-last_name]')), 1) # Enter some data and click 'Save' @@ -473,17 +473,17 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): self.selenium.find_element_by_link_text('Add another Profile').click() self.selenium.find_element_by_link_text('Add another Profile').click() self.selenium.find_element_by_link_text('Add another Profile').click() - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '#profile_set-group table tr.dynamic-profile_set')), 5) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-0')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-1')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-2')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-3')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-4')), 1) # Click on a few delete buttons @@ -492,13 +492,13 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): self.selenium.find_element_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-2 td.delete a').click() # Verify that they're gone and that the IDs have been re-sequenced - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( '#profile_set-group table tr.dynamic-profile_set')), 3) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-0')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-1')), 1) - self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector( + self.assertEqual(len(self.selenium.find_elements_by_css_selector( 'form#profilecollection_form tr.dynamic-profile_set#profile_set-2')), 1) diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 047bcc2ae9..f9a9b15114 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -3144,7 +3144,7 @@ class ReadonlyTest(TestCase): def test_user_password_change_limited_queryset(self): su = User.objects.filter(is_superuser=True)[0] response = self.client.get('/test_admin/admin2/auth/user/%s/password/' % su.pk) - self.assertEquals(response.status_code, 404) + self.assertEqual(response.status_code, 404) @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py index 038f652698..eec817c5a2 100644 --- a/tests/regressiontests/backends/tests.py +++ b/tests/regressiontests/backends/tests.py @@ -521,7 +521,7 @@ class ThreadTests(TestCase): t = threading.Thread(target=runner) t.start() t.join() - self.assertEquals(len(connections_set), 3) + self.assertEqual(len(connections_set), 3) # Finish by closing the connections opened by the other threads (the # connection opened in the main thread will automatically be closed on # teardown). @@ -548,7 +548,7 @@ class ThreadTests(TestCase): t = threading.Thread(target=runner) t.start() t.join() - self.assertEquals(len(connections_set), 6) + self.assertEqual(len(connections_set), 6) # Finish by closing the connections opened by the other threads (the # connection opened in the main thread will automatically be closed on # teardown). diff --git a/tests/regressiontests/createsuperuser/tests.py b/tests/regressiontests/createsuperuser/tests.py index 4fdb5923ab..1c1bb0ed38 100644 --- a/tests/regressiontests/createsuperuser/tests.py +++ b/tests/regressiontests/createsuperuser/tests.py @@ -28,7 +28,7 @@ class MultiDBChangepasswordManagementCommandTestCase(TestCase): command.execute("joe", database='other', stdout=self.stdout) command_output = self.stdout.getvalue().strip() - self.assertEquals(command_output, "Changing password for user 'joe'\nPassword changed successfully for user 'joe'") + self.assertEqual(command_output, "Changing password for user 'joe'\nPassword changed successfully for user 'joe'") self.assertTrue(models.User.objects.using('other').get(username="joe").check_password("not qwerty")) diff --git a/tests/regressiontests/file_uploads/tests.py b/tests/regressiontests/file_uploads/tests.py index a461ce1702..b9ce3c2753 100644 --- a/tests/regressiontests/file_uploads/tests.py +++ b/tests/regressiontests/file_uploads/tests.py @@ -202,7 +202,7 @@ class FileUploadTests(TestCase): 'wsgi.input': client.FakePayload(payload), } got = json.loads(self.client.request(**r).content) - self.assertEquals(got, {}) + self.assertEqual(got, {}) def test_empty_multipart_handled_gracefully(self): """ @@ -217,7 +217,7 @@ class FileUploadTests(TestCase): 'wsgi.input': client.FakePayload(''), } got = json.loads(self.client.request(**r).content) - self.assertEquals(got, {}) + self.assertEqual(got, {}) def test_custom_upload_handler(self): # A small file (under the 5M quota) @@ -313,7 +313,7 @@ class FileUploadTests(TestCase): try: response = self.client.post('/file_uploads/upload_errors/', post_data) except reference_error.__class__ as err: - self.failIf( + self.assertFalse( str(err) == str(reference_error), "Caught a repeated exception that'll cause an infinite loop in file uploads." ) diff --git a/tests/regressiontests/servers/tests.py b/tests/regressiontests/servers/tests.py index c3def15771..5d287a195b 100644 --- a/tests/regressiontests/servers/tests.py +++ b/tests/regressiontests/servers/tests.py @@ -103,7 +103,7 @@ class LiveServerViews(LiveServerBase): try: self.urlopen('/') except urllib2.HTTPError as err: - self.assertEquals(err.code, 404, 'Expected 404 response') + self.assertEqual(err.code, 404, 'Expected 404 response') else: self.fail('Expected 404 response') @@ -113,7 +113,7 @@ class LiveServerViews(LiveServerBase): Refs #2879. """ f = self.urlopen('/example_view/') - self.assertEquals(f.read(), 'example view') + self.assertEqual(f.read(), 'example view') def test_static_files(self): """ @@ -121,7 +121,7 @@ class LiveServerViews(LiveServerBase): Refs #2879. """ f = self.urlopen('/static/example_static_file.txt') - self.assertEquals(f.read(), 'example static file\n') + self.assertEqual(f.read(), 'example static file\n') def test_media_files(self): """ @@ -129,7 +129,7 @@ class LiveServerViews(LiveServerBase): Refs #2879. """ f = self.urlopen('/media/example_media_file.txt') - self.assertEquals(f.read(), 'example media file\n') + self.assertEqual(f.read(), 'example media file\n') class LiveServerDatabase(LiveServerBase): @@ -141,7 +141,7 @@ class LiveServerDatabase(LiveServerBase): Refs #2879. """ f = self.urlopen('/model_view/') - self.assertEquals(f.read().splitlines(), ['jane', 'robert']) + self.assertEqual(f.read().splitlines(), ['jane', 'robert']) def test_database_writes(self): """ diff --git a/tests/regressiontests/settings_tests/tests.py b/tests/regressiontests/settings_tests/tests.py index 2027382a85..ffcb79eb09 100644 --- a/tests/regressiontests/settings_tests/tests.py +++ b/tests/regressiontests/settings_tests/tests.py @@ -19,10 +19,10 @@ class FullyDecoratedTranTestCase(TransactionTestCase): self.assertEqual(settings.TEST, 'override2') def test_decorated_testcase_name(self): - self.assertEquals(FullyDecoratedTranTestCase.__name__, 'FullyDecoratedTranTestCase') + self.assertEqual(FullyDecoratedTranTestCase.__name__, 'FullyDecoratedTranTestCase') def test_decorated_testcase_module(self): - self.assertEquals(FullyDecoratedTranTestCase.__module__, __name__) + self.assertEqual(FullyDecoratedTranTestCase.__module__, __name__) @override_settings(TEST='override') diff --git a/tests/regressiontests/test_client_regress/models.py b/tests/regressiontests/test_client_regress/models.py index ab0afd08f6..4f057b934c 100644 --- a/tests/regressiontests/test_client_regress/models.py +++ b/tests/regressiontests/test_client_regress/models.py @@ -956,23 +956,23 @@ class ReadLimitedStreamTest(TestCase): def test_body_from_empty_request(self): """HttpRequest.body on a test client GET request should return the empty string.""" - self.assertEquals(self.client.get("/test_client_regress/body/").content, '') + self.assertEqual(self.client.get("/test_client_regress/body/").content, '') def test_read_from_empty_request(self): """HttpRequest.read() on a test client GET request should return the empty string.""" - self.assertEquals(self.client.get("/test_client_regress/read_all/").content, '') + self.assertEqual(self.client.get("/test_client_regress/read_all/").content, '') def test_read_numbytes_from_empty_request(self): """HttpRequest.read(LARGE_BUFFER) on a test client GET request should return the empty string.""" - self.assertEquals(self.client.get("/test_client_regress/read_buffer/").content, '') + self.assertEqual(self.client.get("/test_client_regress/read_buffer/").content, '') def test_read_from_nonempty_request(self): """HttpRequest.read() on a test client PUT request with some payload should return that payload.""" payload = 'foobar' - self.assertEquals(self.client.put("/test_client_regress/read_all/", + self.assertEqual(self.client.put("/test_client_regress/read_all/", data=payload, content_type='text/plain').content, payload) @@ -980,7 +980,7 @@ class ReadLimitedStreamTest(TestCase): """HttpRequest.read(LARGE_BUFFER) on a test client PUT request with some payload should return that payload.""" payload = 'foobar' - self.assertEquals(self.client.put("/test_client_regress/read_buffer/", + self.assertEqual(self.client.put("/test_client_regress/read_buffer/", data=payload, content_type='text/plain').content, payload) diff --git a/tests/regressiontests/test_runner/tests.py b/tests/regressiontests/test_runner/tests.py index 27e18ce550..3a8a4efe3d 100644 --- a/tests/regressiontests/test_runner/tests.py +++ b/tests/regressiontests/test_runner/tests.py @@ -296,11 +296,11 @@ class AutoIncrementResetTest(TransactionTestCase): "tests") def test_autoincrement_reset1(self): p = Person.objects.create(first_name='Jack', last_name='Smith') - self.assertEquals(p.pk, 1) + self.assertEqual(p.pk, 1) @unittest.skipIf(connection.vendor == 'oracle', "Oracle's auto-increment fields are not reset between " "tests") def test_autoincrement_reset2(self): p = Person.objects.create(first_name='Jack', last_name='Smith') - self.assertEquals(p.pk, 1) + self.assertEqual(p.pk, 1) diff --git a/tests/regressiontests/utils/feedgenerator.py b/tests/regressiontests/utils/feedgenerator.py index 3990896f12..4f1d07852c 100644 --- a/tests/regressiontests/utils/feedgenerator.py +++ b/tests/regressiontests/utils/feedgenerator.py @@ -100,12 +100,12 @@ class FeedgeneratorTest(unittest.TestCase): def test_feed_without_feed_url_gets_rendered_without_atom_link(self): feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr') - self.assertEquals(feed.feed['feed_url'], None) + self.assertEqual(feed.feed['feed_url'], None) feed_content = feed.writeString('utf-8') self.assertNotIn('', feed_content)