summaryrefslogtreecommitdiff
path: root/tests/modeltests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-03-03 15:04:39 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-03-03 15:04:39 +0000
commitafd040d4d3a06fe92e3080870b2ff2095ce86a75 (patch)
treebda969614999a3fcfbf1466caa0d75e512dd1374 /tests/modeltests
parentb7c41c1fbb2d45634dde5f7a450ba1a5aea5a8af (diff)
Updated test assertions that have been deprecated by the move to unittest2. In summary, this means:
assert_ -> assertTrue assertEquals -> assertEqual failUnless -> assertTrue For full details, see http://www.voidspace.org.uk/python/articles/unittest2.shtml#deprecations git-svn-id: http://code.djangoproject.com/svn/django/trunk@15728 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests')
-rw-r--r--tests/modeltests/aggregation/tests.py2
-rw-r--r--tests/modeltests/model_formsets/tests.py2
-rw-r--r--tests/modeltests/model_inheritance_same_model_name/tests.py4
-rw-r--r--tests/modeltests/proxy_model_inheritance/tests.py4
-rw-r--r--tests/modeltests/raw_query/tests.py10
-rw-r--r--tests/modeltests/serializers/tests.py2
-rw-r--r--tests/modeltests/test_client/models.py6
-rw-r--r--tests/modeltests/unmanaged_models/tests.py4
-rw-r--r--tests/modeltests/user_commands/tests.py4
-rw-r--r--tests/modeltests/validation/__init__.py4
-rw-r--r--tests/modeltests/validators/tests.py12
11 files changed, 27 insertions, 27 deletions
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: