-
Notifications
You must be signed in to change notification settings - Fork 0
Backports for doctest
#56
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
Merged
Merged
Conversation
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
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #56 +/- ##
==========================================
+ Coverage 62.58% 71.11% +8.52%
==========================================
Files 11 14 +3
Lines 695 914 +219
==========================================
+ Hits 435 650 +215
- Misses 260 264 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tony
added a commit
that referenced
this pull request
Nov 25, 2025
what: - pytest autouse fixtures fix (backport from pytest 9cd14b4ff) - doctest directive whitespace fix (backport from Sphinx ad0c343d3)
tony
added a commit
that referenced
this pull request
Nov 25, 2025
Backport: pytest commit 9cd14b4ff (2024-02-06) Ref: pytest-dev/pytest@9cd14b4ff what: - Test autouse fixtures from conftest.py with .rst/.md doctests - Parametrized over scopes: module, session, class, function - Parametrized over file types: .rst, .md (8 test cases total) Refs: pytest-dev/pytest#11929
tony
added a commit
that referenced
this pull request
Nov 25, 2025
Backport: Sphinx commit ad0c343d3 (2025-01-04) Ref: sphinx-doc/sphinx@ad0c343d3 what: - Test doctestopt_re regex removes leading whitespace before flags - Covers trailing spaces, tabs, multiline, mixed whitespace - 6 test cases using NamedTuple parametrization Refs: sphinx-doc/sphinx#13164
why: Document analysis of upstream changes for informed backporting decisions what: - Comprehensive audit of 115 commits across CPython, pytest, and Sphinx (2022-2025) - Documents applicability of each commit to gp-libs architecture - Identifies 2 backports needed: pytest 9cd14b4ff, Sphinx ad0c343d3 - Explains why gp-libs inherits most fixes automatically via stdlib/dependencies
Backport: pytest commit 9cd14b4ff (2024-02-06) Ref: pytest-dev/pytest@9cd14b4ff why: Autouse fixtures were not being discovered for doctest files what: - Add parsefactories() call to DocTestDocutilsFile.collect() - Ensures session fixture manager processes the doctest module - Allows autouse fixtures from conftest.py to apply to doctests
Backport: Sphinx commit ad0c343d3 (2025-01-04) Ref: sphinx-doc/sphinx@ad0c343d3 why: Doctest directive comments with leading whitespace were not recognized what: - Add [ \t]* prefix to doctestopt_re pattern - Allows doctest options like " # doctest: +SKIP" to be properly parsed - Fixes edge case where indented doctest directive comments were ignored
…module method why: Method is unreachable and would fail if called what: - Remove _from_module override from DocutilsDocTestFinder - Method called super()._from_module() but class has no parent - Copied from pytest's MockAwareDocTestFinder but not applicable here - DocutilsDocTestFinder parses documents, not Python modules - Remove unused functools import
what: - pytest autouse fixtures fix (backport from pytest 9cd14b4ff) - doctest directive whitespace fix (backport from Sphinx ad0c343d3)
Backport: pytest commit 9cd14b4ff (2024-02-06) Ref: pytest-dev/pytest@9cd14b4ff what: - Test autouse fixtures from conftest.py with .rst/.md doctests - Parametrized over scopes: module, session, class, function - Parametrized over file types: .rst, .md (8 test cases total) Refs: pytest-dev/pytest#11929
Backport: Sphinx commit ad0c343d3 (2025-01-04) Ref: sphinx-doc/sphinx@ad0c343d3 what: - Test doctestopt_re regex removes leading whitespace before flags - Covers trailing spaces, tabs, multiline, mixed whitespace - 6 test cases using NamedTuple parametrization Refs: sphinx-doc/sphinx#13164
cdda92f to
ed9c8bd
Compare
…outing tests why: Ensure plugin suppression/precedence works correctly across pytest 7.x/8.x what: - Test automatic doctest plugin blocking via pytest_configure - Test explicit -p no:doctest behavior with addopts - Test restoring builtin doctest via -p no:pytest_doctest_docutils - Test plugin precedence with -p no:X -p X patterns - Test collector routing: .py uses DoctestModule, .rst/.md use DocTestDocutilsFile - Use NamedTuple + test_id parametrization pattern Ref: pytest's test_pluginmanager.py (lines 442-483) for plugin blocking patterns
why: Ensure doctest options work correctly in document files what: - Test ELLIPSIS, NORMALIZE_WHITESPACE via doctest_optionflags ini setting - Test combined ELLIPSIS + NORMALIZE_WHITESPACE - Test inline # doctest: +SKIP and +ELLIPSIS directives - Test --doctest-continue-on-failure behavior - Test custom flags: ALLOW_UNICODE, NUMBER - Test edge cases: empty files, files without doctests - Use NamedTuple + test_id parametrization pattern Ref: pytest's test_doctest.py option flag test patterns
why: Ensure plugin works across recent pytest major versions what: - Add pytest-version matrix to CI workflow (pytest 7 and 8) - Install specific pytest version after uv sync - Print pytest version in CI logs for verification - Exclude pytest 7 from Python 3.14 (reduce matrix size)
why: Ensure plugin compatibility with latest pytest major version what: - Add pytest 9 to CI test matrix alongside pytest 7 and 8 - Tests now run against all three recent major versions
why: Test new pluginmanager.unblock() API introduced in pytest 8.1.0 what: - Add PYTEST_VERSION constant for version detection - Add requires_pytest_version() marker helper for version-specific tests - Add test_unblock_api_available() for pytest 8.1+ unblock() API - Test skips automatically on pytest < 8.1 Ref: pytest 8.1.0 changelog - pluginmanager.unblock() public API
why: Test new --disable-plugin-autoload CLI flag introduced in pytest 8.4.0 what: - Add test_disable_plugin_autoload_flag() for flag recognition - Add test_disable_plugin_autoload_with_explicit_plugin() for explicit plugin loading - Tests skip automatically on pytest < 8.4 Ref: pytest 8.4.0 changelog - --disable-plugin-autoload CLI flag
… 8.1+ why: Enable programmatic re-enabling of built-in doctest plugin using the public unblock() API introduced in pytest 8.1.0. what: - Add PYTEST_VERSION constant for version-specific feature detection - Add _unblock_doctest() helper that uses pluginmanager.unblock() when available, with graceful fallback for older pytest versions
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.
Backport upstream doctest bug fixes and add pytest 7/8/9 compatibility
Summary
This PR backports critical bug fixes from upstream pytest and Sphinx, adds pytest version compatibility features, and ensures compatibility across pytest 7.x, 8.x, and 9.x.
Bug Fixes
pytest_doctest_docutils
conftest.pynow properly discovered for doctest filesdoctest_docutils
# doctest: +SKIP) now properly matchedNew Features
pytest_doctest_docutils
_unblock_doctest()helper - Programmatic re-enabling of built-in doctest pluginpluginmanager.unblock()API (pytest 8.1+)Development Improvements
CI Enhancements
Test Coverage
unblock()API--disable-plugin-autoloadflagCode Quality
_from_module()method (unused since Python 3.13+)Documentation
notes/2025-11-25-upstream-backports.md