Im trying patch an async property on a mock instance.
class Foo:
@property
async def bar(self) -> bool:
return True
foo_mock = AsyncMock(Foo)
foo_mock.bar.return_value = False
assert await foo_mock.bar is False
but it fails with
> assert await foo_mock.bar is False
E TypeError: object MagicMock can't be used in 'await' expression
When the @property is not async it works as intended.
There is a similar question but the answer relies on patching the class instead of working with a mock instance which isn't an option for me. Mocking an Async Property in Python