这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions nox-utils/src/tmlt/nox_utils/_session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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"]
Expand Down