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


Python Monster.health方法代码示例

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


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

示例1: test_attack

# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import health [as 别名]
class test_attack(unittest.TestCase):
    def setUp(self):
        self.monsta = Monster()
        print(self.shortDescription())

    #Tests if heal function works
    def test_attack_live(self):
        self.monsta.health = 6
        expected = 1
        actual = self.monsta.attack(5)
        self.assertEqual(expected, actual)

    #Heal function should not work if total > 10
    def test_attack_die(self):
        self.monsta.health = 4
        expected = -1
        actual = self.monsta.attack(5)
        self.assertEqual(expected, actual)

    #Tests if invalid output was printed
    @patch ('sys.stdout', new_callable=StringIO)
    def test_attack_die_KO(self, mock_stdout):
        health = self.monsta.health(4)

        expected = "K.O.'d"
        actual = self.monsta.attack(6)
        self.assertNotEqual(mock_stdout.getValue(), text)
开发者ID:PDXDevCampJuly,项目名称:daniel_pearl,代码行数:29,代码来源:test_attack.py

示例2: test_reset

# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import health [as 别名]
    def test_reset(self):
        """Set status to "Oops", health to -200 and victory_points to 90 on
        a Monster class object, new_monster. Call reset() then check that
        new_monster's status, health and victory_points attributes were
        restored to their initial values."""

        new_monster = Monster("Cookie")
        new_monster.status = "Oops"
        new_monster.health = -200
        new_monster.victory_points = 90
        new_monster.reset()
        self.assertEqual(new_monster.status, "Out of Tokyo")
        self.assertEqual(new_monster.health, 10)
        self.assertEqual(new_monster.victory_points, 0)

        del new_monster
开发者ID:TheOneTAR,项目名称:atifar,代码行数:18,代码来源:test_reset.py


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