def test_ace_values( self ): #Checks if the calc_val() method correctly recalculates the sum of the Players hand if there are multiple aces in the Players hand player = Player("Mikkel") player.hand.append(Card("Hearts", "Ace", 11)) player.hand.append(Card("Diamonds", "Ace", 11)) self.assertEqual( player.calc_val(), 12, "If the player starts with 2 aces the value should be 12 and not 22" ) player.hand.append(Card("Spades", "Ace", 11)) self.assertEqual( player.calc_val(), 13, "Fails if the calc.val() doesn't correctly make the value 13")
def test_value( self ): #Tests my calc_val() method in my Player class. It calculates the value sum of the hand of the player player = Player("Mikkel") player.hand.append(Card("Hearts", "Ace", 11)) player.hand.append(Card("Hearts", "King", 10)) self.assertEqual( player.calc_val(), 21, "Total should be 21" ) #In this scenario it tests if the appended cards give a sum of 21 which they should do