本文整理匯總了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)