fixed test in deck and added hand
test
This commit is contained in:
@@ -13,11 +13,26 @@ def test_deck_init(default_deck):
|
||||
assert len(default_deck.cards) == 52
|
||||
|
||||
|
||||
def test_shuffle_deck(default_deck):
|
||||
"""Tests if the deck is randomized after method call"""
|
||||
assert default_deck != default_deck.shuffle()
|
||||
def test_deck_shuffle_order_changes(default_deck):
|
||||
"""Tests if the order of the cards have been changed."""
|
||||
# saves a list of cards before shufflening
|
||||
ordered_cards = list(default_deck.cards)
|
||||
#shuffle cards
|
||||
default_deck.shuffle()
|
||||
|
||||
assert default_deck.cards != ordered_cards
|
||||
|
||||
def test_deck_shuffle_content_is_preserved(default_deck):
|
||||
# 1. Capture the unique cards of the original list (as a set)
|
||||
original_card_set = set(str(card) for card in default_deck.cards)
|
||||
# 2. Shuffle the deck
|
||||
default_deck.shuffle()
|
||||
# 3. Check if the number of cards is still 52
|
||||
assert len(default_deck.cards) == 52
|
||||
# 4. Check if the card contents are still identical (all 52 unique cards must be present)
|
||||
shuffled_card_set = set(str(card) for card in default_deck.cards)
|
||||
assert shuffled_card_set == original_card_set
|
||||
|
||||
def test_card_dealing(default_deck):
|
||||
"""Tests if the a card is correctly removed from the deck."""
|
||||
default_deck.shuffle()
|
||||
|
||||
12
tests/test_hand.py
Normal file
12
tests/test_hand.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from pyjack.hand import Hand
|
||||
|
||||
@pytest.fixture
|
||||
def default_hand():
|
||||
my_hand = Hand()
|
||||
return my_hand
|
||||
|
||||
|
||||
def test_adding_card_to_hand(default_hand):
|
||||
default_hand.add_card("diamonds","2")
|
||||
Reference in New Issue
Block a user