Skip to content

Commit

Permalink
Added release information tests, prepared pyproject.toml for release
Browse files Browse the repository at this point in the history
  • Loading branch information
fjwillemsen committed Jun 2, 2023
1 parent e510e32 commit 57eff78
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]

[project] # https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#declaring-project-metadata
name = "autotuning_methodology"
version = "0.1.0.b1"
version = "0.1.0b1"
authors = [
{name = "Floris-Jan Willemsen", email = "fjwillemsen97@gmail.com"},
]
Expand All @@ -28,13 +28,12 @@ dependencies = [
"progressbar2 >= 4.2.0",
"jsonschema >= 4.17.3",
"nonconformist >= 2.1.0",
"kernel_tuner @ git+https://github.com/KernelTuner/kernel_tuner.git",
"kernel_tuner >= 0.4.5",
]

[project.optional-dependencies]
dev = [
"pylint >=2.14.4",
"toml >= 0.10.2",
"black >= 23.3.0",
]
docs = [
Expand All @@ -49,6 +48,7 @@ test = [
"pytest-cov >= 4.0.0",
"nox >= 2023.4.22",
"crepes >= 0.2.0",
"tomli >= 2.0.1", # can be replaced by built-in [tomllib](https://docs.python.org/3.11/library/tomllib.html) from Python 3.11
]

[project.scripts]
Expand All @@ -67,6 +67,7 @@ addopts = "--cov --cov-config=.coveragerc --cov-report html --cov-report term-mi
testpaths = [
"tests/unit",
"tests/integration",
"tests/release",
]

[tool.black]
Expand Down
66 changes: 66 additions & 0 deletions tests/autotuning_methodology/release/test_toml_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Tests for release information."""

from importlib.resources import files
from pathlib import Path

import tomli

package_root = Path(files("autotuning_methodology")).parent.parent
pyproject_toml_path = package_root / "pyproject.toml"
assert pyproject_toml_path.exists()
with open(pyproject_toml_path, mode="rb") as fp:
pyproject = tomli.load(fp)


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
assert "project" in pyproject


def test_name():
"""Ensure the name is consistent."""
assert "name" in pyproject["project"]
assert pyproject["project"]["name"] == "autotuning_methodology"


def test_versioning():
"""Test whether the versioning is PEP440 compliant."""
from pep440 import is_canonical

assert "version" in pyproject["project"]
assert is_canonical(pyproject["project"]["version"])


def test_authors():
"""Ensure the authors are specified."""
assert "authors" in pyproject["project"]
assert len(pyproject["project"]["authors"]) > 0


def test_license():
"""Ensure the license is set and the file exists."""
assert "license" in pyproject["project"]
license = pyproject["project"]["license"]
assert len(license) > 0
assert license["file"] == "LICENSE"
assert Path(package_root / "LICENSE").exists()


def test_readme():
"""Ensure the readme is set and the file exists."""
assert "readme" in pyproject["project"]
readme = pyproject["project"]["readme"]
assert len(readme) > 0
assert Path(package_root / readme).exists()


def test_project_keys():
"""Check whether the expected keys in [project] are present."""
project = pyproject["project"]
assert "description" in project
assert "keywords" in project
assert "classifiers" in project
assert "dependencies" in project
assert "requires-python" in project

0 comments on commit 57eff78

Please sign in to comment.