We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed81f34 commit b71f036Copy full SHA for b71f036
umock.py
@@ -55,10 +55,17 @@
55
def is_awaitable(obj):
56
"""
57
Returns a boolean indication if the passed in obj is an awaitable
58
- function. (MicroPython treats awaitables as generator functions.)
+ function. (MicroPython treats awaitables as generator functions, and if
59
+ the object is a closure containing an async function we need to tread
60
+ carefully.)
61
62
if is_micropython:
63
+ # MicroPython doesn't appear to have a way to determine if a closure is
64
+ # an async function except via the repr. This is a bit hacky.
65
+ if "<closure <generator>" in repr(obj):
66
+ return True
67
return inspect.isgeneratorfunction(obj)
68
+
69
return inspect.iscoroutinefunction(obj)
70
71
0 commit comments