Skip to content

Commit 8baa9de

Browse files
committed
pytest_doctest_docutils(feat[async]): Integrate AsyncDocTestRunner
why: Provide async doctest support in pytest plugin what: - Import AsyncDocTestRunner from doctest_docutils - Change PytestDoctestRunner to extend AsyncDocTestRunner - Async support is now transparent for all doctest files
1 parent cd93773 commit 8baa9de

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/pytest_doctest_docutils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
from _pytest import outcomes
2424
from _pytest.outcomes import OutcomeException
2525

26-
from doctest_docutils import DocutilsDocTestFinder, _ensure_directives_registered
26+
from doctest_docutils import (
27+
AsyncDocTestRunner,
28+
DocutilsDocTestFinder,
29+
_ensure_directives_registered,
30+
)
2731

2832
if t.TYPE_CHECKING:
2933
import pathlib
@@ -137,11 +141,11 @@ def _is_doctest(
137141
def _init_runner_class() -> type[doctest.DocTestRunner]:
138142
import doctest
139143

140-
class PytestDoctestRunner(doctest.DebugRunner):
141-
"""Runner to collect failures.
144+
class PytestDoctestRunner(AsyncDocTestRunner):
145+
"""Runner to collect failures with async support.
142146
143-
Note that the out variable in this case is a list instead of a
144-
stdout-like object.
147+
Extends AsyncDocTestRunner to enable top-level await in doctests.
148+
The out variable in this case is a list instead of a stdout-like object.
145149
"""
146150

147151
def __init__(

0 commit comments

Comments
 (0)