Beispiel #1
0
def test_rules_full_house():
    cards = [
        poker.Card("C", 14),
        poker.Card("D", 14),
        poker.Card("S", 8),
        poker.Card("H", 14),
        poker.Card("D", 8),
    ]
    ruleset = poker.Rules(big_blind=10)
    house, rest, string = ruleset.x_of_a_kind(cards)

    assert all([house == cards, rest == [], string == "Full House"])
Beispiel #2
0
def test_rules_high_card():
    cards = [
        poker.Card("C", 14),
        poker.Card("C", 5),
        poker.Card("S", 10),
        poker.Card("H", 2),
        poker.Card("D", 8),
    ]
    ruleset = poker.Rules(big_blind=10)
    high_card = ruleset.high_card(cards)

    assert high_card == cards[0]
Beispiel #3
0
def test_rules_two_pair():
    cards = [
        poker.Card("C", 14),
        poker.Card("D", 14),
        poker.Card("S", 8),
        poker.Card("H", 10),
        poker.Card("D", 8),
    ]
    ruleset = poker.Rules(big_blind=10)
    twopair, rest, string = ruleset.x_of_a_kind(cards)

    assert all([
        twopair == [cards[0], cards[1], cards[2], cards[4]],
        rest == [cards[3]],
        string == "Two Pair",
    ])
Beispiel #4
0
def test_rules_four_of_a_kind():
    cards = [
        poker.Card("C", 14),
        poker.Card("D", 14),
        poker.Card("S", 14),
        poker.Card("H", 14),
        poker.Card("D", 8),
    ]
    ruleset = poker.Rules(big_blind=10)
    fours, rest, string = ruleset.x_of_a_kind(cards)

    assert all([
        fours == [cards[0], cards[1], cards[2], cards[3]],
        rest == [cards[4]],
        string == "Four of a Kind",
    ])
Beispiel #5
0
def test_rules_three_of_a_kind():
    cards = [
        poker.Card("C", 14),
        poker.Card("C", 5),
        poker.Card("S", 14),
        poker.Card("H", 14),
        poker.Card("D", 8),
    ]
    ruleset = poker.Rules(big_blind=10)
    threes, rest, string = ruleset.x_of_a_kind(cards)

    assert all([
        threes == [cards[0], cards[2], cards[3]],
        rest == [cards[1], cards[4]],
        string == "Three of a Kind",
    ])
Beispiel #6
0
def test_straight():
    cards = [
        poker.Card("H", 2),
        poker.Card("H", 14),
        poker.Card("S", 11),
        poker.Card("H", 12),
        poker.Card("S", 5),
        poker.Card("H", 10),
        poker.Card("C", 13),
    ]
    ruleset = poker.Rules(big_blind=10)
    straight, string = ruleset.straight(cards)

    assert all([
        straight == [cards[1], cards[6], cards[3], cards[2], cards[5]],
        string == "Straight! Ace to Ten",
    ])
Beispiel #7
0
def test_flush():
    cards = [
        poker.Card("H", 2),
        poker.Card("H", 14),
        poker.Card("S", 8),
        poker.Card("H", 7),
        poker.Card("H", 9),
        poker.Card("H", 11),
        poker.Card("H", 8),
    ]
    ruleset = poker.Rules(big_blind=10)
    flush, string = ruleset.flush(cards)

    assert all([
        flush == [cards[1], cards[5], cards[4], cards[6], cards[3]],
        string == "Flush! Ace high",
    ])