-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathtest_toml_file.py
More file actions
72 lines (54 loc) · 2.11 KB
/
Copy pathtest_toml_file.py
File metadata and controls
72 lines (54 loc) · 2.11 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
"""Tests for release information."""
from pathlib import Path
import tomllib
package_root = Path(".").parent.parent
pyproject_toml_path = package_root / "pyproject.toml"
assert pyproject_toml_path.exists()
with open(pyproject_toml_path, mode="rb") as fp:
pyproject = tomllib.load(fp)
project = pyproject["project"] if "project" in pyproject else pyproject["tool"]["poetry"]
def test_read():
"""Test whether the contents have been read correctly and the required keys are in place."""
assert isinstance(pyproject, dict)
assert "build-system" in pyproject
def test_name():
"""Ensure the name is consistent."""
assert "name" in project
assert project["name"] == "python-constraint2"
def test_versioning():
"""Test whether the versioning is PEP440 compliant."""
from pep440 import is_canonical
assert "version" in project
assert is_canonical(project["version"])
def test_authors():
"""Ensure the authors are specified."""
assert "authors" in project
assert len(project["authors"]) > 0
def test_license():
"""Ensure the license is set and the file exists."""
assert "license" in project
license = project["license"]
if isinstance(license, dict):
assert "file" in license
license = project["license"]["file"]
assert isinstance(license, str)
assert len(license) > 0
if license == "LICENSE":
assert Path(package_root / license).exists()
def test_readme():
"""Ensure the readme is set and the file exists."""
assert "readme" in project
readme = project["readme"]
if isinstance(readme, dict):
assert "file" in readme
readme = project["readme"]["file"]
assert isinstance(readme, str)
assert len(readme) > 0
assert readme[:6] == "README"
assert Path(package_root / readme).exists()
def test_project_keys():
"""Check whether the expected keys in [project] or [tool.poetry] are present."""
assert "description" in project
assert "keywords" in project
assert "classifiers" in project
assert "requires-python" in project or "python" in pyproject["tool"]["poetry"]["dependencies"]