-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathhw5_tests.py
154 lines (108 loc) · 6.07 KB
/
hw5_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import unittest
import hw5_cards
class TestCard(unittest.TestCase):
def test_construct_Card(self):
c1 = hw5_cards.Card(0, 2)
c2 = hw5_cards.Card(1, 1)
self.assertEqual(c1.suit, 0)
self.assertEqual(c1.suit_name, "Diamonds")
self.assertEqual(c1.rank, 2)
self.assertEqual(c1.rank_name, "2")
self.assertIsInstance(c1.suit, int)
self.assertIsInstance(c1.suit_name, str)
self.assertIsInstance(c1.rank, int)
self.assertIsInstance(c1.rank_name, str)
self.assertEqual(c2.suit, 1)
self.assertEqual(c2.suit_name, "Clubs")
self.assertEqual(c2.rank, 1)
self.assertEqual(c2.rank_name, "Ace")
def test_q1(self):
'''
1. fill in your test method for question 1:
Test that if you create a card with rank 12, its rank_name will be "Queen"
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.
'''
pass
#return X, Y
def test_q2(self):
'''
1. fill in your test method for question 1:
Test that if you create a card instance with suit 1, its suit_name will be "Clubs"
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.
'''
pass
#return X, Y
def test_q3(self):
'''
1. fill in your test method for question 3:
Test that if you invoke the __str__ method of a card instance that is created with suit=3, rank=13, it returns the string "King of Spades"
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.
'''
pass
#return X, Y
def test_q4(self):
'''
1. fill in your test method for question 4:
Test that if you create a eck 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.
'''
pass
#return X, Y
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.
'''
pass
#return X, Y
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.
'''
pass
#return X, Y
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.
'''
pass
#return X, Y
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.
'''
pass
#return X, Y
if __name__=="__main__":
unittest.main()