Skip to content

Commit 3c00e43

Browse files
committed
tests: add more test cases
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 721f340 commit 3c00e43

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/test_standard_metadata.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,22 @@ def test_load(
958958
],
959959
id="Four errors including extra keys",
960960
),
961+
pytest.param(
962+
"""
963+
[project]
964+
name = 'test'
965+
version = "0.1.0"
966+
import-names = ["test", "other"]
967+
import-namespaces = ["other.one.two", "invalid name", "not; public"]
968+
""",
969+
[
970+
"\"import-namespaces\" contains 'invalid name', which is not a valid identifier",
971+
"\"import-namespaces\" contains an ending tag other than '; private', got 'not; public'",
972+
"\"import-namespaces\" contains a Python keyword, which is not a valid import name, got 'not; public'",
973+
"\"project.import-namespaces\" is missing 'other.one', but submodules are present elsewhere",
974+
],
975+
id="Multiple errors related to names/namespaces",
976+
),
961977
],
962978
)
963979
def test_load_multierror(
@@ -1132,6 +1148,25 @@ def test_value(after_rfc: bool, monkeypatch: pytest.MonkeyPatch) -> None:
11321148
]
11331149

11341150

1151+
@pytest.mark.parametrize("after_rfc", [False, True])
1152+
def test_value_25(after_rfc: bool, monkeypatch: pytest.MonkeyPatch) -> None:
1153+
monkeypatch.chdir(DIR / "packages/metadata-2.5")
1154+
with open("pyproject.toml", "rb") as f:
1155+
metadata = pyproject_metadata.StandardMetadata.from_pyproject(tomllib.load(f))
1156+
1157+
if after_rfc:
1158+
metadata.as_rfc822()
1159+
1160+
assert metadata.auto_metadata_version == "2.5"
1161+
1162+
assert isinstance(metadata.license, str)
1163+
assert metadata.license == "MIT"
1164+
assert metadata.license_files == [pathlib.Path("LICENSE")]
1165+
1166+
assert metadata.import_names == ["full_metadata"]
1167+
assert metadata.import_namespaces == []
1168+
1169+
11351170
def test_read_license(monkeypatch: pytest.MonkeyPatch) -> None:
11361171
monkeypatch.chdir(DIR / "packages/full-metadata2")
11371172
with open("pyproject.toml", "rb") as f:

0 commit comments

Comments
 (0)