import pytest from pyjack.card import Card from pyjack.hand import Hand @pytest.fixture def default_hand(): my_hand = Hand() return my_hand def test_adding_card_to_hand(default_hand): default_hand.add_card(Card("diamonds", "2")) default_hand.add_card(Card("spades", "A")) assert default_hand.value == 13 assert len(default_hand.cards) == 2 def test_adjusting_for_ace(default_hand): """Tests if the value of an ace is adjusted if the hand holds 1 ace and two cards, making the value of the hand > 21""" # Creating a hand with a value pre adjustment of 31 cards = [Card("spades", "10"), Card("diamonds", "K"), Card("heart", "A")] for card in cards: default_hand.add_card(card) default_hand.adjust_for_aces() assert default_hand.value == 21 def testing_adjusting_for_multiple_aces(default_hand): """ "Testing if multiple aces a treated correctly, resulting in the hands value to be 12.""" # Creating a hand with a value pre adjustment of 32 cards = [Card("spades", "10"), Card("diamonds", "A"), Card("heart", "A")] for card in cards: default_hand.add_card(card) default_hand.adjust_for_aces() assert default_hand.value == 12