コード例 #1
0
ファイル: tests.py プロジェクト: jd1123/blackjack
class HandTest(unittest.TestCase):
    
    def setUp(self):
        self.my_deck = MultiDeck(4)
        self.hand = Hand()
    
    def test_addingcards(self):
        card = self.my_deck.draw_card()
        self.hand.add_card_to_hand(card)
        self.assertEqual(len(self.hand.cards_in_hand),1, 'There is not one and only one card in the hand after adding one')
        self.assertTrue(card==self.hand.pop_card(), 'pop_card did not return the same object as the last card in hand')
        self.assertEqual(len(self.hand.cards_in_hand), 0, 'pop_card did not remove the card in hand')
    
    def test_clr_hand(self):
        card = self.my_deck.draw_card()
        self.hand.add_card_to_hand(card)
        self.hand.clr_hand()
        self.assertEqual(self.hand.cards_in_hand, [], 'There are cards in the hand after clearing')
        self.assertTrue(self.hand.hand_active, 'Hand is not active after clearing')
        self.assertFalse(self.hand.busted, 'Busted flag is not false after clearing')
        self.assertEqual(self.hand.soft, 0, 'Soft counter is not 0 after clearing')
    
    def test_hit(self):
        self.my_deck.shuffle()
        self.hand.clr_hand()