From 5f70c9d4ee61faed488e789bc6449fa347f9f778 Mon Sep 17 00:00:00 2001 From: Luke McGuire Date: Wed, 23 Oct 2024 19:30:28 -0500 Subject: [PATCH] test: Update Chaitana's tests to verify queue has been updated (#3799) --- .../list_methods_test.py | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py b/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py index c519ff255c..5df2af327b 100644 --- a/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py +++ b/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py @@ -140,14 +140,39 @@ def test_how_many_namefellows(self): @pytest.mark.task(taskno=6) def test_remove_the_last_person(self): - test_data = ['Natasha', 'Steve', 'Ultron', 'Natasha', 'Rocket'] - actual_result = remove_the_last_person(test_data) - expected = 'Rocket' - error_message = (f'Called remove_the_last_person({test_data}).' - f'The function returned {actual_result}, but the tests ' - f'expected {expected} as the person who was removed.') + test_data = [ + (['Natasha', 'Steve', 'Ultron', 'Natasha', 'Rocket'], 'Rocket'), + (['Wanda', 'Natasha', 'Steve', 'Rocket', 'Ultron'], 'Ultron'), + (['Steve', 'Wanda', 'Rocket', 'Ultron', 'Natasha'], 'Natasha') + ] + for variant, (input, expected) in enumerate(test_data, start=1): + with self.subTest(f'variation #{variant}', input=input, expected=expected): + actual_result = remove_the_last_person(input) + expected_result = expected + + error_message = (f'Called remove_the_last_person({input}).' + f'The function returned {actual_result}, but the tests expected {expected_result}.') + + self.assertEqual(actual_result, expected_result, msg=error_message) + + @pytest.mark.task(taskno=6) + def test_remove_the_last_person_validate_queue(self): + test_data = [ + (['Natasha', 'Steve', 'Ultron', 'Natasha', 'Rocket'], ['Natasha', 'Steve', 'Ultron', 'Natasha']), + (['Wanda', 'Natasha', 'Steve', 'Rocket', 'Ultron'], ['Wanda', 'Natasha', 'Steve', 'Rocket']), + (['Steve', 'Wanda', 'Rocket', 'Ultron', 'Natasha'], ['Steve', 'Wanda', 'Rocket', 'Ultron']) + ] + for variant, (input, modified) in enumerate(test_data, start=1): + with self.subTest(f'variation #{variant}', input=input, modified=modified): + unmodified = deepcopy(input) + actual_result = remove_the_last_person(input) + expected_queue = modified + + error_message = (f'\nCalled remove_the_last_person({unmodified}).\n' + f'The function was expected to change the queue to {expected_queue},\n' + f'but the queue looks like {input} instead.') - self.assertIs(actual_result, expected, msg=error_message) + self.assertEqual(input, expected_queue, msg=error_message) @pytest.mark.task(taskno=7) def test_sorted_names(self):