def test_lead_when_card_is_missing(): card_list = [ Deck.generate_card_from_index(card_index) for card_index in test_list ] hand = BridgeHand.generate_partially_played_hand(card_list) with pytest.raises(CardNotInHandException): hand.lead(Card(Suits.SPADES, Ranks.ACE))
def test_legal_cards(): card_list = [ Deck.generate_card_from_index(card_index) for card_index in test_list ] hand = BridgeHand.generate_partially_played_hand(card_list) legal = hand.legal_cards(Suits.DIAMONDS) assert Card(Suits.DIAMONDS, Ranks.ACE) in legal
def test_lead(): card_list = [ Deck.generate_card_from_index(card_index) for card_index in test_list ] hand = BridgeHand.generate_partially_played_hand(card_list) hand.lead(Card(Suits.DIAMONDS, Ranks.KING)) assert not hand.contains_card(Card(Suits.DIAMONDS, Ranks.KING))
def test_follow_raises(led_suit, card, expected_except): card_list = [ Deck.generate_card_from_index(card_index) for card_index in test_list ] hand = BridgeHand.generate_partially_played_hand(card_list) with expected_except: hand.follow(led_suit, card)
def test_follow(led_suit, card): card_list = [ Deck.generate_card_from_index(card_index) for card_index in test_list ] hand = BridgeHand.generate_partially_played_hand(card_list) hand.follow(led_suit, card) assert not hand.contains_card(card)
def test_partial_hand_fill_and_contains(suit, rank, expected): card_list = [ Deck.generate_card_from_index(card_index) for card_index in test_list ] hand = BridgeHand.generate_partially_played_hand(card_list) assert hand.contains_card(Card(suit, rank)) == expected
def test_bridge_hand_constructor(list, expected_except): card_list = [ Deck.generate_card_from_index(card_index) for card_index in list ] with expected_except: bridge_hand = BridgeHand(card_list)
def test_generate_hand(list, expected_except): card_list = [ Deck.generate_card_from_index(card_index) for card_index in list ] with expected_except: hand = BridgeHand.generate_complete_hand(card_list)