Skip to content

feat(tests): enable --doctest-modules in pytest configuration#3922

Open
haoyu-haoyu wants to merge 2 commits intosourmash-bio:latestfrom
haoyu-haoyu:feat/enable-doctests
Open

feat(tests): enable --doctest-modules in pytest configuration#3922
haoyu-haoyu wants to merge 2 commits intosourmash-bio:latestfrom
haoyu-haoyu:feat/enable-doctests

Conversation

@haoyu-haoyu
Copy link
Copy Markdown

Summary

Enable automatic doctest discovery for Python source modules by adding --doctest-modules to pytest and src/sourmash to testpaths.

Changes

pyproject.toml:

  • Add --doctest-modules to [tool.pytest.ini_options] addopts
  • Add "src/sourmash" to testpaths so pytest collects doctests from source files

Why

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 tested doc/*.md doctests via --doctest-glob. Adding --doctest-modules with src/sourmash in testpaths ensures source-level doctests are collected and run alongside unit tests.

Notes

  • The -n4 parallel flag is compatible with --doctest-modules (xdist handles collection correctly)
  • Source doctests that import sourmash require the compiled Rust extension, which is available in CI but not in bare Python environments

Closes #897

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

execute doctests in our continuous integration setup

1 participant