Пример #1
0
def test_is_suited():
    assert Combo('AdKd').is_suited is True
Пример #2
0
import pytest
from poker.card import Suit, Card
from poker.hand import Hand, Combo, Range, PAIR_HANDS


# from worse to best (suit matter)
DEUCE_COMBOS = (
    Combo("2d2c"),
    Combo("2h2c"),
    Combo("2h2d"),
    Combo("2s2c"),
    Combo("2s2d"),
    Combo("2s2h"),
)

THREE_COMBOS = (
    Combo("3d3c"),
    Combo("3h3c"),
    Combo("3h3d"),
    Combo("3s3c"),
    Combo("3s3d"),
    Combo("3s3h"),
)

# from worse to best (suit matter)
TEN_COMBOs = (
    Combo("TdTc"),
    Combo("ThTc"),
    Combo("ThTd"),
    Combo("TsTc"),
    Combo("TsTd"),
Пример #3
0
def test_equal_pairs_are_not_less():
    assert (Combo('2s2c') < Combo('2s2c')) is False
    assert (Combo('2s2c') > Combo('2s2c')) is False
Пример #4
0
def test_repr():
    assert unicode(Combo('2s2c')) == '2♠2♣'
    assert unicode(Combo('KhAs')) == 'A♠K♥'
    assert unicode(Combo('ThTd')) == 'T♥T♦'
Пример #5
0
def test_card_are_only_depends_from_rank_not_suit_when_different():
    assert Combo('Kc7s') > Combo('Kd4c')
    assert Combo('Kd4c') < Combo('Kc7s')

    assert Combo('K♠5♣') < Combo('K♥7♠')
    assert Combo('K♥7♠') > Combo('K♠5♣')
Пример #6
0
def test_suited_combos_are_higher_than_offsuit():
    assert Combo('AcKc') > Combo('AsKd')
    assert Combo('AsKd') < Combo('AcKc')

    assert Combo('AsKs') > Combo('AdKd')
    assert Combo('AdKd') > Combo('AcKc')
Пример #7
0
def test_hash():
    combination1 = Combo('2s2c')
    combination2 = Combo('2c2s')
    assert hash(combination1) == hash(combination2)
Пример #8
0
def test_pairs_are_better_than_non_pairs():
    assert Combo('2s2c') > Combo('AsKh')
    assert Combo('5s5h') > Combo('JsTs')
Пример #9
0
def test_is_broadway():
    assert Combo('KsJc').is_broadway is True
Пример #10
0
def test_case_insensitive():
    assert Combo('ASKC') > Combo('QCJH')
    assert Combo('askc') > Combo('qcjh')
    assert Combo('KSjh').is_broadway is True

    assert Combo('2s2c') == Combo('2S2C')
Пример #11
0
def test_is_suited_connector():
    assert Combo('AdKd').is_connector
    assert Combo('KsQs').is_suited_connector
Пример #12
0
def test_is_two_gapper():
    assert Combo('Jd8s').is_two_gapper is True
Пример #13
0
def test_is_one_gapper():
    assert Combo('Jd9s').is_one_gapper is True
Пример #14
0
def test_is_connector():
    assert Combo('AdKs').is_connector is True
    assert Combo('JdTc').is_connector is True
    assert Combo('KsQs').is_connector is True
Пример #15
0
def test_putting_them_in_set_doesnt_raise_Exception():
    {Combo('AsAh'), Combo('2s2c')}
Пример #16
0
def test_pairs_are_NOT_equal():
    assert Combo('2s2c') != Combo('2d2h')
    assert Combo('5d5h') != Combo('5s5h')
Пример #17
0
def test_two_set_of_combinations_are_equal_if_they_contains_same_cards():
    assert {Combo('2s2c')} == {Combo('2c2s')}
Пример #18
0
def test_card_are_better_when_ranks_are_higher():
    assert Combo('AsKc') > Combo('QcJh')
    assert Combo('KsJh') > Combo('QcJh')
Пример #19
0
def test_from_cards():
    assert Combo.from_cards(Card('As'), Card('Kh')) == Combo('AsKh')

    combination = Combo.from_cards(Card('Kh'), Card('As'))
    assert combination == Combo('AsKh')
    assert repr(combination) == b"Combo('A♠K♥')"
Пример #20
0
def test_first_hand_suit_also_matters():
    assert Combo('K♠4♣') > Combo('K♥4♣')
    assert Combo('K♥4♣') < Combo('K♠4♣')
Пример #21
0
def test_shape_property():
    assert Combo('2s2c').shape == Shape.PAIR
    assert Combo('AsKs').shape == Shape.SUITED
    assert Combo('AdKs').shape == Shape.OFFSUIT
Пример #22
0
def test_pair_when_first_card_are_the_same():
    assert Combo('2d2c') < Combo('2d2h')
Пример #23
0
def test_to_hand_converter_method():
    assert Combo('2s2c').to_hand() == Hand('22')
    assert Combo('AsKc').to_hand() == Hand('AKo')
    assert Combo('7s6s').to_hand() == Hand('76s')
Пример #24
0
def test_unicode():
    assert Combo('AsAh') == Combo('A♠A♥')
    assert Combo('5s5h') > Combo('J♠T♠')
    assert Combo('5s5h') >= Combo('J♠T♠')
Пример #25
0
def test_pairs_are_not_offsuits():
    assert Combo('2s2c').is_offsuit is False
Пример #26
0
def test_first_and_second_are_Card_instances():
    assert isinstance(Combo('AsKc').first, Card)
    assert isinstance(Combo('AsKc').second, Card)
Пример #27
0
def test_pickable():
    assert pickle.loads(pickle.dumps(Combo('AsKc'))) == Combo('AsKc')
Пример #28
0
def test_is_offsuit():
    assert Combo('AcKh').is_offsuit is True
    assert Combo('AcKh').is_suited is False
Пример #29
0
def test_card_order_is_not_significant():
    assert Combo('2s2c') == Combo('2c2s')
    assert Combo('AsQc') == Combo('QcAs')
Пример #30
0
def test_from_cards():
    assert Combo.from_cards(Card('As'), Card('Kh')) == Combo('AsKh')

    combination = Combo.from_cards(Card('Kh'), Card('As'))
    assert combination == Combo('AsKh')
    assert repr(combination) == b"Combo('A♠K♥')"
Пример #31
0
def test_is_pair():
    assert Combo('2s2c').is_pair is True
    assert Combo('AhAd').is_pair is True