本文整理汇总了Python中cards.Deck.iter_cards方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.iter_cards方法的具体用法?Python Deck.iter_cards怎么用?Python Deck.iter_cards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cards.Deck
的用法示例。
在下文中一共展示了Deck.iter_cards方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_noargs
# 需要导入模块: from cards import Deck [as 别名]
# 或者: from cards.Deck import iter_cards [as 别名]
def test_noargs(self):
# if no args are given then the deck should be initialized to 52 cards
x = Deck()
self.assertEqual(len(x), 52)
expected_elements = list(Deck.iter_cards())
self.assertListEqual(x, expected_elements)
rlock_type = type(threading.RLock())
self.assertIs(type(x.lock), rlock_type)
示例2: test_values
# 需要导入模块: from cards import Deck [as 别名]
# 或者: from cards.Deck import iter_cards [as 别名]
def test_values(self):
suits_left = set([Card.SPADE, Card.HEART, Card.DIAMOND, Card.CLUB])
x = Deck.iter_cards()
while suits_left:
card = next(x)
self.assertIn(card.suit, suits_left)
suits_left.remove(card.suit)
expected_suit = card.suit
self.assertEqual(card.rank, 13)
for rank in (12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1):
card = next(x)
self.assertEqual(card.rank, rank)
self.assertEqual(card.suit, expected_suit)
with self.assertRaises(StopIteration):
next(x)
示例3: do_test_reset
# 需要导入模块: from cards import Deck [as 别名]
# 或者: from cards.Deck import iter_cards [as 别名]
def do_test_reset(self, deck):
deck.reset()
expected = list(Deck.iter_cards())
self.assertListEqual(deck, expected)
示例4: test_type
# 需要导入模块: from cards import Deck [as 别名]
# 或者: from cards.Deck import iter_cards [as 别名]
def test_type(self):
x = Deck.iter_cards()
for card in x:
self.assertIsInstance(card, Card)
示例5: test_count
# 需要导入模块: from cards import Deck [as 别名]
# 或者: from cards.Deck import iter_cards [as 别名]
def test_count(self):
x = Deck.iter_cards()
count = 0
for unused in x:
count += 1
self.assertEqual(count, 52)
示例6: test_next
# 需要导入模块: from cards import Deck [as 别名]
# 或者: from cards.Deck import iter_cards [as 别名]
def test_next(self):
x = Deck.iter_cards()
result = next(x) # make sure it is actually iterable
self.assertIsNotNone(result)