def __post_init__(self): """ Generate actual list of Card instances from card_string """ self.card_list = [] for suit_holding in self.card_string.split(): suit = Suit[suit_holding[0]] for rank in suit_holding[2:]: card = Card(suit, Rank[rank]) self.card_list.append(card) shuffle(self.card_list)
def test_wrong_cards(): with pytest.raises(ValueError): BridgeHand([Card(Suit.S, Rank.A)] + [None] * 12)