本文整理汇总了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)
示例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