Skip to content

Commit 7b575c2

Browse files
test: Read dependencies from pyproject.toml to generate metadata snapshots (#62)
Signed-off-by: Edgar Ramírez-Mondragón <edgarrm358@gmail.com>
1 parent 9f3e842 commit 7b575c2

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

tests/test_snapshots.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from __future__ import annotations
2424

2525
from copy import deepcopy
26+
from pathlib import Path
2627
from typing import TYPE_CHECKING, Any
2728

2829
import packaging
@@ -33,6 +34,7 @@
3334
from packaging.version import Version
3435

3536
from hatch_pinned_extra import PinnedExtraMetadataHook
37+
from hatch_pinned_extra._compat import read_toml
3638

3739
if TYPE_CHECKING:
3840
from packaging.metadata import RawMetadata
@@ -83,21 +85,11 @@ def test_snapshot_project_metadata(
8385
) -> None:
8486
"""Snapshot the METADATA content for the uv_lock/project fixture."""
8587
monkeypatch.setenv("HATCH_PINNED_EXTRA_ENABLE", "1")
88+
89+
pyproject = read_toml(Path("fixtures/uv_lock/project/pyproject.toml"))
8690
metadata: dict[str, Any] = {
87-
"dependencies": [
88-
"anyio>=4.5.2",
89-
"boto3>=1.36.15",
90-
"colorama; sys_platform == 'win32'",
91-
"exceptiongroup>=1.2.2",
92-
"importlib-resources; python_version < '3.10'",
93-
"fastapi>=0.115.8",
94-
],
95-
"optional-dependencies": {
96-
"dev": [
97-
"pytest>=8; python_version >= '3.13'",
98-
"pytest>=7,<8; python_version < '3.13'",
99-
],
100-
},
91+
"dependencies": pyproject["project"]["dependencies"],
92+
"optional-dependencies": pyproject["project"]["optional-dependencies"],
10193
}
10294
hook = PinnedExtraMetadataHook("fixtures/uv_lock/project", {"extra-name": "pinned"})
10395

@@ -119,10 +111,10 @@ def test_snapshot_extras_metadata(
119111
) -> None:
120112
"""Snapshot the METADATA content for the uv_lock/extras fixture."""
121113
monkeypatch.setenv("HATCH_PINNED_EXTRA_ENABLE", "1")
114+
115+
pyproject = read_toml(Path("fixtures/uv_lock/extras/pyproject.toml"))
122116
metadata: dict[str, Any] = {
123-
"dependencies": [
124-
"fastapi[standard]>=0.115.12",
125-
],
117+
"dependencies": pyproject["project"]["dependencies"],
126118
}
127119
hook = PinnedExtraMetadataHook("fixtures/uv_lock/extras", {"extra-name": "pinned"})
128120

0 commit comments

Comments
 (0)