Merge branch 'master' of github.com:django/django

This commit is contained in:
Ramiro Morales 2012-05-03 11:54:51 -03:00
commit c0395dea46
19 changed files with 80 additions and 80 deletions

View File

@ -50,7 +50,7 @@ class ChangepasswordManagementCommandTestCase(TestCase):
command.execute("joe", stdout=self.stdout) command.execute("joe", stdout=self.stdout)
command_output = self.stdout.getvalue().strip() 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")) self.assertTrue(models.User.objects.get(username="joe").check_password("not qwerty"))
def test_that_max_tries_exits_1(self): def test_that_max_tries_exits_1(self):

View File

@ -46,12 +46,12 @@ class NaturalKeysTestCase(TestCase):
def test_user_natural_key(self): def test_user_natural_key(self):
staff_user = User.objects.get(username='staff') staff_user = User.objects.get(username='staff')
self.assertEquals(User.objects.get_by_natural_key('staff'), staff_user) self.assertEqual(User.objects.get_by_natural_key('staff'), staff_user)
self.assertEquals(staff_user.natural_key(), ('staff',)) self.assertEqual(staff_user.natural_key(), ('staff',))
def test_group_natural_key(self): def test_group_natural_key(self):
users_group = Group.objects.create(name='users') 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) @override_settings(USE_TZ=False)
@ -61,7 +61,7 @@ class LoadDataWithoutNaturalKeysTestCase(TestCase):
def test_user_is_created_and_added_to_group(self): def test_user_is_created_and_added_to_group(self):
user = User.objects.get(username='my_username') user = User.objects.get(username='my_username')
group = Group.objects.get(name='my_group') group = Group.objects.get(name='my_group')
self.assertEquals(group, user.groups.get()) self.assertEqual(group, user.groups.get())
@override_settings(USE_TZ=False) @override_settings(USE_TZ=False)
@ -71,7 +71,7 @@ class LoadDataWithNaturalKeysTestCase(TestCase):
def test_user_is_created_and_added_to_group(self): def test_user_is_created_and_added_to_group(self):
user = User.objects.get(username='my_username') user = User.objects.get(username='my_username')
group = Group.objects.get(name='my_group') group = Group.objects.get(name='my_group')
self.assertEquals(group, user.groups.get()) self.assertEqual(group, user.groups.get())
class UserManagerTestCase(TestCase): class UserManagerTestCase(TestCase):
@ -79,23 +79,23 @@ class UserManagerTestCase(TestCase):
def test_create_user(self): def test_create_user(self):
email_lowercase = 'normal@normal.com' email_lowercase = 'normal@normal.com'
user = User.objects.create_user('user', email_lowercase) user = User.objects.create_user('user', email_lowercase)
self.assertEquals(user.email, email_lowercase) self.assertEqual(user.email, email_lowercase)
self.assertEquals(user.username, 'user') self.assertEqual(user.username, 'user')
self.assertEquals(user.password, '!') self.assertEqual(user.password, '!')
def test_create_user_email_domain_normalize_rfc3696(self): def test_create_user_email_domain_normalize_rfc3696(self):
# According to http://tools.ietf.org/html/rfc3696#section-3 # According to http://tools.ietf.org/html/rfc3696#section-3
# the "@" symbol can be part of the local part of an email address # the "@" symbol can be part of the local part of an email address
returned = UserManager.normalize_email(r'Abc\@DEF@EXAMPLE.com') 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): def test_create_user_email_domain_normalize(self):
returned = UserManager.normalize_email('normal@DOMAIN.COM') 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): def test_create_user_email_domain_normalize_with_whitespace(self):
returned = UserManager.normalize_email('email\ with_whitespace@D.COM') 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): def test_empty_username(self):
self.assertRaisesMessage(ValueError, self.assertRaisesMessage(ValueError,

View File

@ -303,7 +303,7 @@ class WizardTestGenericViewInterface(TestCase):
view = TestWizard.as_view([forms.Form]) view = TestWizard.as_view([forms.Form])
response = view(factory.get('/')) 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): def test_get_context_data_with_mixin(self):
class AnotherMixin(object): class AnotherMixin(object):
@ -329,8 +329,8 @@ class WizardTestGenericViewInterface(TestCase):
view = TestWizard.as_view([forms.Form]) view = TestWizard.as_view([forms.Form])
response = view(factory.get('/')) response = view(factory.get('/'))
self.assertEquals(response.context_data['test_key'], 'test_value') self.assertEqual(response.context_data['test_key'], 'test_value')
self.assertEquals(response.context_data['another_key'], 'another_value') self.assertEqual(response.context_data['another_key'], 'another_value')
class WizardFormKwargsOverrideTests(TestCase): class WizardFormKwargsOverrideTests(TestCase):

View File

@ -87,7 +87,7 @@ class GeoIPTest(unittest.TestCase):
self.assertEqual('TX', d['region']) self.assertEqual('TX', d['region'])
self.assertEqual(713, d['area_code']) self.assertEqual(713, d['area_code'])
geom = g.geos(query) geom = g.geos(query)
self.failIf(not isinstance(geom, GEOSGeometry)) self.assertTrue(isinstance(geom, GEOSGeometry))
lon, lat = (-95.4010, 29.7079) lon, lat = (-95.4010, 29.7079)
lat_lon = g.lat_lon(query) lat_lon = g.lat_lon(query)
lat_lon = (lat_lon[1], lat_lon[0]) lat_lon = (lat_lon[1], lat_lon[0])

View File

@ -45,7 +45,7 @@ class DistanceTest(unittest.TestCase):
def testAccessInvalid(self): def testAccessInvalid(self):
"Testing access in invalid units" "Testing access in invalid units"
d = D(m=100) d = D(m=100)
self.failIf(hasattr(d, 'banana')) self.assertFalse(hasattr(d, 'banana'))
def testAddition(self): def testAddition(self):
"Test addition & subtraction" "Test addition & subtraction"
@ -133,7 +133,7 @@ class DistanceTest(unittest.TestCase):
self.assertTrue(d2 > d1) self.assertTrue(d2 > d1)
self.assertTrue(d1 == d1) self.assertTrue(d1 == d1)
self.assertTrue(d1 < d2) self.assertTrue(d1 < d2)
self.failIf(d3) self.assertFalse(d3)
def testUnitsStr(self): def testUnitsStr(self):
"Testing conversion to strings" "Testing conversion to strings"
@ -179,7 +179,7 @@ class AreaTest(unittest.TestCase):
def testAccessInvaliA(self): def testAccessInvaliA(self):
"Testing access in invalid units" "Testing access in invalid units"
a = A(sq_m=100) a = A(sq_m=100)
self.failIf(hasattr(a, 'banana')) self.assertFalse(hasattr(a, 'banana'))
def testAddition(self): def testAddition(self):
"Test addition & subtraction" "Test addition & subtraction"
@ -267,7 +267,7 @@ class AreaTest(unittest.TestCase):
self.assertTrue(a2 > a1) self.assertTrue(a2 > a1)
self.assertTrue(a1 == a1) self.assertTrue(a1 == a1)
self.assertTrue(a1 < a2) self.assertTrue(a1 < a2)
self.failIf(a3) self.assertFalse(a3)
def testUnitsStr(self): def testUnitsStr(self):
"Testing conversion to strings" "Testing conversion to strings"

View File

@ -341,7 +341,7 @@ class MultiTableInheritanceTest(TestCase):
qs = AuthorWithAge.objects.prefetch_related('addresses') qs = AuthorWithAge.objects.prefetch_related('addresses')
addresses = [[unicode(address) for address in obj.addresses.all()] addresses = [[unicode(address) for address in obj.addresses.all()]
for obj in qs] for obj in qs]
self.assertEquals(addresses, [[unicode(self.authorAddress)], [], []]) self.assertEqual(addresses, [[unicode(self.authorAddress)], [], []])
def test_m2m_to_inheriting_model(self): def test_m2m_to_inheriting_model(self):
qs = AuthorWithAge.objects.prefetch_related('books_with_year') qs = AuthorWithAge.objects.prefetch_related('books_with_year')
@ -351,7 +351,7 @@ class MultiTableInheritanceTest(TestCase):
qs = AuthorWithAge.objects.all() qs = AuthorWithAge.objects.all()
lst2 = [[unicode(book) for book in author.books_with_year.all()] lst2 = [[unicode(book) for book in author.books_with_year.all()]
for author in qs] for author in qs]
self.assertEquals(lst, lst2) self.assertEqual(lst, lst2)
qs = BookWithYear.objects.prefetch_related('aged_authors') qs = BookWithYear.objects.prefetch_related('aged_authors')
with self.assertNumQueries(2): with self.assertNumQueries(2):
@ -360,7 +360,7 @@ class MultiTableInheritanceTest(TestCase):
qs = BookWithYear.objects.all() qs = BookWithYear.objects.all()
lst2 = [[unicode(author) for author in book.aged_authors.all()] lst2 = [[unicode(author) for author in book.aged_authors.all()]
for book in qs] for book in qs]
self.assertEquals(lst, lst2) self.assertEqual(lst, lst2)
def test_parent_link_prefetch(self): def test_parent_link_prefetch(self):
with self.assertNumQueries(2): with self.assertNumQueries(2):
@ -402,7 +402,7 @@ class ForeignKeyToFieldTest(TestCase):
qs = Author.objects.prefetch_related('addresses') qs = Author.objects.prefetch_related('addresses')
addresses = [[unicode(address) for address in obj.addresses.all()] addresses = [[unicode(address) for address in obj.addresses.all()]
for obj in qs] for obj in qs]
self.assertEquals(addresses, [[unicode(self.authorAddress)], [], []]) self.assertEqual(addresses, [[unicode(self.authorAddress)], [], []])
def test_m2m(self): def test_m2m(self):
with self.assertNumQueries(3): with self.assertNumQueries(3):
@ -411,7 +411,7 @@ class ForeignKeyToFieldTest(TestCase):
[unicode(i_like) for i_like in author.favorite_authors.all()], [unicode(i_like) for i_like in author.favorite_authors.all()],
[unicode(likes_me) for likes_me in author.favors_me.all()] [unicode(likes_me) for likes_me in author.favors_me.all()]
) for author in qs] ) for author in qs]
self.assertEquals( self.assertEqual(
favorites, favorites,
[ [
([unicode(self.author2)],[unicode(self.author3)]), ([unicode(self.author2)],[unicode(self.author3)]),
@ -549,7 +549,7 @@ class MultiDbTests(TestCase):
authors = "".join(["%s: %s\n" % authors = "".join(["%s: %s\n" %
(author.name, ", ".join(b.title for b in author.books.all())) (author.name, ", ".join(b.title for b in author.books.all()))
for author in qs2]) for author in qs2])
self.assertEquals(authors, self.assertEqual(authors,
"Charlotte: Poems, Jane Eyre\n" "Charlotte: Poems, Jane Eyre\n"
"Anne: Poems\n" "Anne: Poems\n"
"Emily: Poems, Wuthering Heights\n" "Emily: Poems, Wuthering Heights\n"

View File

@ -80,7 +80,7 @@ class SelectForUpdateTests(TransactionTestCase):
return bool(sql.find(for_update_sql) > -1) return bool(sql.find(for_update_sql) > -1)
def check_exc(self, exc): def check_exc(self, exc):
self.failUnless(isinstance(exc, DatabaseError)) self.assertTrue(isinstance(exc, DatabaseError))
@skipUnlessDBFeature('has_select_for_update') @skipUnlessDBFeature('has_select_for_update')
def test_for_update_sql_generated(self): def test_for_update_sql_generated(self):
@ -217,7 +217,7 @@ class SelectForUpdateTests(TransactionTestCase):
# Check the thread has finished. Assuming it has, we should # Check the thread has finished. Assuming it has, we should
# find that it has updated the person's name. # 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, # We must commit the transaction to ensure that MySQL gets a fresh read,
# since by default it runs in REPEATABLE READ mode # since by default it runs in REPEATABLE READ mode

View File

@ -378,7 +378,7 @@ class ClientTest(TestCase):
# Get the page without logging in. Should result in 403. # Get the page without logging in. Should result in 403.
response = self.client.get('/test_client/permission_protected_view_exception/') response = self.client.get('/test_client/permission_protected_view_exception/')
self.assertEquals(response.status_code, 403) self.assertEqual(response.status_code, 403)
# Log in # Log in
login = self.client.login(username='testclient', password='password') login = self.client.login(username='testclient', password='password')
@ -386,7 +386,7 @@ class ClientTest(TestCase):
# Log in with wrong permissions. Should result in 403. # Log in with wrong permissions. Should result in 403.
response = self.client.get('/test_client/permission_protected_view_exception/') 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): def test_view_with_method_permissions(self):
"Request a page that is protected with a @permission_required method" "Request a page that is protected with a @permission_required method"

View File

@ -270,7 +270,7 @@ class ListFiltersTests(TestCase):
# Make sure the last choice is None and is selected # Make sure the last choice is None and is selected
filterspec = changelist.get_filters(request)[0][1] 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)) choices = list(filterspec.choices(changelist))
self.assertEqual(choices[-1]['selected'], True) self.assertEqual(choices[-1]['selected'], True)
self.assertEqual(choices[-1]['query_string'], '?author__isnull=True') self.assertEqual(choices[-1]['query_string'], '?author__isnull=True')
@ -280,7 +280,7 @@ class ListFiltersTests(TestCase):
# Make sure the correct choice is selected # Make sure the correct choice is selected
filterspec = changelist.get_filters(request)[0][1] 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 # order of choices depends on User model, which has no order
choice = select_by(filterspec.choices(changelist), "display", "alfred") choice = select_by(filterspec.choices(changelist), "display", "alfred")
self.assertEqual(choice['selected'], True) self.assertEqual(choice['selected'], True)
@ -298,7 +298,7 @@ class ListFiltersTests(TestCase):
# Make sure the last choice is None and is selected # Make sure the last choice is None and is selected
filterspec = changelist.get_filters(request)[0][2] 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)) choices = list(filterspec.choices(changelist))
self.assertEqual(choices[-1]['selected'], True) self.assertEqual(choices[-1]['selected'], True)
self.assertEqual(choices[-1]['query_string'], '?contributors__isnull=True') self.assertEqual(choices[-1]['query_string'], '?contributors__isnull=True')
@ -308,7 +308,7 @@ class ListFiltersTests(TestCase):
# Make sure the correct choice is selected # Make sure the correct choice is selected
filterspec = changelist.get_filters(request)[0][2] 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") choice = select_by(filterspec.choices(changelist), "display", "bob")
self.assertEqual(choice['selected'], True) self.assertEqual(choice['selected'], True)
self.assertEqual(choice['query_string'], '?contributors__id__exact=%d' % self.bob.pk) 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) self.assertEqual(choices[3]['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk)
filterspec = changelist.get_filters(request)[0][0] 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") choice = select_by(filterspec.choices(changelist), "display", "alfred")
self.assertEqual(choice['selected'], True) self.assertEqual(choice['selected'], True)
self.assertEqual(choice['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk) self.assertEqual(choice['query_string'], '?publication-decade=the+00s&author__id__exact=%s' % self.alfred.pk)

View File

@ -405,14 +405,14 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
# Check that there's only one inline to start with and that it has the # Check that there's only one inline to start with and that it has the
# correct ID. # 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) '.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'), '.dynamic-profile_set')[0].get_attribute('id'),
'profile_set-0') '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) '.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) '.dynamic-profile_set#profile_set-0 input[name=profile_set-0-last_name]')), 1)
# Add an inline # Add an inline
@ -420,24 +420,24 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
# Check that the inline has been added, that it has the right id, and # Check that the inline has been added, that it has the right id, and
# that it contains the right fields. # 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) '.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') '.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) '.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) '.dynamic-profile_set#profile_set-1 input[name=profile_set-1-last_name]')), 1)
# Let's add another one to be sure # Let's add another one to be sure
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(
'.dynamic-profile_set')), 3) '.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') '.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) '.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) '.dynamic-profile_set#profile_set-2 input[name=profile_set-2-last_name]')), 1)
# Enter some data and click 'Save' # 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.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) '#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) '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) '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) '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) '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) 'form#profilecollection_form tr.dynamic-profile_set#profile_set-4')), 1)
# Click on a few delete buttons # Click on a few delete buttons
@ -492,13 +492,13 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
self.selenium.find_element_by_css_selector( self.selenium.find_element_by_css_selector(
'form#profilecollection_form tr.dynamic-profile_set#profile_set-2 td.delete a').click() '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 # 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) '#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) '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) '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) 'form#profilecollection_form tr.dynamic-profile_set#profile_set-2')), 1)

View File

@ -3144,7 +3144,7 @@ class ReadonlyTest(TestCase):
def test_user_password_change_limited_queryset(self): def test_user_password_change_limited_queryset(self):
su = User.objects.filter(is_superuser=True)[0] su = User.objects.filter(is_superuser=True)[0]
response = self.client.get('/test_admin/admin2/auth/user/%s/password/' % su.pk) 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',)) @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))

View File

@ -521,7 +521,7 @@ class ThreadTests(TestCase):
t = threading.Thread(target=runner) t = threading.Thread(target=runner)
t.start() t.start()
t.join() 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 # Finish by closing the connections opened by the other threads (the
# connection opened in the main thread will automatically be closed on # connection opened in the main thread will automatically be closed on
# teardown). # teardown).
@ -548,7 +548,7 @@ class ThreadTests(TestCase):
t = threading.Thread(target=runner) t = threading.Thread(target=runner)
t.start() t.start()
t.join() 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 # Finish by closing the connections opened by the other threads (the
# connection opened in the main thread will automatically be closed on # connection opened in the main thread will automatically be closed on
# teardown). # teardown).

View File

@ -28,7 +28,7 @@ class MultiDBChangepasswordManagementCommandTestCase(TestCase):
command.execute("joe", database='other', stdout=self.stdout) command.execute("joe", database='other', stdout=self.stdout)
command_output = self.stdout.getvalue().strip() 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")) self.assertTrue(models.User.objects.using('other').get(username="joe").check_password("not qwerty"))

View File

@ -202,7 +202,7 @@ class FileUploadTests(TestCase):
'wsgi.input': client.FakePayload(payload), 'wsgi.input': client.FakePayload(payload),
} }
got = json.loads(self.client.request(**r).content) got = json.loads(self.client.request(**r).content)
self.assertEquals(got, {}) self.assertEqual(got, {})
def test_empty_multipart_handled_gracefully(self): def test_empty_multipart_handled_gracefully(self):
""" """
@ -217,7 +217,7 @@ class FileUploadTests(TestCase):
'wsgi.input': client.FakePayload(''), 'wsgi.input': client.FakePayload(''),
} }
got = json.loads(self.client.request(**r).content) got = json.loads(self.client.request(**r).content)
self.assertEquals(got, {}) self.assertEqual(got, {})
def test_custom_upload_handler(self): def test_custom_upload_handler(self):
# A small file (under the 5M quota) # A small file (under the 5M quota)
@ -313,7 +313,7 @@ class FileUploadTests(TestCase):
try: try:
response = self.client.post('/file_uploads/upload_errors/', post_data) response = self.client.post('/file_uploads/upload_errors/', post_data)
except reference_error.__class__ as err: except reference_error.__class__ as err:
self.failIf( self.assertFalse(
str(err) == str(reference_error), str(err) == str(reference_error),
"Caught a repeated exception that'll cause an infinite loop in file uploads." "Caught a repeated exception that'll cause an infinite loop in file uploads."
) )

View File

@ -103,7 +103,7 @@ class LiveServerViews(LiveServerBase):
try: try:
self.urlopen('/') self.urlopen('/')
except urllib2.HTTPError as err: except urllib2.HTTPError as err:
self.assertEquals(err.code, 404, 'Expected 404 response') self.assertEqual(err.code, 404, 'Expected 404 response')
else: else:
self.fail('Expected 404 response') self.fail('Expected 404 response')
@ -113,7 +113,7 @@ class LiveServerViews(LiveServerBase):
Refs #2879. Refs #2879.
""" """
f = self.urlopen('/example_view/') f = self.urlopen('/example_view/')
self.assertEquals(f.read(), 'example view') self.assertEqual(f.read(), 'example view')
def test_static_files(self): def test_static_files(self):
""" """
@ -121,7 +121,7 @@ class LiveServerViews(LiveServerBase):
Refs #2879. Refs #2879.
""" """
f = self.urlopen('/static/example_static_file.txt') 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): def test_media_files(self):
""" """
@ -129,7 +129,7 @@ class LiveServerViews(LiveServerBase):
Refs #2879. Refs #2879.
""" """
f = self.urlopen('/media/example_media_file.txt') 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): class LiveServerDatabase(LiveServerBase):
@ -141,7 +141,7 @@ class LiveServerDatabase(LiveServerBase):
Refs #2879. Refs #2879.
""" """
f = self.urlopen('/model_view/') f = self.urlopen('/model_view/')
self.assertEquals(f.read().splitlines(), ['jane', 'robert']) self.assertEqual(f.read().splitlines(), ['jane', 'robert'])
def test_database_writes(self): def test_database_writes(self):
""" """

View File

@ -19,10 +19,10 @@ class FullyDecoratedTranTestCase(TransactionTestCase):
self.assertEqual(settings.TEST, 'override2') self.assertEqual(settings.TEST, 'override2')
def test_decorated_testcase_name(self): def test_decorated_testcase_name(self):
self.assertEquals(FullyDecoratedTranTestCase.__name__, 'FullyDecoratedTranTestCase') self.assertEqual(FullyDecoratedTranTestCase.__name__, 'FullyDecoratedTranTestCase')
def test_decorated_testcase_module(self): def test_decorated_testcase_module(self):
self.assertEquals(FullyDecoratedTranTestCase.__module__, __name__) self.assertEqual(FullyDecoratedTranTestCase.__module__, __name__)
@override_settings(TEST='override') @override_settings(TEST='override')

View File

@ -956,23 +956,23 @@ class ReadLimitedStreamTest(TestCase):
def test_body_from_empty_request(self): def test_body_from_empty_request(self):
"""HttpRequest.body on a test client GET request should return """HttpRequest.body on a test client GET request should return
the empty string.""" 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): def test_read_from_empty_request(self):
"""HttpRequest.read() on a test client GET request should return the """HttpRequest.read() on a test client GET request should return the
empty string.""" 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): def test_read_numbytes_from_empty_request(self):
"""HttpRequest.read(LARGE_BUFFER) on a test client GET request should """HttpRequest.read(LARGE_BUFFER) on a test client GET request should
return the empty string.""" 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): def test_read_from_nonempty_request(self):
"""HttpRequest.read() on a test client PUT request with some payload """HttpRequest.read() on a test client PUT request with some payload
should return that payload.""" should return that payload."""
payload = 'foobar' payload = 'foobar'
self.assertEquals(self.client.put("/test_client_regress/read_all/", self.assertEqual(self.client.put("/test_client_regress/read_all/",
data=payload, data=payload,
content_type='text/plain').content, 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 """HttpRequest.read(LARGE_BUFFER) on a test client PUT request with
some payload should return that payload.""" some payload should return that payload."""
payload = 'foobar' payload = 'foobar'
self.assertEquals(self.client.put("/test_client_regress/read_buffer/", self.assertEqual(self.client.put("/test_client_regress/read_buffer/",
data=payload, data=payload,
content_type='text/plain').content, payload) content_type='text/plain').content, payload)

View File

@ -296,11 +296,11 @@ class AutoIncrementResetTest(TransactionTestCase):
"tests") "tests")
def test_autoincrement_reset1(self): def test_autoincrement_reset1(self):
p = Person.objects.create(first_name='Jack', last_name='Smith') 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', @unittest.skipIf(connection.vendor == 'oracle',
"Oracle's auto-increment fields are not reset between " "Oracle's auto-increment fields are not reset between "
"tests") "tests")
def test_autoincrement_reset2(self): def test_autoincrement_reset2(self):
p = Person.objects.create(first_name='Jack', last_name='Smith') p = Person.objects.create(first_name='Jack', last_name='Smith')
self.assertEquals(p.pk, 1) self.assertEqual(p.pk, 1)

View File

@ -100,12 +100,12 @@ class FeedgeneratorTest(unittest.TestCase):
def test_feed_without_feed_url_gets_rendered_without_atom_link(self): def test_feed_without_feed_url_gets_rendered_without_atom_link(self):
feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr') 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') feed_content = feed.writeString('utf-8')
self.assertNotIn('<atom:link href=', feed_content) self.assertNotIn('<atom:link href=', feed_content)
def test_feed_with_feed_url_gets_rendered_with_atom_link(self): def test_feed_with_feed_url_gets_rendered_with_atom_link(self):
feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr', feed_url='/feed/') feed = feedgenerator.Rss201rev2Feed('title', '/link/', 'descr', feed_url='/feed/')
self.assertEquals(feed.feed['feed_url'], '/feed/') self.assertEqual(feed.feed['feed_url'], '/feed/')
feed_content = feed.writeString('utf-8') feed_content = feed.writeString('utf-8')
self.assertIn('<atom:link href="/feed/" rel="self"></atom:link>', feed_content) self.assertIn('<atom:link href="/feed/" rel="self"></atom:link>', feed_content)