Message339923
In mock.py, in method:
def _mock_call(_mock_self, *args, **kwargs):
There is a following piece of code:
if not _callable(effect):
result = next(effect)
if _is_exception(result):
raise result
if result is DEFAULT:
result = self.return_value
return result
ret_val = effect(*args, **kwargs)
This works correctly for iterables (such as lists) that are not defined as generators.
However, if one defined a generator as a function this would not work.
It seems like the check should be not for callable, but for iterable:
try:
iter(effect)
except TypeError:
# If not iterable then callable or exception
if _callable(effect):
ret_val = effect(*args, **kwargs)
else:
raise effect
else: # Iterable
result = next(effect)
if _is_exception(result):
raise result
if result is DEFAULT:
result = self.return_value
return result |
|
Date |
User |
Action |
Args |
2019-04-11 04:12:58 | jazzblue | set | recipients:
+ jazzblue |
2019-04-11 04:12:58 | jazzblue | set | messageid: <1554955978.5.0.68760722366.issue36598@roundup.psfhosted.org> |
2019-04-11 04:12:58 | jazzblue | link | issue36598 messages |
2019-04-11 04:12:58 | jazzblue | create | |
|