def cards(): return [ Card(value=9, suit="DIAMONDS"), Card(value=9, suit="CLUBS"), Card(value=10, suit="SPADES"), Card(value="K", suit="DIAMONDS"), Card(value="ACE", suit="HEARTS"), ]
def test_deck_add_another_deck(deck, cards): """Test extracting all cards of one deck to another specified deck""" second_deck = Deck( (Card(value="ACE", suit="DIAMONDS"), Card(value="ACE", suit="SPADES"))) expected = list(deck) + list(second_deck) deck.fetch_all(second_deck) assert second_deck.size == 7 assert not sum([not card in expected for card in second_deck])
def cards() -> List[Card]: """Return list of cards""" return [ Card(value=9, suit="DIAMONDS"), Card(value=9, suit="CLUBS"), Card(value=10, suit="SPADES"), Card(value="K", suit="DIAMONDS"), Card(value="ACE", suit="HEARTS"), ]
def generate_deck(deck_number: int) -> List[Card]: """Method for generate requested amount of card decks Args: deck_number (int): requested amount of card """ all_cards = list(product([i for i in range(2, 15)], CARD_SUITS)) * deck_number shuffle(all_cards) return [Card(*card) for card in all_cards]
def test_player_pile_size(player): """Check that pile size is changing after new cards addition""" assert player.pile_size == 0 player.pile.add_card(Card(value="Q", suit="SPADES")) assert player.pile_size == 1
def test_card_init(value: int, suit: str): """Test Card object initialization, all card numbers that greater than 10 should be converted to string""" card = Card(value=value, suit=suit) assert card.value == value assert card.suit == suit
("4", "DIAMONDS"), ("5", "CLUBS"), ("J", "SPADES"), ("Q", "HEARTS"), ("K", "DIAMONDS"), ("ACE", "CLUBS"), ], ) def test_card_init(value: int, suit: str): """Test Card object initialization, all card numbers that greater than 10 should be converted to string""" card = Card(value=value, suit=suit) assert card.value == value assert card.suit == suit @pytest.mark.parametrize( "first_card, second_card, expected", [ (Card("3", "HEARTS"), Card("2", "DIAMONDS"), False), (Card("3", "SPADES"), Card("13", "HEARTS"), False), (Card("11", "HEARTS"), Card("12", "HEARTS"), False), (Card("3", "HEARTS"), Card("3", "DIAMONDS"), True), (Card("14", "SPADES"), Card("14", "CLUBS"), True), (Card("3", "HEARTS"), Card("3", "HEARTS"), True), ], ) def test_card_comparison(first_card: Card, second_card: Card, expected: bool): """Test cards comparison: cards are True if their values are equal""" assert (first_card == second_card) == expected
def test_deck_add_card(deck): """Test card's addition""" assert deck.size == 5 deck.add_card(Card(value="ACE", suit="CLUBS")) assert deck.size == 6 assert deck.get_card() == Card(value="ACE", suit="CLUBS")