I did some research on side effects and as I understand it it's supposed to have the values pulled from an iterable on each call. But I'm not sure why it's not printing 1, 2 but instead
<MagicMock name='bar' id='4448537616'>
<MagicMock name='bar' id='4448537616'>
class Foo():
def __init__(self):
self.bar = 'foo'
pass
from unittest import mock
def test_foo():
f = Foo()
with mock.patch.object(f, 'bar', side_effect=[1,2]) :
print(f.bar)
print(f.bar)
test_foo()
But if I do f.bar()
I get the actual value, but bar
is supposed to be an attribute not a function.
Is my understanding of how side_effects work incorrect?