Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated deprecated test assertions

  • Loading branch information...
commit 34ee7d9875d26809b0a2c6115edee0a35be0d17d 1 parent 23ca3a0
Claude Paroz authored January 08, 2013
4  django/contrib/auth/tests/management.py
@@ -186,7 +186,7 @@ def test_duplicated_permissions(self):
186 186
         # check duplicated default permission
187 187
         models.Permission._meta.permissions = [
188 188
            ('change_permission', 'Can edit permission (duplicate)')]
189  
-        self.assertRaisesRegexp(CommandError,
  189
+        six.assertRaisesRegex(self, CommandError,
190 190
             "The permission codename 'change_permission' clashes with a "
191 191
             "builtin permission for model 'auth.Permission'.",
192 192
             create_permissions, models, [], verbosity=0)
@@ -197,7 +197,7 @@ def test_duplicated_permissions(self):
197 197
             ('other_one', 'Some other permission'),
198 198
             ('my_custom_permission', 'Some permission with duplicate permission code'),
199 199
         ]
200  
-        self.assertRaisesRegexp(CommandError,
  200
+        six.assertRaisesRegex(self, CommandError,
201 201
             "The permission codename 'my_custom_permission' is duplicated for model "
202 202
             "'auth.Permission'.",
203 203
             create_permissions, models, [], verbosity=0)
6  tests/modeltests/basic/tests.py
@@ -141,21 +141,21 @@ def test_lookup(self):
141 141
 
142 142
         # Django raises an Article.MultipleObjectsReturned exception if the
143 143
         # lookup matches more than one object
144  
-        self.assertRaisesRegexp(
  144
+        six.assertRaisesRegex(self,
145 145
             MultipleObjectsReturned,
146 146
             "get\(\) returned more than one Article -- it returned 2!",
147 147
             Article.objects.get,
148 148
             headline__startswith='Area',
149 149
         )
150 150
 
151  
-        self.assertRaisesRegexp(
  151
+        six.assertRaisesRegex(self,
152 152
             MultipleObjectsReturned,
153 153
             "get\(\) returned more than one Article -- it returned 2!",
154 154
             Article.objects.get,
155 155
             pub_date__year=2005,
156 156
         )
157 157
 
158  
-        self.assertRaisesRegexp(
  158
+        six.assertRaisesRegex(self,
159 159
             MultipleObjectsReturned,
160 160
             "get\(\) returned more than one Article -- it returned 2!",
161 161
             Article.objects.get,
2  tests/modeltests/str/tests.py
@@ -28,7 +28,7 @@ def test_broken(self):
28 28
             headline='Girl wins €12.500 in lottery',
29 29
             pub_date=datetime.datetime(2005, 7, 28)
30 30
         )
31  
-        self.assertRaisesRegexp(RuntimeError, "Did you apply "
  31
+        six.assertRaisesRegex(self, RuntimeError, "Did you apply "
32 32
             "@python_2_unicode_compatible without defining __str__\?", str, a)
33 33
 
34 34
     def test_international(self):
2  tests/regressiontests/backends/tests.py
@@ -42,7 +42,7 @@ def test_quote_name(self):
42 42
         # Check that '%' chars are escaped for query execution.
43 43
         name = '"SOME%NAME"'
44 44
         quoted_name = connection.ops.quote_name(name)
45  
-        self.assertEquals(quoted_name % (), name)
  45
+        self.assertEqual(quoted_name % (), name)
46 46
 
47 47
     @unittest.skipUnless(connection.vendor == 'oracle',
48 48
                          "No need to check Oracle cursor semantics")
12  tests/regressiontests/queries/tests.py
@@ -1293,9 +1293,9 @@ def test_combine_join_reuse(self):
1293 1293
         q1 = Author.objects.filter(report__name='r5')
1294 1294
         q2 = Author.objects.filter(report__name='r4').filter(report__name='r1')
1295 1295
         combined = q1|q2
1296  
-        self.assertEquals(str(combined.query).count('JOIN'), 2)
1297  
-        self.assertEquals(len(combined), 1)
1298  
-        self.assertEquals(combined[0].name, 'a1')
  1296
+        self.assertEqual(str(combined.query).count('JOIN'), 2)
  1297
+        self.assertEqual(len(combined), 1)
  1298
+        self.assertEqual(combined[0].name, 'a1')
1299 1299
 
1300 1300
     def test_ticket7095(self):
1301 1301
         # Updates that are filtered on the model being updated are somewhat
@@ -1644,8 +1644,8 @@ def test_join_already_in_query(self):
1644 1644
         # and that join must be LEFT join. The already existing join to related
1645 1645
         # objects must be kept INNER. So, we have both a INNER and a LEFT join
1646 1646
         # in the query.
1647  
-        self.assertEquals(str(qs.query).count('LEFT'), 1)
1648  
-        self.assertEquals(str(qs.query).count('INNER'), 1)
  1647
+        self.assertEqual(str(qs.query).count('LEFT'), 1)
  1648
+        self.assertEqual(str(qs.query).count('INNER'), 1)
1649 1649
         self.assertQuerysetEqual(
1650 1650
             qs,
1651 1651
             ['<Plaything: p2>']
@@ -2452,7 +2452,7 @@ def test_reverse_trimming(self):
2452 2452
         t = Tag.objects.create()
2453 2453
         qs = Tag.objects.filter(annotation__tag=t.pk)
2454 2454
         self.assertIn('INNER JOIN', str(qs.query))
2455  
-        self.assertEquals(list(qs), [])
  2455
+        self.assertEqual(list(qs), [])
2456 2456
 
2457 2457
 class JoinReuseTest(TestCase):
2458 2458
     """
10  tests/regressiontests/select_related_onetoone/tests.py
@@ -183,11 +183,11 @@ def test_inheritance_deferred(self):
@@ -202,9 +202,9 @@ def test_inheritance_deferred2(self):
4  tests/regressiontests/templates/tests.py
@@ -370,13 +370,13 @@ def test_url_explicit_exception_for_old_syntax_at_run_time(self):
370 370
         # Regression test for #19280
371 371
         t = Template('{% url path.to.view %}')      # not quoted = old syntax
372 372
         c = Context()
373  
-        with self.assertRaisesRegexp(urlresolvers.NoReverseMatch,
  373
+        with six.assertRaisesRegex(self, urlresolvers.NoReverseMatch,
374 374
                 "The syntax changed in Django 1.5, see the docs."):
375 375
             t.render(c)
376 376
 
377 377
     def test_url_explicit_exception_for_old_syntax_at_compile_time(self):
378 378
         # Regression test for #19392
379  
-        with self.assertRaisesRegexp(template.TemplateSyntaxError,
  379
+        with six.assertRaisesRegex(self, template.TemplateSyntaxError,
380 380
                 "The syntax of 'url' changed in Django 1.5, see the docs."):
381 381
             t = Template('{% url my-view %}')      # not a variable = old syntax
382 382
 

0 notes on commit 34ee7d9

Please sign in to comment.
Something went wrong with that request. Please try again.