From 34ee7d9875d26809b0a2c6115edee0a35be0d17d Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 8 Jan 2013 19:07:12 +0100 Subject: [PATCH] Updated deprecated test assertions --- django/contrib/auth/tests/management.py | 4 ++-- tests/modeltests/basic/tests.py | 6 +++--- tests/modeltests/str/tests.py | 2 +- tests/regressiontests/backends/tests.py | 2 +- tests/regressiontests/queries/tests.py | 12 ++++++------ .../regressiontests/select_related_onetoone/tests.py | 10 +++++----- tests/regressiontests/templates/tests.py | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/django/contrib/auth/tests/management.py b/django/contrib/auth/tests/management.py index 976c0c4972..02939e39dc 100644 --- a/django/contrib/auth/tests/management.py +++ b/django/contrib/auth/tests/management.py @@ -186,7 +186,7 @@ class PermissionDuplicationTestCase(TestCase): # check duplicated default permission models.Permission._meta.permissions = [ ('change_permission', 'Can edit permission (duplicate)')] - self.assertRaisesRegexp(CommandError, + six.assertRaisesRegex(self, CommandError, "The permission codename 'change_permission' clashes with a " "builtin permission for model 'auth.Permission'.", create_permissions, models, [], verbosity=0) @@ -197,7 +197,7 @@ class PermissionDuplicationTestCase(TestCase): ('other_one', 'Some other permission'), ('my_custom_permission', 'Some permission with duplicate permission code'), ] - self.assertRaisesRegexp(CommandError, + six.assertRaisesRegex(self, CommandError, "The permission codename 'my_custom_permission' is duplicated for model " "'auth.Permission'.", create_permissions, models, [], verbosity=0) diff --git a/tests/modeltests/basic/tests.py b/tests/modeltests/basic/tests.py index 42375ceed9..1ca4f20dac 100644 --- a/tests/modeltests/basic/tests.py +++ b/tests/modeltests/basic/tests.py @@ -141,21 +141,21 @@ class ModelTest(TestCase): # Django raises an Article.MultipleObjectsReturned exception if the # lookup matches more than one object - self.assertRaisesRegexp( + six.assertRaisesRegex(self, MultipleObjectsReturned, "get\(\) returned more than one Article -- it returned 2!", Article.objects.get, headline__startswith='Area', ) - self.assertRaisesRegexp( + six.assertRaisesRegex(self, MultipleObjectsReturned, "get\(\) returned more than one Article -- it returned 2!", Article.objects.get, pub_date__year=2005, ) - self.assertRaisesRegexp( + six.assertRaisesRegex(self, MultipleObjectsReturned, "get\(\) returned more than one Article -- it returned 2!", Article.objects.get, diff --git a/tests/modeltests/str/tests.py b/tests/modeltests/str/tests.py index 31869583aa..bd85c48d05 100644 --- a/tests/modeltests/str/tests.py +++ b/tests/modeltests/str/tests.py @@ -28,7 +28,7 @@ class SimpleTests(TestCase): headline='Girl wins €12.500 in lottery', pub_date=datetime.datetime(2005, 7, 28) ) - self.assertRaisesRegexp(RuntimeError, "Did you apply " + six.assertRaisesRegex(self, RuntimeError, "Did you apply " "@python_2_unicode_compatible without defining __str__\?", str, a) def test_international(self): diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py index 934c37d147..791f4c1daa 100644 --- a/tests/regressiontests/backends/tests.py +++ b/tests/regressiontests/backends/tests.py @@ -42,7 +42,7 @@ class OracleChecks(unittest.TestCase): # Check that '%' chars are escaped for query execution. name = '"SOME%NAME"' quoted_name = connection.ops.quote_name(name) - self.assertEquals(quoted_name % (), name) + self.assertEqual(quoted_name % (), name) @unittest.skipUnless(connection.vendor == 'oracle', "No need to check Oracle cursor semantics") diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py index 780af5a8b7..4adf07657c 100644 --- a/tests/regressiontests/queries/tests.py +++ b/tests/regressiontests/queries/tests.py @@ -1293,9 +1293,9 @@ class Queries4Tests(BaseQuerysetTest): q1 = Author.objects.filter(report__name='r5') q2 = Author.objects.filter(report__name='r4').filter(report__name='r1') combined = q1|q2 - self.assertEquals(str(combined.query).count('JOIN'), 2) - self.assertEquals(len(combined), 1) - self.assertEquals(combined[0].name, 'a1') + self.assertEqual(str(combined.query).count('JOIN'), 2) + self.assertEqual(len(combined), 1) + self.assertEqual(combined[0].name, 'a1') def test_ticket7095(self): # Updates that are filtered on the model being updated are somewhat @@ -1644,8 +1644,8 @@ class NullableRelOrderingTests(TestCase): # and that join must be LEFT join. The already existing join to related # objects must be kept INNER. So, we have both a INNER and a LEFT join # in the query. - self.assertEquals(str(qs.query).count('LEFT'), 1) - self.assertEquals(str(qs.query).count('INNER'), 1) + self.assertEqual(str(qs.query).count('LEFT'), 1) + self.assertEqual(str(qs.query).count('INNER'), 1) self.assertQuerysetEqual( qs, [''] @@ -2452,7 +2452,7 @@ class ReverseJoinTrimmingTest(TestCase): t = Tag.objects.create() qs = Tag.objects.filter(annotation__tag=t.pk) self.assertIn('INNER JOIN', str(qs.query)) - self.assertEquals(list(qs), []) + self.assertEqual(list(qs), []) class JoinReuseTest(TestCase): """ diff --git a/tests/regressiontests/select_related_onetoone/tests.py b/tests/regressiontests/select_related_onetoone/tests.py index d4a1275e49..fce8fc4e73 100644 --- a/tests/regressiontests/select_related_onetoone/tests.py +++ b/tests/regressiontests/select_related_onetoone/tests.py @@ -183,11 +183,11 @@ class ReverseSelectRelatedTestCase(TestCase): p = Parent2.objects.select_related('child1').only( 'id2', 'child1__value').get(name2="n2") with self.assertNumQueries(1): - self.assertEquals(p.name2, 'n2') + self.assertEqual(p.name2, 'n2') p = Parent2.objects.select_related('child1').only( 'id2', 'child1__value').get(name2="n2") with self.assertNumQueries(1): - self.assertEquals(p.child1.name2, 'n2') + self.assertEqual(p.child1.name2, 'n2') @unittest.expectedFailure def test_inheritance_deferred2(self): @@ -202,9 +202,9 @@ class ReverseSelectRelatedTestCase(TestCase): self.assertEqual(p.child1.child4.id2, c.id2) p = qs.get(name2="n2") with self.assertNumQueries(1): - self.assertEquals(p.child1.name2, 'n2') + self.assertEqual(p.child1.name2, 'n2') p = qs.get(name2="n2") with self.assertNumQueries(1): - self.assertEquals(p.child1.name1, 'n1') + self.assertEqual(p.child1.name1, 'n1') with self.assertNumQueries(1): - self.assertEquals(p.child1.child4.name1, 'n1') + self.assertEqual(p.child1.child4.name1, 'n1') diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index d21434a12e..8d2a45b8fc 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -370,13 +370,13 @@ class Templates(TestCase): # Regression test for #19280 t = Template('{% url path.to.view %}') # not quoted = old syntax c = Context() - with self.assertRaisesRegexp(urlresolvers.NoReverseMatch, + with six.assertRaisesRegex(self, urlresolvers.NoReverseMatch, "The syntax changed in Django 1.5, see the docs."): t.render(c) def test_url_explicit_exception_for_old_syntax_at_compile_time(self): # Regression test for #19392 - with self.assertRaisesRegexp(template.TemplateSyntaxError, + with six.assertRaisesRegex(self, template.TemplateSyntaxError, "The syntax of 'url' changed in Django 1.5, see the docs."): t = Template('{% url my-view %}') # not a variable = old syntax