Skip to content

Commit fecd38d

Browse files
committed
docs(doctest_docutils[AsyncDocTestRunner]): Add doctest example
why: Comply with project requirement for working doctests what: - Add Examples section demonstrating basic async doctest usage - Shows top-level await working transparently
1 parent d4926bb commit fecd38d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/doctest_docutils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,21 @@ class AsyncDocTestRunner(doctest.DocTestRunner):
600600
state to persist across examples within the same block.
601601
602602
Usage is identical to doctest.DocTestRunner - async support is automatic.
603+
604+
Examples
605+
--------
606+
>>> import doctest
607+
>>> from doctest_docutils import AsyncDocTestRunner
608+
>>> runner = AsyncDocTestRunner(verbose=False)
609+
>>> test = doctest.DocTest(
610+
... [doctest.Example("import asyncio", ""),
611+
... doctest.Example("await asyncio.sleep(0)", ""),
612+
... doctest.Example("1 + 1", "2\\n")],
613+
... {}, "example", "example.py", 0, None
614+
... )
615+
>>> result = runner.run(test)
616+
>>> result.failed
617+
0
603618
"""
604619

605620
def run(

0 commit comments

Comments
 (0)