You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the introduction of asyncio-compatible methods in the Proxy class, starting from version 1.6.0 of this library, a bunch of tests for a project I have started breaking. The reason is, I use unittest.mock.patch with an object that is fetched from a Proxy, however now since the Proxy implements coroutine methods the patch function always identifies it as asynchronous, which have the effect of making some of my view functions return a coroutine (an AsyncMock instance) instead of a Response object.
I'd like to suggest that someone creates explicit AsyncProxy and SyncProxy classes to avoid this kind of issue, so that it's clear whether the proxied object should be async-compatible or not.
Thanks!
The text was updated successfully, but these errors were encountered:
ionelmc
changed the title
Proxy not playing well with mock patching and Django
Non async versions of Proxy classes
Dec 15, 2023
Hi folks,
Since the introduction of asyncio-compatible methods in the Proxy class, starting from version
1.6.0
of this library, a bunch of tests for a project I have started breaking. The reason is, I useunittest.mock.patch
with an object that is fetched from a Proxy, however now since the Proxy implements coroutine methods the patch function always identifies it as asynchronous, which have the effect of making some of my view functions return a coroutine (anAsyncMock
instance) instead of a Response object.I'd like to suggest that someone creates explicit AsyncProxy and SyncProxy classes to avoid this kind of issue, so that it's clear whether the proxied object should be async-compatible or not.
Thanks!
The text was updated successfully, but these errors were encountered: