Skip to content

Commit 5f70c9d

Browse files
authored
test: Update Chaitana's tests to verify queue has been updated (#3799)
1 parent 6a7a351 commit 5f70c9d

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

exercises/concept/chaitanas-colossal-coaster/list_methods_test.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,39 @@ def test_how_many_namefellows(self):
140140

141141
@pytest.mark.task(taskno=6)
142142
def test_remove_the_last_person(self):
143-
test_data = ['Natasha', 'Steve', 'Ultron', 'Natasha', 'Rocket']
144-
actual_result = remove_the_last_person(test_data)
145-
expected = 'Rocket'
146-
error_message = (f'Called remove_the_last_person({test_data}).'
147-
f'The function returned {actual_result}, but the tests '
148-
f'expected {expected} as the person who was removed.')
143+
test_data = [
144+
(['Natasha', 'Steve', 'Ultron', 'Natasha', 'Rocket'], 'Rocket'),
145+
(['Wanda', 'Natasha', 'Steve', 'Rocket', 'Ultron'], 'Ultron'),
146+
(['Steve', 'Wanda', 'Rocket', 'Ultron', 'Natasha'], 'Natasha')
147+
]
148+
for variant, (input, expected) in enumerate(test_data, start=1):
149+
with self.subTest(f'variation #{variant}', input=input, expected=expected):
150+
actual_result = remove_the_last_person(input)
151+
expected_result = expected
152+
153+
error_message = (f'Called remove_the_last_person({input}).'
154+
f'The function returned {actual_result}, but the tests expected {expected_result}.')
155+
156+
self.assertEqual(actual_result, expected_result, msg=error_message)
157+
158+
@pytest.mark.task(taskno=6)
159+
def test_remove_the_last_person_validate_queue(self):
160+
test_data = [
161+
(['Natasha', 'Steve', 'Ultron', 'Natasha', 'Rocket'], ['Natasha', 'Steve', 'Ultron', 'Natasha']),
162+
(['Wanda', 'Natasha', 'Steve', 'Rocket', 'Ultron'], ['Wanda', 'Natasha', 'Steve', 'Rocket']),
163+
(['Steve', 'Wanda', 'Rocket', 'Ultron', 'Natasha'], ['Steve', 'Wanda', 'Rocket', 'Ultron'])
164+
]
165+
for variant, (input, modified) in enumerate(test_data, start=1):
166+
with self.subTest(f'variation #{variant}', input=input, modified=modified):
167+
unmodified = deepcopy(input)
168+
actual_result = remove_the_last_person(input)
169+
expected_queue = modified
170+
171+
error_message = (f'\nCalled remove_the_last_person({unmodified}).\n'
172+
f'The function was expected to change the queue to {expected_queue},\n'
173+
f'but the queue looks like {input} instead.')
149174

150-
self.assertIs(actual_result, expected, msg=error_message)
175+
self.assertEqual(input, expected_queue, msg=error_message)
151176

152177
@pytest.mark.task(taskno=7)
153178
def test_sorted_names(self):

0 commit comments

Comments
 (0)