def test_MultiplePlayerDrawCard(): """ Test that multiple players can draw cards from a deck to their hand. Ensure the card is present in the player's hand but not present in the deck after being drawn or in the other player's hand. """ d = Deck() d.shuffle() p1 = Player("Matt") p2 = Player("Sarah") for i in range(2): p1.draw(d) p2.draw(d) assert len(p1.hand) > 0 assert len(p2.hand) > 0 for card in p1.hand: assert card not in d.cards assert card not in p2.hand for card in p2.hand: assert card not in d.cards assert card not in p1.hand return
def test_draw( self ): #This method tests if the player draws correctly. In the beginning the player should draw 2 cards and then 1 card each time onwards when the method is called. player = Player("Mikkel") deck = Deck() player.draw(deck) self.assertTrue( len(player.hand) == 2, "The player should get 2 cards in the beginning of the first round" ) player.draw(deck) self.assertTrue( len(player.hand) == 3, "If the player hits once after the first round he should have 3 cards in hand" )
def test_SinglePlayerDrawCard(): """ Test that a single player can draw a card from a deck to their hand. Ensure the card is present in the player's hand but not present in the deck after being drawn. """ d = Deck() d.shuffle() p1 = Player("Matt") for i in range(2): p1.draw(d) assert p1.hand != None assert len(p1.hand) > 0 for card in p1.hand: assert card not in d.cards return