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


Python Monster.score方法代码示例

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


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

示例1: ScoreTest

# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import score [as 别名]
class ScoreTest(unittest.TestCase):
    """Test the functionality of the Monster class score function."""

    def setUp(self):
        self.new_monster = Monster("Cookie")

    def tearDown(self):
        del self.new_monster

    def test_score_no_win(self):
        """
        Initialize health to 1. Call function with 7 and check that 7 is
        returned and status is unchanged.
        """

        self.new_monster.health = 1
        original_status = self.new_monster.status

        # Call function
        victory_points = self.new_monster.score(7)

        self.assertEqual(victory_points, 7,
                         "Expected t for victory points.")
        self.assertEqual(self.new_monster.status, original_status,
                         "Status should have remained {}".
                         format(original_status))

    def test_score_winning(self):
        """
        Initialize health to 16. Call function with 7 and check that 7 is
        returned and status is 'WINNING'.
        """

        self.new_monster.health = 16

        # Call function
        victory_points = self.new_monster.score(7)

        self.assertEqual(victory_points, 7,
                         "Expected t for victory points.")
        self.assertEqual(self.new_monster.status, "WINNING",
                         "Status should be 'WINNING'")
开发者ID:PDXDevCampJuly,项目名称:atifar,代码行数:44,代码来源:test_score.py


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