Skip to content

Commit 2caf26c

Browse files
committed
Changed names of test classes to be ExerciseNameTest, for better readability in UI results.
1 parent 2eaeb28 commit 2caf26c

File tree

14 files changed

+64
-296
lines changed

14 files changed

+64
-296
lines changed

exercises/concept/black-jack/black_jack_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
)
88

99

10-
class TestComparisons(unittest.TestCase):
10+
class BlackJackTest(unittest.TestCase):
1111

1212
@pytest.mark.task(taskno=1)
1313
def test_number_of_card(self):

exercises/concept/card-games/lists_test.py

Lines changed: 52 additions & 236 deletions
Original file line numberDiff line numberDiff line change
@@ -12,337 +12,153 @@
1212
)
1313

1414

15-
class TestToRounds(unittest.TestCase):
15+
class CardGamesTest(unittest.TestCase):
1616

1717
@pytest.mark.task(taskno=1)
18-
def test_instructions_example(self):
19-
round_number = 27
20-
want = [27, 28, 29]
21-
got = get_rounds(round_number)
22-
23-
self.assertEqual(
24-
want,
25-
got,
26-
msg=f'Expected {want} but got an incorrect result: {got!r}'
27-
)
28-
29-
@pytest.mark.task(taskno=1)
30-
def test_zero(self):
18+
def test_round_number_zero(self):
3119
round_number = 0
3220
want = [0, 1, 2]
33-
got = get_rounds(round_number)
3421

35-
self.assertEqual(
36-
want,
37-
got,
38-
msg=f'Expected {want} but got an incorrect result: {got!r}'
22+
self.assertEqual(want, get_rounds(round_number),
23+
msg=f'Expected {want} but got an incorrect result.'
3924
)
4025

4126
@pytest.mark.task(taskno=1)
42-
def test_random_int(self):
27+
def test_random_int_for_round_number(self):
4328
round_number = random.randint(0, 100)
4429
want = [round_number + i for i in range(3)]
45-
got = get_rounds(round_number)
4630

47-
self.assertEqual(
48-
want,
49-
got,
50-
msg=f'Expected {want} but got an incorrect result: {got!r}'
31+
self.assertEqual(get_rounds(round_number), want,
32+
msg=f'Expected {want} but got an incorrect result.'
5133
)
5234

53-
54-
class TestConcatenateRounds(unittest.TestCase):
55-
5635
@pytest.mark.task(taskno=2)
57-
def test_empty(self):
36+
def test_concatenate_empty_rounds(self):
5837
rounds_1 = []
5938
rounds_2 = []
6039
want = []
6140

62-
self.assertEqual(concatenate_rounds(rounds_1, rounds_2),
63-
want,
64-
msg=f'Expected {want} but got an incorrect result.'
65-
)
41+
self.assertEqual(concatenate_rounds(rounds_1, rounds_2), want,
42+
msg=f'Expected {want} but got an incorrect result.'
43+
)
6644

6745
@pytest.mark.task(taskno=2)
68-
def test_other(self):
46+
def test_concatenate_other_rounds(self):
6947
rounds_1 = [1, 2, 3]
7048
rounds_2 = [4, 5, 6]
7149
want = [1, 2, 3, 4, 5, 6]
7250

73-
self.assertEqual(concatenate_rounds(rounds_1, rounds_2),
74-
want,
75-
msg=f'Expected {want} but got an incorrect result.'
76-
)
77-
78-
79-
class TestListContainsRound(unittest.TestCase):
51+
self.assertEqual(concatenate_rounds(rounds_1, rounds_2), want,
52+
msg=f'Expected {want} but got an incorrect result.'
53+
)
8054

8155
@pytest.mark.task(taskno=3)
82-
def test_instructions_example_1(self):
83-
rounds = [27, 28, 29, 35, 36]
84-
round_number = 29
85-
want = True
86-
got = list_contains_round(rounds, round_number)
87-
88-
self.assertEqual(
89-
want,
90-
got,
91-
msg=f'Expected {want} but got an incorrect result: {got!r}'
92-
)
93-
94-
@pytest.mark.task(taskno=3)
95-
def test_instructions_example_2(self):
96-
rounds = [27, 28, 29, 35, 36]
97-
round_number = 30
98-
want = False
99-
got = list_contains_round(rounds, round_number)
100-
101-
self.assertEqual(
102-
want,
103-
got,
104-
msg=f'Expected {want} but got an incorrect result: {got!r}'
105-
)
106-
107-
@pytest.mark.task(taskno=3)
108-
def test_empty(self):
56+
def test_contains_empty_rounds(self):
10957
rounds = []
11058
round_number = 1
11159
want = False
112-
got = list_contains_round(rounds, round_number)
11360

114-
self.assertEqual(
115-
want,
116-
got,
117-
msg=f'Expected {want} but got an incorrect result: {got!r}'
61+
self.assertEqual(list_contains_round(rounds, round_number), want,
62+
msg=f'Expected {want} but got an incorrect result.'
11863
)
11964

12065
@pytest.mark.task(taskno=3)
121-
def test_other_true(self):
66+
def test_contains_other_rounds_true(self):
12267
rounds = [1, 2, 3]
12368
round_number = 2
12469
want = True
125-
got = list_contains_round(rounds, round_number)
12670

127-
self.assertEqual(
128-
want,
129-
got,
130-
msg=f'Expected {want} but got an incorrect result: {got!r}'
71+
self.assertEqual(list_contains_round(rounds, round_number), want,
72+
msg=f'Expected {want} but got an incorrect result.'
13173
)
13274

13375
@pytest.mark.task(taskno=3)
134-
def test_other_false(self):
76+
def test_contains_other_rounds_false(self):
13577
rounds = [1, 2, 3]
13678
round_number = 0
13779
want = False
138-
got = list_contains_round(rounds, round_number)
13980

140-
self.assertEqual(
141-
want,
142-
got,
143-
msg=f'Expected {want} but got an incorrect result: {got!r}'
81+
self.assertEqual(list_contains_round(rounds, round_number), want,
82+
msg=f'Expected {want} but got an incorrect result.'
14483
)
14584

146-
147-
class TestCardAverage(unittest.TestCase):
148-
14985
@pytest.mark.task(taskno=4)
150-
def test_instructions_example(self):
151-
hand = [5, 6, 7]
152-
want = 6.0
153-
got = card_average(hand)
154-
155-
self.assertEqual(
156-
want,
157-
got,
158-
msg=f'Expected {want} but got an incorrect result: {got!r}'
159-
)
160-
161-
@pytest.mark.task(taskno=4)
162-
def test_other(self):
86+
def test_card_average_other(self):
16387
hand = [1, 2, 3, 4]
16488
want = 2.5
165-
got = card_average(hand)
166-
167-
self.assertEqual(
168-
want,
169-
got,
170-
msg=f'Expected {want} but got an incorrect result: {got!r}'
171-
)
172-
173-
174-
class TestApproxAverageIsAverage(unittest.TestCase):
175-
176-
@pytest.mark.task(taskno=5)
177-
def test_instructions_example_1(self):
178-
hand = [1, 2, 3]
179-
want = True
180-
got = approx_average_is_average(hand)
181-
182-
self.assertEqual(
183-
want,
184-
got,
185-
msg=f'Expected {want} but got an incorrect result: {got!r}'
186-
)
18789

188-
@pytest.mark.task(taskno=5)
189-
def test_instructions_example_2(self):
190-
hand = [2, 3, 4, 8, 8]
191-
want = True
192-
got = approx_average_is_average(hand)
193-
194-
self.assertEqual(
195-
want,
196-
got,
197-
msg=f'Expected {want} but got an incorrect result: {got!r}'
90+
self.assertEqual(card_average(hand), want,
91+
msg=f'Expected {want} but got an incorrect result.'
19892
)
19993

20094
@pytest.mark.task(taskno=5)
20195
def test_instructions_example_3(self):
20296
hand = [1, 2, 3, 5, 9]
20397
want = False
204-
got = approx_average_is_average(hand)
20598

206-
self.assertEqual(
207-
want,
208-
got,
209-
msg=f'Expected {want} but got an incorrect result: {got!r}'
99+
self.assertEqual(approx_average_is_average(hand), want,
100+
msg=f'Expected {want} but got an incorrect result.'
210101
)
211102

212103
@pytest.mark.task(taskno=5)
213-
def test_median_true(self):
104+
def test_approx_average_median_true(self):
214105
hand = [1, 2, 4, 5, 8]
215106
want = True
216-
got = approx_average_is_average(hand)
217107

218-
self.assertEqual(
219-
want,
220-
got,
221-
msg=f'Expected {want} but got an incorrect result: {got!r}'
108+
self.assertEqual(approx_average_is_average(hand), want,
109+
msg=f'Expected {want} but got an incorrect result.'
222110
)
223111

224112
@pytest.mark.task(taskno=5)
225-
def test_other_true(self):
113+
def test_approx_average_other_true(self):
226114
hand = [2, 3, 4]
227115
want = True
228-
got = approx_average_is_average(hand)
229116

230-
self.assertEqual(
231-
want,
232-
got,
233-
msg=f'Expected {want} but got an incorrect result: {got!r}'
117+
self.assertEqual(approx_average_is_average(hand), want,
118+
msg=f'Expected {want} but got an incorrect result.'
234119
)
235120

236121
@pytest.mark.task(taskno=5)
237-
def test_other_false(self):
122+
def test_approx_average_other_false(self):
238123
hand = [2, 3, 4, 7, 8]
239-
want = False
240-
got = approx_average_is_average(hand)
241-
242-
self.assertEqual(
243-
want,
244-
got,
245-
msg=f'Expected {want} but got an incorrect result: {got!r}'
246-
)
247-
248-
249-
class TestAverageEvenIsAverageOdd(unittest.TestCase):
250-
251-
@pytest.mark.task(taskno=6)
252-
def test_instructions_example_1(self):
253-
hand = [1, 2, 3]
254-
want = True
255-
got = average_even_is_average_odd(hand)
124+
want= False
256125

257-
self.assertEqual(
258-
want,
259-
got,
260-
msg=f'Expected {want} but got an incorrect result: {got!r}'
126+
self.assertEqual(approx_average_is_average(hand), want,
127+
msg=f'Expected {want} but got an incorrect result.'
261128
)
262129

263130
@pytest.mark.task(taskno=6)
264-
def test_instructions_example_2(self):
265-
hand = [1, 2, 3, 4]
266-
want = False
267-
got = average_even_is_average_odd(hand)
268-
269-
self.assertEqual(
270-
want,
271-
got,
272-
msg=f'Expected {want} but got an incorrect result: {got!r}'
273-
)
274-
275-
@pytest.mark.task(taskno=6)
276-
def test_other_true(self):
131+
def test_avg_even_odd_other_true(self):
277132
hand = [5, 6, 7]
278-
want = True
279-
got = average_even_is_average_odd(hand)
133+
want= True
280134

281-
self.assertEqual(
282-
want,
283-
got,
284-
msg=f'Expected {want} but got an incorrect result: {got!r}'
135+
self.assertEqual(average_even_is_average_odd(hand), want,
136+
msg=f'Expected {want} but got an incorrect result.'
285137
)
286138

287139
@pytest.mark.task(taskno=6)
288-
def test_other_false(self):
140+
def test_avg_even_odd_other_false(self):
289141
hand = [5, 6, 8]
290142
want = False
291-
got = average_even_is_average_odd(hand)
292143

293-
self.assertEqual(
294-
want,
295-
got,
296-
msg=f'Expected {want} but got an incorrect result: {got!r}'
297-
)
298-
299-
300-
class TestMaybeDoubleLast(unittest.TestCase):
301-
302-
@pytest.mark.task(taskno=7)
303-
def test_instructions_example_1(self):
304-
hand = [5, 9, 11]
305-
want = [5, 9, 22]
306-
got = maybe_double_last(hand)
307-
308-
self.assertEqual(
309-
want,
310-
got,
311-
msg=f'Expected {want} but got an incorrect result: {got!r}'
312-
)
313-
314-
@pytest.mark.task(taskno=7)
315-
def test_instructions_example_2(self):
316-
hand = [5, 9, 10]
317-
want = [5, 9, 10]
318-
got = maybe_double_last(hand)
319-
320-
self.assertEqual(
321-
want,
322-
got,
323-
msg=f'Expected {want} but got an incorrect result: {got!r}'
144+
self.assertEqual(average_even_is_average_odd(hand), want,
145+
msg=f'Expected {want} but got an incorrect result.'
324146
)
325147

326148
@pytest.mark.task(taskno=7)
327-
def test_other_doubles(self):
149+
def test_maybe_double_last_other_doubles(self):
328150
hand = [1, 2, 11]
329151
want = [1, 2, 22]
330-
got = maybe_double_last(hand)
331152

332-
self.assertEqual(
333-
want,
334-
got,
335-
msg=f'Expected {want} but got an incorrect result: {got!r}'
153+
self.assertEqual(maybe_double_last(hand), want,
154+
msg=f'Expected {want} but got an incorrect result.'
336155
)
337156

338157
@pytest.mark.task(taskno=7)
339-
def test_other_no_change(self):
158+
def test_maybe_double_last_other_no_change(self):
340159
hand = [1, 2, 3]
341160
want = [1, 2, 3]
342-
got = maybe_double_last(hand)
343161

344-
self.assertEqual(
345-
want,
346-
got,
347-
msg=f'Expected {want} but got an incorrect result: {got!r}'
162+
self.assertEqual(maybe_double_last(hand), want,
163+
msg=f'Expected {want} but got an incorrect result.'
348164
)

0 commit comments

Comments
 (0)