Using unittest.mock.PropertyMock
(available since Python 3.3):
from unittest import mock
with mock.patch.object(Foo, 'foo', new_callable=mock.PropertyMock) as m:
m.return_value = 'nAME'
assert Foo.foo == 'nAME'
NOTE: If you use Python version lower than 3.3, use mock
.