Skip to content

Commit 009d9c1

Browse files
committed
chore: migrate to hatch managed environments
Refs: KEH-282
1 parent 6455457 commit 009d9c1

3 files changed

Lines changed: 73 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,44 @@ graphql_api = [
4545
"graphql-core<3,>=2.1",
4646
"graphql-relay<3,>=2",
4747
]
48+
test = [
49+
"pytest",
50+
"pytest-django",
51+
"pytest-cov",
52+
]
53+
all = ["django-ilmoitin[test,graphql_api]"]
4854

4955
[project.urls]
5056
Homepage = "https://github.com/City-of-Helsinki/django-ilmoitin"
5157

52-
[tool.hatch.build.targets.wheel]
53-
packages = ["django_ilmoitin"]
54-
5558
[tool.coverage.run]
5659
source = ["django_ilmoitin"]
5760
omit = ["**/migrations/*", "**/tests/*"]
5861

62+
[tool.hatch.build.targets.wheel]
63+
packages = ["django_ilmoitin"]
64+
65+
[tool.hatch.envs.default]
66+
dependencies = [
67+
"django~=5.2",
68+
"pre-commit",
69+
]
70+
features = ["all"]
71+
python = "3.10"
72+
73+
[tool.hatch.envs.default.scripts]
74+
test = "pytest {args}"
75+
lint = [
76+
"pre-commit install",
77+
"pre-commit run -a",
78+
]
79+
manage = "tests/manage.py {args}"
80+
81+
[tool.hatch.envs.hatch-uv]
82+
dependencies = [
83+
"uv==0.11.2",
84+
]
85+
5986
[tool.pytest.ini_options]
6087
testpaths = [
6188
"tests",
@@ -96,3 +123,6 @@ select = [
96123
# flake8-print
97124
"T20",
98125
]
126+
127+
[tool.uv]
128+
exclude-newer = "14 days"

tests/manage.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
4+
import os
5+
import sys
6+
7+
8+
def main():
9+
"""Run administrative tasks."""
10+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
11+
try:
12+
from django.core.management import execute_from_command_line
13+
except ImportError as exc:
14+
raise ImportError(
15+
"Couldn't import Django. Are you sure it's installed and "
16+
"available on your PYTHONPATH environment variable? Did you "
17+
"forget to activate a virtual environment?"
18+
) from exc
19+
execute_from_command_line(sys.argv)
20+
21+
22+
if __name__ == "__main__":
23+
main()

tests/settings.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
1+
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite3"}}
22

33
INSTALLED_APPS = (
44
"django.contrib.contenttypes",
@@ -20,6 +20,22 @@
2020
"django.contrib.messages.middleware.MessageMiddleware",
2121
]
2222

23+
TEMPLATES = [
24+
{
25+
"BACKEND": "django.template.backends.django.DjangoTemplates",
26+
"DIRS": [],
27+
"APP_DIRS": True,
28+
"OPTIONS": {
29+
"context_processors": [
30+
"django.template.context_processors.debug",
31+
"django.template.context_processors.request",
32+
"django.contrib.auth.context_processors.auth",
33+
"django.contrib.messages.context_processors.messages",
34+
],
35+
},
36+
},
37+
]
38+
2339
SITE_ID = 1
2440
ROOT_URLCONF = "tests.urls"
2541
DEBUG = True

0 commit comments

Comments
 (0)