Caris Moses <[email protected]> added the comment:
Hello,
I am still running into this issue. I have tested the following code with
Python 3.7.4, 3.7.5rc1 , and 3.8.0rc1.
from unittest import TestCase
from unittest.mock import patch, Mock, call
class MyObject:
def __init__(self):
self.foo = 0
self.bar = 0
def set_foo(self, value):
self.foo = value
def set_bar(self, value):
self.bar = value
def do_something():
o = MyObject()
o.set_foo(3)
o.set_bar(4)
return 'something unrelated'
class MyObjectTest(TestCase):
@patch('test_mock.MyObject.set_bar', autospec=True)
@patch('test_mock.MyObject.set_foo', autospec=True)
def test_do_something(self, mock_set_foo, mock_set_bar):
manager = Mock()
manager.attach_mock(mock_set_foo, 'set_foo_func')
manager.attach_mock(mock_set_bar, 'set_bar_func')
do_something()
assert manager.mock_calls == [call.set_foo_func(3),
call.set_bar_func(4)]
----------
nosy: +Caris Moses
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue21478>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com