Exemple #1
0
def test_clear_hand():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    print(test_hand.cards)
    test_hand.clear_hand()
    print(test_hand.cards)
    assert test_hand.cards == []
Exemple #2
0
def test_add_cards2():
    """Next 5 tests are checking aces are handled correctly"""
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 21
    assert test_hand.aces == 1
Exemple #3
0
def test_add_cards5():
    test_hand = cards.Hand()

    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()

    test_hand.add_cards(cards.Card("Clubs", "Ace"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 12
    assert test_hand.aces == 1
Exemple #4
0
def test_add_cards3():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 19
    assert test_hand.aces == 0
Exemple #5
0
def test_card_string():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    assert test_hand.hand_held() == "King of Diamonds"
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    assert test_hand.hand_held() == "King of Diamonds, and the Ace of Hearts"
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()
    assert (
        test_hand.hand_held()
        == "King of Diamonds, Ace of Hearts, and the Eight of Spades"
    )
Exemple #6
0
def test_holding():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()
    assert test_hand.holding() == [
        ("Diamonds", "King"),
        ("Hearts", "Ace"),
        ("Spades", "Eight"),
    ]
    assert test_hand.cards[0].rank == "King"
Exemple #7
0
def test_add_cards1():
    """Adding cards to hand gives correct hand value"""
    test_hand = cards.Hand()

    test_hand.add_cards(cards.Card("Diamonds", "King"))
    assert test_hand.value == 10
    assert test_hand.aces == 0
Exemple #8
0
def fake_card():
    fake_card = cards.Card("Diamonds", "King")
    return fake_card
Exemple #9
0
def test_card():
    """Simple test for card object"""
    test_card = cards.Card("Diamonds", "King")
    assert test_card.suit == "Diamonds"
    assert test_card.rank == "King"