This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jazzblue
Recipients jazzblue
Date 2019-04-11.04:12:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1554955978.5.0.68760722366.issue36598@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-04-11 04:12:58jazzbluesetrecipients: + jazzblue
2019-04-11 04:12:58jazzbluesetmessageid: <1554955978.5.0.68760722366.issue36598@roundup.psfhosted.org>
2019-04-11 04:12:58jazzbluelinkissue36598 messages
2019-04-11 04:12:58jazzbluecreate