def test_split_hand(monkeypatch):
    interface = blackjack_game.BlackJackCLI()
    game = blackjack_game.BlackJackGame(1)
    player = game.players[0]
    player.money = 50
    splittable_hand = Hand(20)
    splittable_hand.cards = [Card(3, 3), Card(3, 1)]
    player.hands = [splittable_hand]
    interface.game = game

    monkeypatch.setattr(interface, "print_board", Mock())
    # Have the player split the hand, then stand on each split hand
    monkeypatch.setattr(
        blackjack_game,
        "get_user_string_input",
        Mock(side_effect=["split", "stand", "stand"]),
    )
    monkeypatch.setattr(
        game._deck, "get_next_card", Mock(side_effect=[Card(5, 1), Card(9, 0)])
    )
    interface.player_turn(player)

    assert player.money == 30
    assert len(player.hands) == 2
    assert str(player.hands[0]) == "3♦, 5♠"
    assert str(player.hands[1]) == "3♠, 9♥"
예제 #2
0
 def test_add_card_to_hand(self):
     hand = Hand(self.test_cards)
     hand.cards = hand.cards + self.test_card
     self.assertEqual(len(hand.cards),
                      len(self.test_cards + self.test_card))