Skip to content

Commit d035013

Browse files
authored
Use zip_longest for handling test data comparison
Handle situation when a wrong number of items is got.
1 parent 62ac923 commit d035013

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

exercises/concept/ellens-alien-game/classes_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from functools import zip_longest
12
import unittest
23
import pytest
34

@@ -204,7 +205,7 @@ def test_new_aliens_collection(self):
204205
for obj in actual_result:
205206
self.assertIsInstance(obj, Alien, msg=error_message)
206207

207-
for position, obj in zip(test_data, actual_result):
208+
for position, obj in zip_longest(test_data, actual_result):
208209
position_error = (f'After calling new_aliens_collection({test_data}), '
209210
f'found {obj} initialized to position {(obj.x_coordinate, obj.y_coordinate)}, '
210211
f'but the tests expected {obj} to be at position {position} instead.')

0 commit comments

Comments
 (0)