本文整理汇总了Python中monster.Monster.in_tokyo方法的典型用法代码示例。如果您正苦于以下问题:Python Monster.in_tokyo方法的具体用法?Python Monster.in_tokyo怎么用?Python Monster.in_tokyo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monster.Monster
的用法示例。
在下文中一共展示了Monster.in_tokyo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InTokyoTest
# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import in_tokyo [as 别名]
class InTokyoTest(unittest.TestCase):
"""Test the functionality of the Monster class in_tokyo function."""
def setUp(self):
self.new_monster = Monster("Cookie")
def tearDown(self):
del self.new_monster
def test_in_tokyo_yes(self):
"""Set status to "In Tokyo" on a Monster class object, new_monster.
Check that in_tokyo() returns True."""
self.new_monster.status = "In Tokyo"
self.assertEqual(self.new_monster.in_tokyo(), True)
def test_in_tokyo_no(self):
"""Set status to "" on a Monster class object, new_monster.
Check that in_tokyo() returns False."""
self.new_monster.status = ""
self.assertEqual(self.new_monster.in_tokyo(), False)
def test_in_tokyo_invalid(self):
"""Set status to -78.3 on a Monster class object, new_monster.
Check that in_tokyo() returns False."""
self.new_monster.status = -78.3
self.assertEqual(self.new_monster.in_tokyo(), False)
示例2: test_in_tokyo
# 需要导入模块: from monster import Monster [as 别名]
# 或者: from monster.Monster import in_tokyo [as 别名]
class test_in_tokyo(unittest.TestCase):
#Defines status
def setUp(self):
self.monsta = Monster()
self.monsta.status = "In Tokyo"
#Tests if monster shows up in Tokyo
def test_in_toyko_true(self):
tokyo = self.monsta.in_tokyo()
self.assertTrue(tokyo, "Monster not showing up in Tokyo")
#Tests if monster does not show up in Tokyo
def test_in_tokyo_false(self):
self.monsta.status = "Out of Tokyo"
tokyo = self.monsta.in_tokyo()
self.assertFalse(tokyo,"Monster is showing up in Tokyo")