With the newest version (3.15.0) the below code fails with AttributeError: 'itertools._tee' object has no attribute 'start'
foo.py
class Client:
def start(self):
pass
class Lock:
def create_client(self):
return Client()
def start(self):
self._client = self.create_client()
self._client.start()
test_foo.py
import foo
def test(mocker):
mocker.patch("foo.Client")
lock = foo.Lock()
mocker.spy(lock, "create_client")
lock.start()
The problem ist, that spy checks if the returned instance is an iterator, but each MagicMock is an iterator which leads to issues.
The logic should exclude any mock object IMO which should solve the issue
With the newest version (3.15.0) the below code fails with
AttributeError: 'itertools._tee' object has no attribute 'start'foo.py
test_foo.py
The problem ist, that spy checks if the returned instance is an iterator, but each
MagicMockis an iterator which leads to issues.The logic should exclude any mock object IMO which should solve the issue