Skip to content

Commit

Permalink
kraken-build/: feature: Add pytest(include_dirs) to add additional …
Browse files Browse the repository at this point in the history
…directories for testing (#156)
  • Loading branch information
NiklasRosenstein authored Jan 7, 2024
1 parent 1a524a6 commit 81a739e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kraken-build/.changelog/_unreleased.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ id = "03c2043b-e016-400c-900a-6f0844877de0"
type = "improvement"
description = "`Currentable.as_current()` now returns self"
author = "@NiklasRosenstein"

[[entries]]
id = "c778f849-7552-4bde-ace4-34190fa84c8d"
type = "feature"
description = "Add `pytest(include_dirs)` to add additional directories for testing"
author = "@NiklasRosenstein"
4 changes: 4 additions & 0 deletions kraken-build/src/kraken/std/python/tasks/pytest_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PytestTask(EnvironmentAwareDispatchTask):
python_dependencies = ["pytest"]

tests_dir: Property[Path]
include_dirs: Property[Sequence[Path]] = Property.default(())
ignore_dirs: Property[Sequence[Path]] = Property.default_factory(list)
allow_no_tests: Property[bool] = Property.default(False)
doctest_modules: Property[bool] = Property.default(True)
Expand All @@ -53,6 +54,7 @@ def get_execute_command(self) -> list[str] | TaskStatus:
"-vv",
str(self.project.directory / self.settings.source_directory),
str(self.project.directory / tests_dir),
*[str(self.project.directory / path) for path in self.include_dirs.get()],
]
command += flatten(["--ignore", str(self.project.directory / path)] for path in self.ignore_dirs.get())
command += ["--log-cli-level", "INFO"]
Expand Down Expand Up @@ -85,6 +87,7 @@ def pytest(
group: str = "test",
project: Project | None = None,
tests_dir: Path | None = None,
include_dirs: Sequence[Path] = (),
ignore_dirs: Sequence[Path] = (),
allow_no_tests: bool = False,
doctest_modules: bool = True,
Expand All @@ -94,6 +97,7 @@ def pytest(
project = project or Project.current()
task = project.task(name, PytestTask, group=group)
task.tests_dir = tests_dir
task.include_dirs = include_dirs
task.ignore_dirs = ignore_dirs
task.allow_no_tests = allow_no_tests
task.doctest_modules = doctest_modules
Expand Down

0 comments on commit 81a739e

Please sign in to comment.