当前位置: 首页>>代码示例>>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;未经允许,请勿转载。