def test_hand_ace3(self): playersHand = Hand() playersHand.add_card(Card("Clubs", "Ten")) playersHand.add_card(Card("Spades", "Ten")) playersHand.add_card(Card("Clubs", "Ace")) self.assertEqual(31, playersHand.value) playersHand.adjust_for_ace() self.assertEqual(21, playersHand.value)
def test_hand_isDealer1(self): out = io.StringIO() sys.stdout = out playersHand = Hand() playersHand.add_card(Card("Clubs", "Ten")) playersHand.add_card(Card("Spades", "Ten")) dealersHand = Hand() dealersHand.add_card(Card("Spades", "Eight")) dealersHand.add_card(Card("Diamonds", "Two")) show_some(playersHand,dealersHand) output = out.getvalue().strip() self.assertIn("<card hidden>", output) self.assertNotIn("Eight of Spades", output)
def test_hand_value3(self): playersHand = Hand() playersHand.add_card(Card("Spades", "Two")) playersHand.add_card(Card("Hearts", "Two")) playersHand.add_card(Card("Diamonds", "Two")) playersHand.add_card(Card("Clubs", "Two")) self.assertEqual(8, playersHand.value)
def test_hand_isPlayer1(self): out = io.StringIO() sys.stdout = out playersHand = Hand() playersHand.add_card(Card("Clubs", "King")) playersHand.add_card(Card("Hearts", "Ace")) dealersHand = Hand() dealersHand.add_card(Card("Spades", "Eight")) dealersHand.add_card(Card("Diamonds", "Two")) show_some(playersHand,dealersHand) output = out.getvalue().strip() self.assertIn("King of Clubs", output) self.assertIn("Ace of Hearts", output)
def test_hand_value2(self): playersHand = Hand() playersHand.add_card(Card("Clubs", "King")) playersHand.add_card(Card("Hearts", "Jack")) self.assertEqual(4, playersHand.value)
def test_hand_value1(self): playersHand = Hand() playersHand.add_card(Card("Clubs", "King")) playersHand.add_card(Card("Hearts", "Three")) self.assertEqual(6, playersHand.value)
def test_hand_ace1(self): playersHand = Hand() playersHand.add_card(Card("Clubs", "King")) playersHand.add_card(Card("Spades", "King")) playersHand.add_card(Card("Clubs", "Ace")) self.assertEqual(17, playersHand.value)
def test_hand_value4(self): playersHand = Hand() playersHand.add_card(Card("Spades", "Nine")) playersHand.add_card(Card("Hearts", "Nine")) playersHand.add_card(Card("Diamonds", "Nine")) self.assertEqual(27, playersHand.value)