Repository navigation
test(docs): Run plain Python and console fences - #219
Merged
Merged
Conversation
why: Verify copy-pasteable Python blocks, runnable console commands, and MyST literalinclude directives across README.md and docs/ in pytest and CI alongside existing doctests. what: - Add tests/_docs_codeblocks.py and wire conftest.py pytest_collect_file - Register pytest documentation marker and allow exec in docs harness - Execute plain python fences in isolation (UTF-8, explicit imports, sandboxed tempfile.tempdir) and run uncalled test_* functions and Test* classes via real pytest fixtures - Parse CommonMark 4.5 and MyST code-block/colon directives, enforce strict doctest vs plain-python separation, and fail CI on unclassified or trailing-line console blocks and recursive pytest - Keep unpacked sdists passing when scripts/justfile/.git are absent and keep the harness out of wheels and pytest11 entry points - Convert pytest_plugin and quickstart fixture blocks to plain python, classify MIGRATION Before/After blocks, add negative-control tests, and update WRITING.md, CONTRIBUTING.md, and CHANGES
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #217
1. Owner and boundary
README.mdanddocs/**/*.mdnow live intests/_docs_codeblocks.py, wired viapytest_collect_filein rootconftest.pyand markeddocumentationinpyproject.toml. Keeping the harness undertests/preservesdependencies = [], side-effect-freeimport libvt, lazypytest11discovery, sdist inclusion, and alibvt-only wheel.sync/async, CLI/API, single/batch, orN/A): Checkedpytest_doctest_docutils(gp-libs) coexistence so>>>doctests keep running without double execution,tests/test_libvt.py(test_markdown_code_fences_are_collected_and_classified,test_documented_examples_include_explicit_imports),MIGRATIONhistorical# Before/# Afterblocks,{literalinclude}directives,vt_snapshottwo-pass--snapshot-update+ deterministic.ambrmatch whensyrupyis active (skipping cleanly when absent), unpacked sdist layouts withoutscripts//justfile/.git, anddocs/api/pytest_plugin.md+docs/quickstart.mdplainpythonfixture blocks.tests/and rootconftest.py; VT emulation semantics are unchanged so VT byte-replay comparisons inREVIEW.mdsection 2 are inapplicable.2. Failure before the fix (
N/Afor docs, lockfile bumps, or pure refactors)<base>commit, or<pre_fix_head>SHA if fixing a defect introduced in this PR):b77d7e4(master).b77d7e4, adding a plainpythonfence without>>>prompts was rejected bytest_markdown_python_fences_carry_doctest_promptsrather than executed, and none of the 30consolefences or 6{literalinclude}directives acrossREADME.mdanddocs/ran underpytest. After adding the harness, negative controls confirmed failures on a broken plainpythonfence inREADME.md, a broken plainpythonfence indocs/quickstart.md, a broken runnableconsolefence indocs/topics/interactive-game.md, an unclassifiedconsolefence indocs/quickstart.md, trailing plain-Python lines after doctests,--recordand.////path-normalization sandbox escapes, non-read-only scripts, recursive/multi--mpytest targets, POSIX octalprintfescapes, symlinkedTMPDIRfallbacks, non-deterministic and unusedvt_snapshotblocks, replay output mismatches, and disabling the unclassified-fence guard intests/_docs_codeblocks.py.3. Verification and tool disclosure
N/A):uv run ruff check .,uv run ruff format --check .,uv run ty checkacross Python3.12–3.15and--python-version 3.12 --python-platform win32,PYTHONDONTWRITEBYTECODE=1 uv run python -B scripts/check_workarounds.py,uv run pytest -m documentation(41 passed),uv run pytest -m ""(1410 passed, 3 skipped),uv run sphinx-build -W -b dirhtml -d docs/_build/doctrees docs docs/_build/html, anduv buildwheel cleanliness (48libvt-only entries) plus unpacked-sdist verification (37 passed, 4 skippedon-m documentation README.md docsand12 passedontests/test_docs_codeblocks.py)..github/workarounds.tomlupdates (Noneif none):None.git,gh,uv,ruff,ty,pytest,sphinx-build.