Skip to content

Commit 6a8898a

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

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright © 2019 Filipe Laíns <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a
4+
copy of this software and associated documentation files (the "Software"),
5+
to deal in the Software without restriction, including without limitation
6+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
and/or sell copies of the Software, and to permit persons to whom the
8+
Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice (including the next
11+
paragraph) shall be included in all copies or substantial portions of the
12+
Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
DEALINGS IN THE SOFTWARE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
some readme 👋

tests/packages/metadata-2.5/metadata25.py

Whitespace-only changes.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[project]
2+
name = 'metadata25'
3+
version = '3.2.1'
4+
description = 'A package with all the metadata :)'
5+
readme = 'README.md'
6+
license = "MIT"
7+
license-files = ["LICENSE"]
8+
keywords = ['trampolim', 'is', 'interesting']
9+
authors = [
10+
{ email = '[email protected]' },
11+
{ name = 'Example!' },
12+
]
13+
maintainers = [
14+
{ name = 'Other Example', email = '[email protected]' },
15+
]
16+
classifiers = [
17+
'Development Status :: 4 - Beta',
18+
'Programming Language :: Python',
19+
]
20+
21+
requires-python = '>=3.8'
22+
dependencies = [
23+
'dependency1',
24+
'dependency2>1.0.0',
25+
'dependency3[extra]',
26+
'dependency4; os_name != "nt"',
27+
'dependency5[other-extra]>1.0; os_name == "nt"',
28+
]
29+
import-names = ["metadata25"]
30+
31+
[project.optional-dependencies]
32+
test = [
33+
'test_dependency',
34+
'test_dependency[test_extra]',
35+
'test_dependency[test_extra2] > 3.0; os_name == "nt"',
36+
]
37+
38+
[project.urls]
39+
homepage = 'example.com'
40+
documentation = 'readthedocs.org'
41+
repository = 'github.com/some/repo'
42+
changelog = 'github.com/some/repo/blob/master/CHANGELOG.rst'
43+
44+
[project.scripts]
45+
full-metadata = 'full_metadata:main_cli'
46+
47+
[project.gui-scripts]
48+
full-metadata-gui = 'full_metadata:main_gui'
49+
50+
[project.entry-points.custom]
51+
full-metadata = 'full_metadata:main_custom'

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 == ["metadata25"]
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)