summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-ext-autodoc/target/coroutine.py15
-rw-r--r--tests/test_autodoc.py9
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/roots/test-ext-autodoc/target/coroutine.py b/tests/roots/test-ext-autodoc/target/coroutine.py
index 69602325d..692dd4883 100644
--- a/tests/roots/test-ext-autodoc/target/coroutine.py
+++ b/tests/roots/test-ext-autodoc/target/coroutine.py
@@ -1,3 +1,7 @@
+import asyncio
+from functools import wraps
+
+
class AsyncClass:
async def do_coroutine(self):
"""A documented coroutine function"""
@@ -16,3 +20,14 @@ class AsyncClass:
async def _other_coro_func():
return "run"
+
+
+def myawait(f):
+ @wraps(f)
+ def wrapper(*args, **kwargs):
+ awaitable = f(*args, **kwargs)
+ return asyncio.run(awaitable)
+ return wrapper
+
+
+sync_func = myawait(_other_coro_func)
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index cbbdbb787..6d57d795d 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -1379,6 +1379,15 @@ def test_coroutine():
'',
]
+ # force-synchronized wrapper
+ actual = do_autodoc(app, 'function', 'target.coroutine.sync_func')
+ assert list(actual) == [
+ '',
+ '.. py:function:: sync_func()',
+ ' :module: target.coroutine',
+ '',
+ ]
+
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_partialmethod(app):