def remove_from_meld(self, meld: Meld, card: Card) -> None: """Remove a card from a meld. Args: meld (Meld): the meld to add to card (Card): the card to add Side effects: * Updates _card_to_meld_id map accordingly * Removes entry from _card_to_meld_id if empty """ self._card_to_meld_id[card].remove(id(meld)) if len(self._card_to_meld_id[card]) == 0: del self._card_to_meld_id[card] meld.remove(meld.find(card))
def test_remove_last(self): """Test removing the last card in a meld (leaving it empty).""" c = Card(rank=Rank.KING, suit=Suit.CLUB) m = Meld(c) m.remove(m.find(c))