-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
86 lines (74 loc) · 2.56 KB
/
noxfile.py
File metadata and controls
86 lines (74 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""Nox file."""
import nox
# The dictionary of supported Django and Python versions.
SUPPORTED_VERSIONS = {
"4.2": ["3.10", "3.11", "3.12"],
"5.0": ["3.10", "3.11", "3.12"],
"5.1": ["3.10", "3.11", "3.12", "3.13"],
"5.2": ["3.10", "3.11", "3.12", "3.13", "3.14"],
"6.0": ["3.12", "3.13", "3.14"],
}
# The list of all supported Python versions across all Django versions.
# This list is used by the @nox.session decorator to create virtual environments.
python_versions = sorted({py_ver for python_list in SUPPORTED_VERSIONS.values() for py_ver in python_list})
@nox.session(venv_backend="uv", python=python_versions)
@nox.parametrize("django_ver", sorted(SUPPORTED_VERSIONS.keys()))
def test(session: nox.Session, django_ver: str) -> None:
"""Run the test suite for supported Python/Django combinations."""
# Check if the current Python version is supported for the given Django version.
# If not, skip the session.
if session.python not in SUPPORTED_VERSIONS[django_ver]:
session.skip(
f"Python {session.python} is not a supported version for Django {django_ver}",
)
# Install dependencies from your project and pyproject.toml.
session.install("-e", ".", "--extra", "test", "-r", "pyproject.toml")
# Install the correct Django version for the current session.
session.install(f"django~={django_ver}.0")
# Run your tests using pytest.
session.run("pytest")
TIME_ZONES = [
"US/Samoa",
"America/Adak",
"Pacific/Marquesas",
"America/Anchorage",
"America/Ensenada",
"America/Boise",
"America/Bahia_Banderas",
"America/Atikokan",
"America/Anguilla",
"America/St_Johns",
"America/Araguaina",
"America/Godthab",
"Atlantic/Azores",
"Africa/Abidjan",
"Africa/Algiers",
"Africa/Blantyre",
"Africa/Addis_Ababa",
"Asia/Tehran",
"Asia/Baku",
"Asia/Kabul",
"Antarctica/Mawson",
"Asia/Calcutta",
"Asia/Kathmandu",
"Asia/Bishkek",
"Asia/Rangoon",
"Antarctica/Davis",
"Antarctica/Casey",
"Australia/Eucla",
"Asia/Chita",
"Australia/Adelaide",
"Antarctica/DumontDUrville",
"Australia/LHI",
"Asia/Magadan",
"Antarctica/McMurdo",
"NZ-CHAT",
"Etc/GMT-13",
"Etc/GMT-14",
]
@nox.session(venv_backend="uv", python=["3.13"])
@nox.parametrize("time_zone", TIME_ZONES)
def test_timezones(session: nox.Session, time_zone: str) -> None:
"""Run the test suite."""
session.install("-e", ".", "--extra", "test", "-r", "pyproject.toml")
session.run("pytest", env={"TEST_TIME_ZONE": time_zone})