Skip to content

Commit ca77126

Browse files
authored
Merge pull request #13475 from notatallshaw/use-dependency-groups-for-test-requirements
Use dependency groups for test requirements
2 parents 2887964 + 86c3d04 commit ca77126

File tree

4 files changed

+35
-37
lines changed

4 files changed

+35
-37
lines changed

noxfile.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
}
2727
REQUIREMENTS = {
2828
"docs": "docs/requirements.txt",
29-
"tests": "tests/requirements.txt",
30-
"common-wheels": "tests/requirements-common_wheels.txt",
3129
}
3230

3331
AUTHORS_FILE = "AUTHORS.txt"
@@ -54,10 +52,10 @@ def should_update_common_wheels() -> bool:
5452
if not os.path.exists(LOCATIONS["common-wheels"]):
5553
return True
5654

57-
# If the requirements was updated after cache, we'll repopulate it.
55+
# If the pyproject.toml was updated after cache, we'll repopulate it.
5856
cache_last_populated_at = os.path.getmtime(LOCATIONS["common-wheels"])
59-
requirements_updated_at = os.path.getmtime(REQUIREMENTS["common-wheels"])
60-
need_to_repopulate = requirements_updated_at > cache_last_populated_at
57+
pyproject_updated_at = os.path.getmtime("pyproject.toml")
58+
need_to_repopulate = pyproject_updated_at > cache_last_populated_at
6159

6260
# Clear the stale cache.
6361
if need_to_repopulate:
@@ -78,7 +76,7 @@ def test(session: nox.Session) -> None:
7876
session,
7977
"wheel",
8078
"-w", LOCATIONS["common-wheels"],
81-
"-r", REQUIREMENTS["common-wheels"],
79+
"--group", "test-common-wheels",
8280
)
8381
# fmt: on
8482
else:
@@ -115,7 +113,7 @@ def test(session: nox.Session) -> None:
115113
run_with_protected_pip(session, "install", generated_sdist)
116114

117115
# Install test dependencies
118-
run_with_protected_pip(session, "install", "-r", REQUIREMENTS["tests"])
116+
run_with_protected_pip(session, "install", "--group", "test")
119117

120118
# Parallelize tests as much as possible, by default.
121119
arguments = session.posargs or ["-n", "auto"]

pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,36 @@ Changelog = "https://pip.pypa.io/en/stable/news/"
4848
requires = ["setuptools>=77"]
4949
build-backend = "setuptools.build_meta"
5050

51+
[dependency-groups]
52+
test = [
53+
"cryptography",
54+
"freezegun",
55+
"installer",
56+
"pytest",
57+
"pytest-cov",
58+
"pytest-rerunfailures",
59+
"pytest-xdist",
60+
"scripttest",
61+
"setuptools",
62+
# macOS (darwin) arm64 always uses virtualenv >= 20.0
63+
# for other platforms, it depends on python version
64+
"virtualenv < 20.0 ; python_version < '3.10' and (sys_platform != 'darwin' or platform_machine != 'arm64')",
65+
"virtualenv >= 20.0 ; python_version >= '3.10' or (sys_platform == 'darwin' and platform_machine == 'arm64')",
66+
"werkzeug",
67+
"wheel",
68+
"tomli-w",
69+
"proxy.py",
70+
]
71+
72+
test-common-wheels = [
73+
# We pin setuptools<80 because our test suite currently
74+
# depends on setup.py develop to generate egg-link files.
75+
"setuptools >= 40.8.0, != 60.6.0, <80",
76+
"wheel",
77+
# As required by pytest-cov.
78+
"coverage >= 4.4",
79+
]
80+
5181
[tool.setuptools]
5282
package-dir = {"" = "src"}
5383
include-package-data = false

tests/requirements-common_wheels.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/requirements.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)