From ef71ecbca004104b03fbef2bedc0e1f832dbf84b Mon Sep 17 00:00:00 2001 From: dasm Date: Tue, 27 May 2025 16:33:31 -0700 Subject: [PATCH] Fix doctest paths --- .../src/tmlt/nox_utils/_session_manager.py | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/nox-utils/src/tmlt/nox_utils/_session_manager.py b/nox-utils/src/tmlt/nox_utils/_session_manager.py index 0153500..9c95c28 100644 --- a/nox-utils/src/tmlt/nox_utils/_session_manager.py +++ b/nox-utils/src/tmlt/nox_utils/_session_manager.py @@ -91,16 +91,29 @@ def __init__( self._audit_suppressions = audit_suppressions or [] @property - def _code_dirs(self) -> list[Path]: + def _test_dirs(self) -> list[Path]: return [ p for p in [ - self._directory / "src", self._directory / "test", ] if p.exists() ] + @property + def _source_dirs(self) -> list[Path]: + return [ + p + for p in [ + self._directory / "src", + ] + if p.exists() + ] + + @property + def _code_dirs(self) -> list[Path]: + return self._source_dirs + self._test_dirs + def _build(self, sess: Session) -> None: """Build sdists and wheels for the package. @@ -286,8 +299,9 @@ def _test( *, min_coverage: Optional[int] = None, extra_args: Optional[list[str]] = None, + test_paths: [Optional[list[Path]]] = None, ) -> None: - test_paths = self._code_dirs + test_paths = self._code_dirs if test_paths is None else test_paths extra_args = extra_args or [] if sess.posargs: test_paths = [] @@ -348,7 +362,12 @@ def test_doctest(self) -> None: @install_group("test") def test_doctest(sess: Session) -> None: """Run tests on code examples in docstrings.""" - self._test(sess, min_coverage=0, extra_args=["--doctest-modules"]) + self._test( + sess, + min_coverage=0, + extra_args=["--doctest-modules"], + test_paths=self._source_dirs, + ) def _run_sphinx(self, sess: Session, builder: str) -> None: sphinx_options = ["-n", "-W", "--keep-going"]