From f6185ba82dc429e98b66b25bd4e9de93c8a8c242 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Sun, 23 Feb 2020 12:53:45 -0500 Subject: [PATCH] Update about file with less sketchy loading system Remove importlib usage from about file Add tests to enforce data consistency between pyproject and about Update sphinx config to use new about file Remove pyproject from package --- docs/conf.py | 2 +- keyosk/__about__.py | 15 +++------------ keyosk/pyproject.toml | 1 - tests/test_about.py | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 14 deletions(-) delete mode 120000 keyosk/pyproject.toml create mode 100644 tests/test_about.py diff --git a/docs/conf.py b/docs/conf.py index a2ca944..3b452ec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,7 +13,7 @@ with open(Path(BASE_DIR, "..", "keyosk", "__about__.py")) as infile: project = ABOUT["__title__"] copyright = "2019, Ethan Paul" -author = ", ".join(ABOUT["__authors__"]) +author = "Ethan Paul " # The full version, including alpha/beta/rc tags release = ABOUT["__version__"] diff --git a/keyosk/__about__.py b/keyosk/__about__.py index e5a233e..2f76b77 100644 --- a/keyosk/__about__.py +++ b/keyosk/__about__.py @@ -1,12 +1,3 @@ -"""Access package info programatically without duplication""" -import importlib.resources - -import toml - -PYPROJECT = toml.loads(importlib.resources.read_text("keyosk", "pyproject.toml")) - -__authors__ = PYPROJECT["tool"]["poetry"]["authors"] -__summary__ = PYPROJECT["tool"]["poetry"]["description"] -__title__ = PYPROJECT["tool"]["poetry"]["name"] -__url__ = PYPROJECT["tool"]["poetry"]["repository"] -__version__ = PYPROJECT["tool"]["poetry"]["version"] +# pylint: disable=missing-docstring +__version__ = "0.1.0-alpha-1" +__title__ = "keyosk" diff --git a/keyosk/pyproject.toml b/keyosk/pyproject.toml deleted file mode 120000 index 1e11d78..0000000 --- a/keyosk/pyproject.toml +++ /dev/null @@ -1 +0,0 @@ -../pyproject.toml \ No newline at end of file diff --git a/tests/test_about.py b/tests/test_about.py new file mode 100644 index 0000000..a232119 --- /dev/null +++ b/tests/test_about.py @@ -0,0 +1,22 @@ +from pathlib import Path + +import toml + +from keyosk import __about__ + + +PYPROJECT_PATH = Path("pyproject.toml") + + +def test_version(): + with PYPROJECT_PATH.open() as infile: + pyproject = toml.load(infile) + + assert __about__.__version__ == pyproject["tool"]["poetry"]["version"] + + +def test_title(): + with PYPROJECT_PATH.open() as infile: + pyproject = toml.load(infile) + + assert __about__.__title__ == pyproject["tool"]["poetry"]["name"]