inspect: Implement iscoroutinefunction and iscoroutine.

Signed-off-by: Damien George <damien@micropython.org>
master v1.25.0
Damien George 2025-04-14 10:24:54 +10:00
rodzic 2665047fa7
commit 5b496e944e
3 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -25,6 +25,11 @@ def isgenerator(obj):
return isinstance(obj, type((_g)()))
# In MicroPython there's currently no way to distinguish between generators and coroutines.
iscoroutinefunction = isgeneratorfunction
iscoroutine = isgenerator
class _Class:
def meth():
pass

Wyświetl plik

@ -1,3 +1,3 @@
metadata(version="0.1.2")
metadata(version="0.1.3")
module("inspect.py")

Wyświetl plik

@ -44,6 +44,12 @@ class TestInspect(unittest.TestCase):
def test_isgenerator(self):
self._test_is_helper(inspect.isgenerator, entities[2])
def test_iscoroutinefunction(self):
self._test_is_helper(inspect.iscoroutinefunction, entities[1])
def test_iscoroutine(self):
self._test_is_helper(inspect.iscoroutine, entities[2])
def test_ismethod(self):
self._test_is_helper(inspect.ismethod, entities[5])