Skip to content

Commit 4ba761b

Browse files
committed
🔧 Template: add Hatch environment and script for tests
Add the `tests` environment with a `run` script that runs `pytest` with: hatch run tests:run
1 parent 1c78348 commit 4ba761b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

‎template/docs/developer.md.jinja‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@ And the following rules for the files in the `tests` directory:
5151
| --------- | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
5252
| `INP001` | [implicit-namespace-package](https://docs.astral.sh/ruff/rules/implicit-namespace-package/) | When tests are not part of the package, there is no need for `__init__.py` files. |
5353
| `S101` | [assert](https://docs.astral.sh/ruff/rules/assert/) | Asserts should not be used in production environments, but are fine for tests. |
54+
55+
### Tests
56+
57+
Tests are written using the [`pytest` package](https://docs.pytest.org/en/stable/index.html).
58+
They can be run using:
59+
60+
hatch run tests:run

‎template/pyproject.toml.jinja‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ dependencies = ["pre-commit"]
4949
scripts.install = "pre-commit install"
5050
scripts.run = "pre-commit run {args:--all-files}"
5151

52+
[tool.hatch.envs.tests]
53+
dependencies = ["pytest"]
54+
scripts.run = "pytest {args}"
55+
5256
[tool.ruff]
5357
lint.ignore = [
5458
"TRY003", # https://docs.astral.sh/ruff/rules/raise-vanilla-args/

0 commit comments

Comments
 (0)