Switch to inspect.getcoroutinefunction() can break testing with unittest.mock.patch() #2983
-
In v0.46.0, Starlette switched from import sys, asyncio, inspect
from unittest.mock import create_autospec
async def foo():
pass
mock = create_autospec(foo)
print(sys.version_info[:2]) # (3, 12)
print(asyncio.iscoroutinefunction(mock)) # True
print(inspect.iscoroutinefunction(mock)) # False Specifically this is python/cpython#94924, which has been fixed in Python 3.13 but has not been backported. I found this because our tests started to fail after upgrading Starlette in one of our projects. Could starlette make the switch conditional? E.g.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, please. |
Beta Was this translation helpful? Give feedback.
Yes, please.