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