Skip to content

Commit

Permalink
Project standardization 2 (#130)
Browse files Browse the repository at this point in the history
* removing exclusion for `__init__.py`
* removing __version__.py blanket exclusion
* adding test for copyright in `__init__.py`
  • Loading branch information
bandophahita authored Feb 20, 2024
1 parent 59dc96f commit c75cee2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 30 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down Expand Up @@ -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"]


################################################################################
Expand Down
16 changes: 8 additions & 8 deletions screenpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# ____ ____
# / ___| ___ _ __ ___ ___ _ __ | _ \ _ _
# \___ \ / __| '__/ _ \/ _ \ '_ \| |_) | | | |
Expand All @@ -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) 20192024 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
Expand All @@ -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,
Expand All @@ -52,7 +52,7 @@
Performable,
Resolvable,
)
from .resolutions import * # noqa
from .resolutions import * # noqa: F403

# Natural-language-enabling syntactic sugar
AnActor = Actor
Expand Down
4 changes: 2 additions & 2 deletions screenpy/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
18 changes: 0 additions & 18 deletions tests/test__version__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
from __future__ import annotations

from datetime import datetime
from pathlib import Path

from screenpy import __version__


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
27 changes: 27 additions & 0 deletions tests/test_copyright.py
Original file line number Diff line number Diff line change
@@ -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__

0 comments on commit c75cee2

Please sign in to comment.