def test_pairs_from_hands(self): assert Range.from_objects({Hand('AA'), Hand('KK'), Hand('QQ')}) == Range('QQ+')
def test_pairs_with_dash_are_equal_with_spaces(self): assert Range('22-33').combos == Range('22 33').combos assert Range('55-33').combos == Range('33 44 55').combos
def test_offsuit(self): assert Range('AkO') == Range('AKo')
def test_empty_range(self): assert Range().hands == tuple() assert Range().combos == tuple() assert Range('').hands == tuple() assert Range('').combos == tuple()
def test_pairs_multiple(self): assert Range('22 33').combos == DEUCE_COMBOS + THREE_COMBOS
def test_suited_plus(self): assert Range('KJs+').hands == (Hand('KJs'), Hand('KQs'))
def test_offsuit_and_suited_dashed(self): assert Range('J8-J4').hands == (Hand('J4o'), Hand('J4s'), Hand('J5o'), Hand('J5s'), Hand('J6o'), Hand('J6s'), Hand('J7o'), Hand('J7s'), Hand('J8o'), Hand('J8s'))
def test_pickable(): assert pickle.loads(pickle.dumps(Range('Ako 22+'))) == Range('AKo 22+')
def test_pairs_with_dash_reverse(self): assert Range('55-22').hands == (Hand('22'), Hand('33'), Hand('44'), Hand('55')) assert Range('33-22').hands == (Hand('22'), Hand('33'))
def test_wrong_str_in_range_raises_ValueError(self): with pytest.raises(ValueError): assert 'AKl' in Range('AQo+')
def test_pairs_with_dash(self): assert Range('22-55').hands == (Hand('22'), Hand('33'), Hand('44'), Hand('55')) assert Range('22-33').hands == (Hand('22'), Hand('33'))
def test_str_in_range(self): assert 'AKo' in Range('AQo+')
def test_hand_in_range(self): assert Hand('Ako') in Range('AQo+')
def test_combo_in_range(self): assert Combo('2s2c') in Range('22')
def test_from_percent(self): assert Range.from_percent(0.9) == Range('KK+')
def test_multiple_offsuit_hands(self): assert Range('AKo 84o').hands == (Hand('84o'), Hand('AKo'))
def test_offsuit_hand(self): assert bool(Range('AKo')) is True
def test_hands_without_suit(self): assert Range('AK 48').hands == (Hand('84o'), Hand('84s'), Hand('AKo'), Hand('AKs'))
def test_suited_minus(self): assert Range('76s-').hands == (Hand('72s'), Hand('73s'), Hand('74s'), Hand('75s'), Hand('76s'))
def test_dash_offsuit(self): assert Range('J8o-J4o').hands == (Hand('J4o'), Hand('J5o'), Hand('J6o'), Hand('J7o'), Hand('J8o'))
def test_offsuit_and_suited_with_dash_reversed_is_the_same(self): assert Range('J8-J4').hands == Range('J4-J8').hands
def test_dash_suited(self): assert Range('J8s-J4s').hands == (Hand('J4s'), Hand('J5s'), Hand('J6s'), Hand('J7s'), Hand('J8s'))
def test_pairs_simple(self): """Test if pairs get all the combos.""" assert Range('22').combos == DEUCE_COMBOS
def test_pairs_backward(self): assert Range('44-').hands == (Hand('22'), Hand('33'), Hand('44'))
def test_pairs_with_dash(self): assert Range('22-33').combos == DEUCE_COMBOS + THREE_COMBOS
def test_both_suits_with_minus(self): assert Range('A5-').hands == (Hand('A2o'), Hand('A2s'), Hand('A3o'), Hand('A3s'), Hand('A4o'), Hand('A4s'), Hand('A5o'), Hand('A5s'))
def test_pairs(self): assert Range('aA') == Range('AA') assert Range('TT') == Range('tt')
def test_both_suits_with_plus(self): assert Range('A5+').hands == ( Hand('A5o'), Hand('A5s'), Hand('A6o'), Hand('A6s'), Hand('A7o'), Hand('A7s'), Hand('A8o'), Hand('A8s'), Hand('A9o'), Hand('A9s'), Hand('ATo'), Hand('ATs'), Hand('AJo'), Hand('AJs'), Hand('AQo'), Hand('AQs'), Hand('AKo'), Hand('AKs') )
def test_suited(self): assert Range('AKs') == Range('kaS')
def test_offsuit_plus(self): assert Range('KJo+').hands == (Hand('KJo'), Hand('KQo'))
def test_from_combos(self): range = Range.from_objects(DEUCE_COMBOS) assert range == Range('22') assert range.combos == DEUCE_COMBOS assert range.hands == (Hand('22'),)
def test_offsuit_minus(self): assert Range('76o-').hands == (Hand('72o'), Hand('73o'), Hand('74o'), Hand('75o'), Hand('76o'))
def test_from_percent_comparison(self): # both represents 0.9%, but they should not be equal assert Range('AKo') != Range.from_percent(0.9)
def test_hand_combination(self): assert bool(Range('AhKs')) is True