本文整理汇总了Python中card.Card.value方法的典型用法代码示例。如果您正苦于以下问题:Python Card.value方法的具体用法?Python Card.value怎么用?Python Card.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类card.Card
的用法示例。
在下文中一共展示了Card.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_value_setter
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import value [as 别名]
def test_value_setter(self):
normal_card = Card(6, "hearts")
self.assertEqual(normal_card.value, '6')
self.assertEqual(normal_card.index, 6)
normal_card.value = 10
self.assertEqual(normal_card.value, '10')
self.assertEqual(normal_card.index, 10)
normal_card.value = 'J'
self.assertEqual(normal_card.value, 'J')
self.assertEqual(normal_card.index, Card.JACK_INDEX)
normal_card.value = '4'
self.assertEqual(normal_card.value, '4')
self.assertEqual(normal_card.index, 4)
示例2: test_value_setter_invalid
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import value [as 别名]
def test_value_setter_invalid(self):
invalid_values = ['Kings', 'Jack', 'Queen', '0', -1, 0, 14, random.randint(15,100), random.randint(-100, -1)]
for value in invalid_values:
card = Card(3, "diamonds")
try:
card.value = value
self.assert_(False)
except ValueError as e:
self.assert_(isinstance(e, ValueError))