def test_comparison(self): card = Card.from_string("8C") assert card > Card.from_string("6C") assert card > Card.from_string("6H") assert card < Card.from_string("JC") assert card < Card.from_string("JH") # same card (should never happen) assert card == Card.from_string("8C") # same value, different suit. assert card == Card.from_string("8H")
def test_from_string(self, string_repr, value, suit): card = Card.from_string(string_repr) assert card.value == value assert card.suit == suit
def from_string(cls, string_repr): return cls((Card.from_string(s) for s in string_repr.split()))