Пример #1
0
 def test_q7(self):
     q7deck = Deck()
     q7 = q7deck.deal_card()
     q7deck.replace_card(q7)
     self.assertEqual(len(q7deck.cards), 52)
     return len(q7deck.cards), 52
     '''
Пример #2
0
    def test_q5(self):
        '''
        1. fill in your test method for question 5:
        Test that if you invoke the deal_card method on a deck, it will return a card instance.
        
        2. remove the pass command
        
        3. uncomment the return command and 
        3b. change X, Y to the values from your assert statement
        ### please note: normally unit test methods do not have return statements. But returning will allow for unit testing of your unit test, and allow you to check your answer with the autograder.  This is optional today.

        '''
        deck = Deck()
        q5 = deck.deal_card()
        self.assertIsInstance(q5, Card)
        return q5, Card
Пример #3
0
    def test_q6(self):
        '''
        1. fill in your test method for question 6:
        
        Test that if you invoke the deal_card method on a deck, the deck has one fewer cards in it afterwards.
        
        2. remove the pass command
        
        3. uncomment the return command and 
        3b. change X, Y to the values from your assert statement
        ### please note: normally unit test methods do not have return statements. But returning will allow for unit testing of your unit test, and allow you to check your answer with the autograder.  This is optional today.

        '''
        d1 = Deck()
        d1.deal_card()
        self.assertEqual(len(d1.cards), 51)
        return len(d1.cards), 51    
Пример #4
0
    def test_q8(self):
        '''
        1. fill in your test method for question 8:
        Test that if you invoke the replace_card method with a card that is already in the deck, the deck size is not affected.(The function must silently ignore it if you try to add a card that’s already in the deck)

        
        2. remove the pass command
        
        3. uncomment the return command and 
        3b. change X, Y to the values from your assert statement
        ### please note: normally unit test methods do not have return statements. But returning will allow for unit testing of your unit test, and allow you to check your answer with the autograder.  This is optional today.

        '''
        c1 = Card(0, 2)
        d1 = Deck()
        d1.replace_card(c1)
        self.assertEqual(len(d1.cards), 52)
        return len(d1.cards), 52  
Пример #5
0
    def test_q7(self):
        '''
        1. fill in your test method for question 7:
        Test that if you invoke the replace_card method, the deck has one more card in it afterwards. (Please note that you want to use deal_card function first to remove a card from the deck and then add the same card back in)

        
        2. remove the pass command
        
        3. uncomment the return command and 
        3b. change X, Y to the values from your assert statement
        ### please note: normally unit test methods do not have return statements. But returning will allow for unit testing of your unit test, and allow you to check your answer with the autograder.  This is optional today.

        '''
        d1 = Deck()
        Original_d1 = d1
        Removed_card = d1.deal_card()
        d1.replace_card(Removed_card)
        self.assertEqual(len(d1.cards), 52)
        return len(d1.cards), len(Original_d1.cards), 52
Пример #6
0
    def test_q4(self):
        '''
        1. fill in your test method for question 4:
        Test that if you create a deck instance, it will have 52 cards in its cards instance variable
        
        2. remove the pass command
        
        3. uncomment the return command and 
        3b. change X, Y to the values from your assert statement
        ### please note: normally unit test methods do not have return statements. But returning will allow for unit testing of your unit test, and allow you to check your answer with the autograder.  This is optional today.

        '''
        i = 0
        d1 = Deck()
        for items in d1.cards:
            i += 1
        self.assertEqual(i, 52)
        return i, 52 
Пример #7
0
 def test_q6(self):
     q6deck = Deck()
     q6deck.deal_card()
     self.assertEqual(len(q6deck.cards), 51)
     return len(q6deck.cards), 51