def test_hand_value_is_correct(self):
        testCards = (Card("Diamond", 10, "Jack"), Card("Hearts", 2, "Two"))

        for card in testCards:
            self.hand.cards['allCards'].append(card)

        self.hand.recalculate_value()

        self.assertEqual(12, self.hand.value)
    def test_change_aces_brings_hand_to_below_21_when_bust_with_aces(self):
        # add 4 aces, hand value 44, cycle through and change three aces to value 1
        # for hand value of 14
        testCards = (Card("Diamonds", 11, "Ace"), Card("Clubs", 11, "Ace"),
                     Card("Spades", 11, "Ace"), Card("Hearts", 11, "Ace"))

        for card in testCards:
            self.hand.cards['allCards'].append(card)
            self.hand.cards['aces'].append(card)

        self.hand.recalculate_value()

        self.assertEqual(14, self.hand.value)
Beispiel #3
0
 def __init__(self,host,port,name):
     self.name=name
     self.x=socket()
     self.host=host
     self.port=port
     self.status=0
     self.cards = [Card() for x in range(7)]
class TestBlackjackCard(unittest.TestCase):
    def setUp(self):
        self.card = Card("Diamonds", 10, "King")

    def test_card_has_correct_suit(self):
        self.assertEqual("Diamonds", self.card.suit)

    def test_card_has_correct_value(self):
        self.assertEqual(10, self.card.value)

    def test_card_has_correct_title(self):
        self.assertEqual("King", self.card.title)

    def test_card_value_is_num(self):
        self.assertIsInstance(self.card.value, (int, float, complex))

    def test_card_prints_in_correct_pretty_format(self):
        compareString = "King of Diamonds - (10)"
        cardString = self.card.__str__()
        self.assertEqual(compareString, cardString)
Beispiel #5
0
 def draw_card(self):
     x_card = Card()
     self.cards.append(x_card)
 def setUp(self):
     self.card = Card("Diamonds", 10, "King")
    def test_card_inserts_into_hand_correctly(self):
        card = Card("Diamonds", 10, "King")
        self.hand.cards['allCards'].append(card)

        # check first index for card
        self.assertEqual(card, self.hand.cards['allCards'][0])
Beispiel #8
0
 def start_card(self):
     top_card = Card()
     while top_card.symbol in ['+2', '+4', 'rev', 'skip', 'wild']:
         top_card = Card()
     return top_card