@@ -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'\n Called 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