We are stumped again in determining the error condition we need to test for in order to pass the test variants. Looks like we need to shake the tree, again. I’d really appreciate some advice on this question, please/thanks.
remove_the_mean_person
def remove_the_mean_person(queue, person_name):
"""Remove the mean person from the queue by the provided name.
:param queue: list - names in the queue.
:param person_name: str - name of mean person.
:return: list - queue update with the mean persons name removed.
"""
if not isinstance(queue, list):
raise TypeError('Input must be a list')
queue = queue.remove(person_name)
return queue
Task 4 Mean person in the queue
Test 4
* Failed ListMethods > remove the mean person
Code Run
test_data = [(['Natasha', 'Steve', 'Ultron', 'Wanda', 'Rocket'], 'Ultron'),
(['Natasha', 'Steve', 'Wanda', 'Rocket', 'Ultron'], 'Ultron'),
(['Ultron', 'Natasha', 'Steve', 'Wanda', 'Rocket'], 'Ultron'),
]
result_data = [['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket']]
for variant, (params, expected) in enumerate(zip(test_data, result_data), start=1):
# Deepcopy() is needed here because the task expects the input lists to be mutated.
# That mutation wrecks havoc with the verification and error messaging.
queue, person_name = deepcopy(params)
with self.subTest(f'variation #{variant}',
queue=queue,
person_name=person_name,
expected=expected):
actual_result = remove_the_mean_person(*params)
error_message = (f'Called remove_the_mean_person{queue, person_name}. '
f'The function returned {actual_result}, but '
f'The tests expected {expected} when removing '
f'{person_name} from the queue.')
self.assertListEqual(actual_result, expected, msg=error_message)
Test Failure
One or more variations of this test failed. Details can be found under each [variant#].
Test 5
- Failed … [variation #1]
Code Run
test_data = [(['Natasha', 'Steve', 'Ultron', 'Wanda', 'Rocket'], 'Ultron'),
(['Natasha', 'Steve', 'Wanda', 'Rocket', 'Ultron'], 'Ultron'),
(['Ultron', 'Natasha', 'Steve', 'Wanda', 'Rocket'], 'Ultron'),
]
result_data = [['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket']]
for variant, (params, expected) in enumerate(zip(test_data, result_data), start=1):
# Deepcopy() is needed here because the task expects the input lists to be mutated.
# That mutation wrecks havoc with the verification and error messaging.
queue, person_name = deepcopy(params)
with self.subTest(f'variation #{variant}',
queue=queue,
person_name=person_name,
expected=expected):
actual_result = remove_the_mean_person(*params)
error_message = (f'Called remove_the_mean_person{queue, person_name}. '
f'The function returned {actual_result}, but '
f'The tests expected {expected} when removing '
f'{person_name} from the queue.')
self.assertListEqual(actual_result, expected, msg=error_message)
Test Failure
AssertionError: First sequence is not a list: None
Test 6
- Failed … [variation #2]
Code Run
test_data = [(['Natasha', 'Steve', 'Ultron', 'Wanda', 'Rocket'], 'Ultron'),
(['Natasha', 'Steve', 'Wanda', 'Rocket', 'Ultron'], 'Ultron'),
(['Ultron', 'Natasha', 'Steve', 'Wanda', 'Rocket'], 'Ultron'),
]
result_data = [['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket']]
for variant, (params, expected) in enumerate(zip(test_data, result_data), start=1):
# Deepcopy() is needed here because the task expects the input lists to be mutated.
# That mutation wrecks havoc with the verification and error messaging.
queue, person_name = deepcopy(params)
with self.subTest(f'variation #{variant}',
queue=queue,
person_name=person_name,
expected=expected):
actual_result = remove_the_mean_person(*params)
error_message = (f'Called remove_the_mean_person{queue, person_name}. '
f'The function returned {actual_result}, but '
f'The tests expected {expected} when removing '
f'{person_name} from the queue.')
self.assertListEqual(actual_result, expected, msg=error_message)
Test Failure
AssertionError: First sequence is not a list: None
Test 7
- Failed … [variation #3]
Code Run
test_data = [(['Natasha', 'Steve', 'Ultron', 'Wanda', 'Rocket'], 'Ultron'),
(['Natasha', 'Steve', 'Wanda', 'Rocket', 'Ultron'], 'Ultron'),
(['Ultron', 'Natasha', 'Steve', 'Wanda', 'Rocket'], 'Ultron'),
]
result_data = [['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket'],
['Natasha', 'Steve', 'Wanda', 'Rocket']]
for variant, (params, expected) in enumerate(zip(test_data, result_data), start=1):
# Deepcopy() is needed here because the task expects the input lists to be mutated.
# That mutation wrecks havoc with the verification and error messaging.
queue, person_name = deepcopy(params)
with self.subTest(f'variation #{variant}',
queue=queue,
person_name=person_name,
expected=expected):
actual_result = remove_the_mean_person(*params)
error_message = (f'Called remove_the_mean_person{queue, person_name}. '
f'The function returned {actual_result}, but '
f'The tests expected {expected} when removing '
f'{person_name} from the queue.')
self.assertListEqual(actual_result, expected, msg=error_message)
Test Failure
AssertionError: First sequence is not a list: None