Use tuple() to test for generators. Thanks to otacon!

svn path=/plone.app.discussion/trunk/; revision=42096
This commit is contained in:
Timo Stollenwerk 2010-10-30 18:58:20 +00:00
parent cc96acb50a
commit 093eaa393a
2 changed files with 7 additions and 9 deletions

View File

@ -242,8 +242,7 @@ class TestCommentsViewlet(PloneTestCase):
conversation.addComment(comment)
conversation.addComment(comment)
replies = self.viewlet.get_replies()
self.assertEquals(sum(1 for w in replies), # pylint: disable-msg=W0612
2)
self.assertEquals(tuple(replies), 2)
replies = self.viewlet.get_replies()
replies.next()
replies.next()
@ -255,9 +254,8 @@ class TestCommentsViewlet(PloneTestCase):
comment.text = 'Comment text'
conversation = IConversation(self.portal.doc1)
c1 = conversation.addComment(comment)
self.assertEquals(sum(1 for w in # pylint: disable-msg=W0612
self.viewlet.get_replies(workflow_actions=True)),
1)
self.assertEquals(
tuple(self.viewlet.get_replies(workflow_actions=True)), 1)
# Enable moderation workflow
self.portal.portal_workflow.setChainForPortalTypes(
('Discussion Item',),

View File

@ -54,7 +54,7 @@ class ConversationTest(PloneTestCase):
aq_base(conversation))
self.assertEquals(new_id, comment.comment_id)
self.assertEquals(len(list(conversation.getComments())), 1)
self.assertEquals(sum(1 for w in conversation.getThreads()), 1)
self.assertEquals(tuple(conversation.getThreads()), 1)
self.assertEquals(conversation.total_comments, 1)
self.assert_(conversation.last_comment_date - datetime.utcnow() <
timedelta(seconds=1))
@ -75,7 +75,7 @@ class ConversationTest(PloneTestCase):
# make sure the comment has been added
self.assertEquals(len(list(conversation.getComments())), 1)
self.assertEquals(sum(1 for w in conversation.getThreads()), 1)
self.assertEquals(tuple(conversation.getThreads()), 1)
self.assertEquals(conversation.total_comments, 1)
# delete the comment we just created
@ -83,7 +83,7 @@ class ConversationTest(PloneTestCase):
# make sure there is no comment left in the conversation
self.assertEquals(len(list(conversation.getComments())), 0)
self.assertEquals(sum(1 for w in conversation.getThreads()), 0)
self.assertEquals(tuple(conversation.getThreads()), 0)
self.assertEquals(conversation.total_comments, 0)
def test_delete_recursive(self):
@ -165,7 +165,7 @@ class ConversationTest(PloneTestCase):
# Make sure the comment has been deleted as well
self.assertEquals(len(list(conversation.getComments())), 0)
self.assertEquals(sum(1 for w in conversation.getThreads()), 0)
self.assertEquals(tuple(conversation.getThreads()), 0)
self.assertEquals(conversation.total_comments, 0)
def test_allow_discussion(self):