コード例 #1
0
 def test_string_arguments():
     """" Test creation of a hand by string arguments. """
     reference = bluff.Hand(
         bluff.Card("Ad"),
         bluff.Card("Ks"),
         bluff.Card("Tc"),
         bluff.Card("6c"),
         bluff.Card("2h"),
     )
     alternatives = [
         bluff.Hand("Ad", "Ks", "Tc", "6c", "2h"),
         bluff.Hand("AdKsTc6c2h"),
         bluff.Hand("Ad Ks Tc 6c 2h"),
         bluff.Hand("Ad, Ks, Tc, 6c, 2h"),
         bluff.Hand("Ad,Ks,Tc,6c,2h"),
     ]
     for alt in alternatives:
         assert reference.value == alt.value
コード例 #2
0
 def test_place_card_in_btm_hand():
     """ Test placing a card in the bottom hand. """
     player = chinese.Player(name="Dan Harrington", points=574)
     player.place_card(card=bluff.Card("As"), hand="bottom")
     assert len(player.bottom_hand) == 1
コード例 #3
0
 def test_place_card_in_mid_hand():
     """ Test placing a card in the mid hand. """
     player = chinese.Player(name="Sam Farha", points=999)
     player.place_card(card=bluff.Card("As"), hand="middle")
     assert len(player.middle_hand) == 1
コード例 #4
0
 def test_place_card_in_top_hand():
     """ Test placing a card in the top hand. """
     player = chinese.Player(name="Chris Moneymaker", points=2344)
     player.place_card(card=bluff.Card("As"), hand="top")
     assert len(player.top_hand) == 1
コード例 #5
0
 def test_repr(self):
     """ Test class' __repr__. """
     for rank, suit in itertools.product(self.RANKS, self.SUITS):
         assert rank + suit == repr(bluff.Card(rank + suit))
コード例 #6
0
 def test_suit_value_error():
     """ "Test if invalid suits raise exceptions. """
     invalid_suits = ("spades", "hearts", "clubs", "diamonds", "x", "y", "z")
     for suit in invalid_suits:
         with pytest.raises(ValueError):
             bluff.Card(f"A{suit}")
コード例 #7
0
 def test_rank_value_error():
     """ Test if invalid ranks raise exceptions. """
     invalid_ranks = ("0", "1", "10")
     for rank in invalid_ranks:
         with pytest.raises(ValueError):
             bluff.Card(f"{rank}s")
コード例 #8
0
 def test_all_suits(self):
     """ test if all suits are recognized."""
     for suit in self.SUITS:
         card = bluff.Card(f"A{suit}")
         assert card.suit == suit
コード例 #9
0
 def test_numerical_rank(self):
     """ Test if ranks are converted to numerical ranks correctly. """
     numerical_ranks = range(2, 15)
     for rank, numerical_rank in zip(self.RANKS, numerical_ranks):
         card = bluff.Card(f"{rank}s")
         assert card.numerical_rank == numerical_rank
コード例 #10
0
 def test_all_ranks(self):
     """ Test if all ranks are recognized. """
     for rank in self.RANKS:
         card = bluff.Card(f"{rank}s")
         assert card.rank == rank
コード例 #11
0
 def test_case_rank():
     """ Test lower and upper case ranks. """
     lowercase_card = bluff.Card("As")
     uppercase_card = bluff.Card("as")
     assert lowercase_card.rank == uppercase_card.rank
コード例 #12
0
 def test_case_suit():
     """ Test lower and upper case suits. """
     lowercase_card = bluff.Card("As")
     uppercase_card = bluff.Card("AS")
     assert lowercase_card.suit == uppercase_card.suit