当前位置: 首页>>代码示例>>Python>>正文


Python Team.nextSnailTurn方法代码示例

本文整理汇总了Python中team.Team.nextSnailTurn方法的典型用法代码示例。如果您正苦于以下问题:Python Team.nextSnailTurn方法的具体用法?Python Team.nextSnailTurn怎么用?Python Team.nextSnailTurn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在team.Team的用法示例。


在下文中一共展示了Team.nextSnailTurn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestTeam

# 需要导入模块: from team import Team [as 别名]
# 或者: from team.Team import nextSnailTurn [as 别名]
class TestTeam(unittest.TestCase):
    """
    A test class for the Team module.
    """

    def setUp(self):
        """
        set up data used in the tests.
        setUp is called before each test function execution.
        """        
        self.maxSnails = 3
        self.team1 = Team("team1")
        self.team2 = Team("team2")
        self.team1.setGravity(Direction.UP)
        self.team2.setGravity(Direction.DOWN)
        
    def testInitialized(self):
        """
        Test if init goes good
        """
        self.assertEqual(self.team1.name, "team1")
        self.assertEqual(self.team1.hasTurn, False)
    
    def testAddSnails(self):
        self.team1.addSnails(self.maxSnails)
        self.assertEquals(self.team1.currentSnailWithTurn, self.team1.orderedSnailList[0])
        self.assertEqual(len(self.team1.sprites()), self.maxSnails)
        self.assertEqual(len(self.team1.orderedSnailList), self.maxSnails)
        self.assertEqual(self.team1.orderedSnailList[0].hasTurn, True)
        for i in range(0, len(self.team1.orderedSnailList)):
            if i == 0:
                self.assertEqual(self.team1.orderedSnailList[i].hasTurn, True)
            else:
                self.assertEqual(self.team1.orderedSnailList[i].hasTurn, False)
        
    def testNextSnailTurn(self):
        """
        Test if the next time get's the turn
        """
        # test if the currentSnailTurn is 0
        self.team1.addSnails(self.maxSnails)
        
        # Check when all the snails had the turn, if the first snail gets turn again
        for i in range(0, self.maxSnails):
            print i
            self.assertEqual(self.team1.orderedSnailList[i].hasTurn, True)
            self.team1.nextSnailTurn()
            self.assertEqual(self.team1.orderedSnailList[i].hasTurn, False)
            
            
        # check if the first snail in the list has the turn again
        self.assertEqual(self.team1.orderedSnailList[0].hasTurn, True)
开发者ID:ryuken,项目名称:gravity-snails,代码行数:54,代码来源:unittest_team.py


注:本文中的team.Team.nextSnailTurn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。