testing-cabal / mock

The Python mock library

Home Page:https://docs.python.org/dev/library/unittest.mock.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

side_effect should be checked for iterable not callable

jazzblue opened this issue · comments

mock/mock/mock.py

Lines 1115 to 1116 in 7a6ff35

if not _callable(effect):
result = next(effect)

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.

This repo is only for backport related issues. Please report this upstream on https://bugs.python.org and a short code snippet of the expected and actual behavior will also help.

Thanks

OK, thanks, I have opened the issue:

https://bugs.python.org/issue36598