From c75cee2ed31662539662bdd8babb930d412030bb Mon Sep 17 00:00:00 2001 From: Marcel Wilson Date: Tue, 20 Feb 2024 10:38:52 -0600 Subject: [PATCH] Project standardization 2 (#130) * removing exclusion for `__init__.py` * removing __version__.py blanket exclusion * adding test for copyright in `__init__.py` --- pyproject.toml | 3 +-- screenpy/__init__.py | 16 ++++++++-------- screenpy/__version__.py | 4 ++-- tests/test__version__.py | 18 ------------------ tests/test_copyright.py | 27 +++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 tests/test_copyright.py diff --git a/pyproject.toml b/pyproject.toml index b8d5c83..ad14969 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,8 +39,6 @@ extend-exclude = ''' target-version = "py38" # minimum supported version line-length = 88 # same as Black. extend-exclude = [ - "__init__.py", - "__version__.py", "docs", ] @@ -124,6 +122,7 @@ split-on-trailing-comma = false "FBT", # using a boolean as a test object is useful! "PLR", # likewise using specific numbers and strings in tests. ] +"__version__.py" = ["D"] ################################################################################ diff --git a/screenpy/__init__.py b/screenpy/__init__.py index 57264eb..94acc79 100644 --- a/screenpy/__init__.py +++ b/screenpy/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # ____ ____ # / ___| ___ _ __ ___ ___ _ __ | _ \ _ _ # \___ \ / __| '__/ _ \/ _ \ '_ \| |_) | | | | @@ -8,19 +6,21 @@ # |___/ """ - ScreenPy + ScreenPy. + FADE IN: -INT. SITEPACKAGES DIRECTORY + +INT. SITEPACKAGES DIRECTORY. ScreenPy is a composition-based test framework. It is inspired by the SerenityBDD library for Java. -:copyright: (c) 2019–2024 by Perry Goy. +:copyright: (c) 2019-2024 by Perry Goy. :license: MIT, see LICENSE for more details. """ from . import actions, narration, resolutions -from .actions import * # noqa +from .actions import * # noqa: F403 from .actor import Actor from .configuration import settings from .directions import noted, noted_under, the_noted @@ -41,7 +41,7 @@ UnableToPerform, ) from .given_when_then import and_, given, given_that, then, when -from .narration import * # noqa +from .narration import * # noqa: F403 from .pacing import act, aside, beat, scene, the_narrator from .protocols import ( Adapter, @@ -52,7 +52,7 @@ Performable, Resolvable, ) -from .resolutions import * # noqa +from .resolutions import * # noqa: F403 # Natural-language-enabling syntactic sugar AnActor = Actor diff --git a/screenpy/__version__.py b/screenpy/__version__.py index b28fa22..c640947 100644 --- a/screenpy/__version__.py +++ b/screenpy/__version__.py @@ -7,9 +7,9 @@ |___/ """ -import importlib.metadata as importlib_metadata +import importlib.metadata -metadata = importlib_metadata.metadata("screenpy") +metadata = importlib.metadata.metadata("screenpy") __title__ = metadata["Name"] __description__ = metadata["Summary"] diff --git a/tests/test__version__.py b/tests/test__version__.py index 4c1c02d..c1dfad5 100644 --- a/tests/test__version__.py +++ b/tests/test__version__.py @@ -1,8 +1,5 @@ from __future__ import annotations -from datetime import datetime -from pathlib import Path - from screenpy import __version__ @@ -10,18 +7,3 @@ def test_metadata() -> None: assert __version__.__title__ == "screenpy" assert __version__.__license__ == "MIT" assert __version__.__author__ == "Perry Goy" - - -def test_copyright_year() -> None: - current = datetime.now().year - - assert f"{current}" in __version__.__copyright__ - - -def test_copyright_year_in_license() -> None: - current = datetime.now().year - license_path = Path(__file__).parent / ".." / "LICENSE" - with open(license_path) as fp: - license_text = fp.read() - - assert f"{current}" in license_text diff --git a/tests/test_copyright.py b/tests/test_copyright.py new file mode 100644 index 0000000..b415e09 --- /dev/null +++ b/tests/test_copyright.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +from datetime import datetime +from pathlib import Path + +import pytest + +from screenpy import __doc__, __version__ + + +class TestCopyrightYear: + @pytest.fixture(autouse=True) + def _setup(self) -> None: + self.current_year = datetime.now().year + + def test_version(self) -> None: + assert f"{self.current_year}" in __version__.__copyright__ + + def test_license(self) -> None: + license_path = Path(__file__).parent / ".." / "LICENSE" + with open(license_path) as fp: + license_text = fp.read() + + assert f"{self.current_year}" in license_text + + def test_init(self) -> None: + assert f"{self.current_year}" in __doc__