feat(tests): enable --doctest-modules in pytest configuration#3922
Open
haoyu-haoyu wants to merge 2 commits intosourmash-bio:latestfrom
Open
feat(tests): enable --doctest-modules in pytest configuration#3922haoyu-haoyu wants to merge 2 commits intosourmash-bio:latestfrom
haoyu-haoyu wants to merge 2 commits intosourmash-bio:latestfrom
Conversation
Add --doctest-modules to pytest addopts so doctests embedded in Python source files (e.g., sourmash/minhash.py, sourmash/lca/lca_utils.py) are executed during CI test runs alongside the existing doc/*.md doctests. Closes sourmash-bio#897
--doctest-modules only scans modules under collected paths. Without src/sourmash in testpaths, doctests in source files like minhash.py and lca/lca_utils.py would not be collected during CI runs.
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.
Summary
Enable automatic doctest discovery for Python source modules by adding
--doctest-modulesto pytest andsrc/sourmashtotestpaths.Changes
pyproject.toml:--doctest-modulesto[tool.pytest.ini_options] addopts"src/sourmash"totestpathsso pytest collects doctests from source filesWhy
Issue #897 noted that doctests in source files (e.g.,
sourmash/minhash.py,sourmash/lca/lca_utils.py) were never executed in CI. The existing config only testeddoc/*.mddoctests via--doctest-glob. Adding--doctest-moduleswithsrc/sourmashintestpathsensures source-level doctests are collected and run alongside unit tests.Notes
-n4parallel flag is compatible with--doctest-modules(xdist handles collection correctly)sourmashrequire the compiled Rust extension, which is available in CI but not in bare Python environmentsCloses #897