-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add async doctest support with top-level await #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #59 +/- ##
==========================================
- Coverage 71.11% 70.68% -0.43%
==========================================
Files 14 15 +1
Lines 914 1177 +263
==========================================
+ Hits 650 832 +182
- Misses 264 345 +81 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
why: Document new features and breaking changes for upcoming release what: - Add AsyncDocTestRunner feature with before/after code examples - Note pytest plugin integration - Document testdocutils -> run_doctest_docutils rename as breaking change
Code Review SummaryOverall Assessment: ✅ LGTM with one minor suggestion This PR implements async doctest support with top-level await functionality - a well-designed feature that follows stdlib patterns and includes comprehensive tests (all 108 tests pass). Issues FoundAfter thorough analysis by 5 specialized review agents (AGENTS.md compliance, bug scanning, git history, previous PR patterns, and code comments), only 1 issue met the confidence threshold for reporting: Import Style Violation (Confidence: 88/100)Location: Issue: AGENTS.md states: "Use namespace imports for stdlib: Note: The file already has Suggested fix: - from contextlib import AbstractContextManager
...
- class _Runner310(AbstractContextManager["_Runner310"]):
+ class _Runner310(contextlib.AbstractContextManager["_Runner310"]):What Looked Good
Filtered Issues (Below 80 confidence threshold)The following were considered but filtered out as style preferences rather than requirements:
|
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
why: Document new features and breaking changes for upcoming release what: - Add AsyncDocTestRunner feature with before/after code examples - Note pytest plugin integration - Document testdocutils -> run_doctest_docutils rename as breaking change
3bfe654 to
780890a
Compare
why: Document new features and breaking changes for upcoming release what: - Add AsyncDocTestRunner feature with before/after code examples - Note pytest plugin integration - Document testdocutils -> run_doctest_docutils rename as breaking change
why: Document new features and breaking changes for upcoming release what: - Add AsyncDocTestRunner feature with before/after code examples - Note pytest plugin integration - Document testdocutils -> run_doctest_docutils rename as breaking change
why: Prepare for asyncio development with consistent patterns what: - Add critical doctest rules (executable tests, no SKIP workarounds) - Add async doctest pattern with asyncio.run() - Add Asyncio Development section with subprocess patterns - Add async API conventions, testing patterns, and anti-patterns
…wait why: Enable clean async doctests without asyncio.run() boilerplate what: - Add _Runner310 shim for Python 3.10 compatibility (asyncio.Runner is 3.11+) - Add _run_doctest_example() with PyCF_ALLOW_TOP_LEVEL_AWAIT compile flag - Add AsyncDocTestRunner extending DocTestRunner with async support - Add AsyncDebugRunner for raise-on-error behavior - Rename testdocutils -> run_doctest_docutils to avoid pytest collection - Detect CO_COROUTINE flag to transparently handle sync vs async code
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
why: Make asyncio module available in doctests without explicit import what: - Add autouse doctest_namespace fixture - Inject asyncio module for use in async doctests
why: Verify async doctest functionality works correctly what: - Use functional pytest style with NamedTuple parametrization - Add RST and Markdown dual coverage for all test cases - Test basic top-level await with asyncio.sleep - Test async functions returning values - Test mixed sync/async examples in same block - Test state persistence across examples - Test async context managers (async with) - Test async iteration (async for) - Test async comprehensions - Test expected exceptions in async code - Add pytester-based plugin integration tests - Test conftest fixture integration with async - Test failure reporting for async doctests
why: Document new features and breaking changes for upcoming release what: - Add AsyncDocTestRunner feature with before/after code examples - Note pytest plugin integration - Document testdocutils -> run_doctest_docutils rename as breaking change
why: Comply with project coding standards requiring NumPy docstrings what: - Add Parameters/Returns sections to _rst_content, _md_content helpers - Add docstrings to _Runner310.__init__, __enter__, __exit__ methods
why: Comply with project docstring standards what: - Add Parameters section documenting debug and loop_factory - Add Returns section documenting return type
why: Comply with project requirement for working doctests what: - Add Examples section demonstrating basic async doctest usage - Shows top-level await working transparently
why: Document the new capability enabled by AsyncDocTestRunner what: - Replace asyncio.run() boilerplate with top-level await syntax - Show that await works directly in doctests now
Summary
Enable clean async doctests without
asyncio.run()boilerplate:Implementation
PyCF_ALLOW_TOP_LEVEL_AWAITcompile flagCO_COROUTINEflag to transparently handle sync vs async codeasyncio.Runnerper DocTest block (allowscreate_task()in one line,awaitin the next)_Runner310shim provides Python 3.10 compatibility (asyncio.Runner is 3.11+)testdocutils→run_doctest_docutilsto avoid pytest auto-collectionTest plan
>>> await asyncio.sleep(0)async with)async for)