From afd040d4d3a06fe92e3080870b2ff2095ce86a75 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 3 Mar 2011 15:04:39 +0000 Subject: 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 --- .../comment_tests/tests/comment_form_tests.py | 6 +++--- .../comment_tests/tests/comment_utils_moderators_tests.py | 12 ++++++------ .../comment_tests/tests/comment_view_tests.py | 6 +++--- tests/regressiontests/comment_tests/tests/feed_tests.py | 4 ++-- .../comment_tests/tests/moderation_view_tests.py | 6 +++--- .../regressiontests/comment_tests/tests/templatetag_tests.py | 10 +++++----- 6 files changed, 22 insertions(+), 22 deletions(-) (limited to 'tests/regressiontests/comment_tests') diff --git a/tests/regressiontests/comment_tests/tests/comment_form_tests.py b/tests/regressiontests/comment_tests/tests/comment_form_tests.py index 5efa5c64a8..57dad3625c 100644 --- a/tests/regressiontests/comment_tests/tests/comment_form_tests.py +++ b/tests/regressiontests/comment_tests/tests/comment_form_tests.py @@ -20,7 +20,7 @@ class CommentFormTests(CommentTestCase): def testValidPost(self): a = Article.objects.get(pk=1) f = CommentForm(a, data=self.getValidData(a)) - self.assert_(f.is_valid(), f.errors) + self.assertTrue(f.is_valid(), f.errors) return f def tamperWithForm(self, **kwargs): @@ -65,12 +65,12 @@ class CommentFormTests(CommentTestCase): def testSecurityErrors(self): f = self.tamperWithForm(honeypot="I am a robot") - self.assert_("honeypot" in f.security_errors()) + self.assertTrue("honeypot" in f.security_errors()) def testGetCommentObject(self): f = self.testValidPost() c = f.get_comment_object() - self.assert_(isinstance(c, Comment)) + self.assertTrue(isinstance(c, Comment)) self.assertEqual(c.content_object, Article.objects.get(pk=1)) self.assertEqual(c.comment, "This is my comment") c.save() diff --git a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py index 9728490bc2..4177163f2a 100644 --- a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py +++ b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py @@ -65,29 +65,29 @@ class CommentUtilsModeratorTests(CommentTestCase): def testEmailNotification(self): moderator.register(Entry, EntryModerator1) self.createSomeComments() - self.assertEquals(len(mail.outbox), 2) + self.assertEqual(len(mail.outbox), 2) def testCommentsEnabled(self): moderator.register(Entry, EntryModerator2) self.createSomeComments() - self.assertEquals(Comment.objects.all().count(), 1) + self.assertEqual(Comment.objects.all().count(), 1) def testAutoCloseField(self): moderator.register(Entry, EntryModerator3) self.createSomeComments() - self.assertEquals(Comment.objects.all().count(), 0) + self.assertEqual(Comment.objects.all().count(), 0) def testAutoModerateField(self): moderator.register(Entry, EntryModerator4) c1, c2 = self.createSomeComments() - self.assertEquals(c2.is_public, False) + self.assertEqual(c2.is_public, False) def testAutoModerateFieldImmediate(self): moderator.register(Entry, EntryModerator5) c1, c2 = self.createSomeComments() - self.assertEquals(c2.is_public, False) + self.assertEqual(c2.is_public, False) def testAutoCloseFieldImmediate(self): moderator.register(Entry, EntryModerator6) c1, c2 = self.createSomeComments() - self.assertEquals(Comment.objects.all().count(), 0) \ No newline at end of file + self.assertEqual(Comment.objects.all().count(), 0) \ No newline at end of file diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py index 5e791966ae..e3f3bbeff7 100644 --- a/tests/regressiontests/comment_tests/tests/comment_view_tests.py +++ b/tests/regressiontests/comment_tests/tests/comment_view_tests.py @@ -155,7 +155,7 @@ class CommentViewTests(CommentTestCase): # callback def receive(sender, **kwargs): self.assertEqual(kwargs['comment'].comment, "This is my comment") - self.assert_('request' in kwargs) + self.assertTrue('request' in kwargs) received_signals.append(kwargs.get('signal')) # Connect signals and keep track of handled ones @@ -269,7 +269,7 @@ class CommentViewTests(CommentTestCase): response = self.client.post("/post/", data) location = response["Location"] match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+#baz$", location) - self.failUnless(match != None, "Unexpected redirect location: %s" % location) + self.assertTrue(match != None, "Unexpected redirect location: %s" % location) # Without a query string a = Article.objects.get(pk=1) @@ -279,4 +279,4 @@ class CommentViewTests(CommentTestCase): response = self.client.post("/post/", data) location = response["Location"] match = re.search(r"^http://testserver/somewhere/else/\?c=\d+#baz$", location) - self.failUnless(match != None, "Unexpected redirect location: %s" % location) + self.assertTrue(match != None, "Unexpected redirect location: %s" % location) diff --git a/tests/regressiontests/comment_tests/tests/feed_tests.py b/tests/regressiontests/comment_tests/tests/feed_tests.py index 0bc6618d9a..f385dcec5a 100644 --- a/tests/regressiontests/comment_tests/tests/feed_tests.py +++ b/tests/regressiontests/comment_tests/tests/feed_tests.py @@ -11,8 +11,8 @@ class CommentFeedTests(CommentTestCase): def test_feed(self): response = self.client.get(self.feed_url) - self.assertEquals(response.status_code, 200) - self.assertEquals(response['Content-Type'], 'application/rss+xml') + self.assertEqual(response.status_code, 200) + self.assertEqual(response['Content-Type'], 'application/rss+xml') self.assertContains(response, '') self.assertContains(response, 'example.com comments') self.assertContains(response, 'http://example.com/') diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py index e5094ab0cc..c9be06a340 100644 --- a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py +++ b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py @@ -182,14 +182,14 @@ class AdminActionsTests(CommentTestCase): comments = self.createSomeComments() self.client.login(username="normaluser", password="normaluser") response = self.client.get("/admin/comments/comment/") - self.assertEquals("approve_comments" in response.content, False) + self.assertEqual("approve_comments" in response.content, False) def testActionsModerator(self): comments = self.createSomeComments() makeModerator("normaluser") self.client.login(username="normaluser", password="normaluser") response = self.client.get("/admin/comments/comment/") - self.assertEquals("approve_comments" in response.content, True) + self.assertEqual("approve_comments" in response.content, True) def testActionsDisabledDelete(self): "Tests a CommentAdmin where 'delete_selected' has been disabled." @@ -197,7 +197,7 @@ class AdminActionsTests(CommentTestCase): self.client.login(username="normaluser", password="normaluser") response = self.client.get('/admin2/comments/comment/') self.assertEqual(response.status_code, 200) - self.assert_( + self.assertTrue( '