Yes, a generator can’t be equal to a string.
When your call your function: get_objects("anything")
, it returns a generator object you can iterate over to get the values.
If you want to check if the i
th element returned is equal to something
, do:
for i, elem in enumerate(get_objects("bla bla")):
if i == 3:
return self.assertEqual(elem, something)
2
solved How to test Generators in Python 3. It gives error all the time