當前位置: 首頁>>代碼示例>>Python>>正文


Python Deck.iter_cards方法代碼示例

本文整理匯總了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)
開發者ID:denversc,項目名稱:cards,代碼行數:10,代碼來源:test_Deck.py

示例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)
開發者ID:denversc,項目名稱:cards,代碼行數:17,代碼來源:test_Deck.py

示例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)
開發者ID:denversc,項目名稱:cards,代碼行數:6,代碼來源:test_Deck.py

示例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)
開發者ID:denversc,項目名稱:cards,代碼行數:6,代碼來源:test_Deck.py

示例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)
開發者ID:denversc,項目名稱:cards,代碼行數:8,代碼來源:test_Deck.py

示例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)
開發者ID:denversc,項目名稱:cards,代碼行數:6,代碼來源:test_Deck.py


注:本文中的cards.Deck.iter_cards方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。