From 19a98629d7f016fecacaf76e0a31c7f05d421ab9 Mon Sep 17 00:00:00 2001 From: Marcel Wilson Date: Tue, 20 Feb 2024 10:38:29 -0600 Subject: [PATCH] Project standardization (#51) * rearrange pyproject for easier sync between packages * sync tox.ini * sync mypy.ini * sync lint.yaml * sync poetry.yml * sync .gitignore * test__version__.py * avoiding https://github.com/ScreenPyHQ/screenpy_selenium/issues/36 * adding copyright year test * sync conf.py * setting up docs installation via pyproject.toml * centering ascii art * adjusting boilerplate pyproject.toml * cleaner test format * sync conf.py * adding license copyright test * sync pyproject.toml * adding test for copyright in `__init__.py` --- .github/workflows/lint.yml | 8 +- .github/workflows/poetry.yml | 2 +- .gitignore | 3 + .readthedocs.yaml | 7 +- LICENSE | 2 +- Makefile | 33 +++-- docs/conf.py | 59 ++++----- mypy.ini | 2 +- poetry.lock | 39 +++++- pyproject.toml | 217 ++++++++++++++++--------------- screenpy_selenium/__init__.py | 18 +-- screenpy_selenium/__version__.py | 17 +-- tests/test_copyright.py | 27 ++++ tox.ini | 5 + 14 files changed, 253 insertions(+), 186 deletions(-) create mode 100644 tests/test_copyright.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9507910..5577de5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,15 +28,13 @@ jobs: shell: bash run: | python -m pip install --upgrade pip - pip install -e .[dev-all] + pip install -e .[dev] - name: Lint with black run: | - black --check --diff screenpy_selenium - black --check --diff tests + black --check --diff . - name: Lint with ruff run: | ruff check . - name: Lint with mypy run: | - mypy screenpy_selenium - mypy tests + mypy . diff --git a/.github/workflows/poetry.yml b/.github/workflows/poetry.yml index 05bd919..6d0f8e5 100644 --- a/.github/workflows/poetry.yml +++ b/.github/workflows/poetry.yml @@ -34,6 +34,6 @@ jobs: - name: Check toml structure run: poetry check - + - name: Check lock file run: poetry lock --check diff --git a/.gitignore b/.gitignore index 9b6c533..577b667 100644 --- a/.gitignore +++ b/.gitignore @@ -144,3 +144,6 @@ dmypy.json # Pyre type checker .pyre/ + +# ruff linter +.ruff_cache/ diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e572217..04d4682 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -3,11 +3,14 @@ version: 2 build: os: "ubuntu-20.04" tools: - python: "3.11" + python: "3.12" sphinx: configuration: docs/conf.py python: install: - - requirements: docs/rtd-requirements.txt + - method: pip + path: . + extra_requirements: + - docs diff --git a/LICENSE b/LICENSE index d8edffb..799975a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022-2023 Perry Goy +Copyright (c) 2022-2024 Perry Goy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index b47e564..5b6a012 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,17 @@ -# shortcuts +# shortcuts to help manage flipping between branches with different dependencies sync: - poetry install --extras dev_all --sync + poetry install --extras dev --sync update_lock_only: poetry update --lock update: update_lock_only - poetry install --extras dev_all + poetry install --extras dev check: poetry check -trunk_screenpy: - poetry add screenpy git+ssh://git@github.com:ScreenPyHQ/screenpy.git#trunk - -local_screenpy: - pip uninstall screenpy - pip install -e ~/projects/screenpy - -.PHONY: sync update trunk_screenpy local_screenpy +.PHONY: sync update_lock_only update check black-check: black --check . @@ -42,3 +35,21 @@ pre-check-in: black-check ruff-check mypy pre-check-in-fix: black-fix ruff-fix mypy .PHONY: pre-check-in pre-check-in-fix + +# requires poetry-plugin-export +requirements: + poetry export --without-hashes --extras dev -f requirements.txt > requirements.txt + +.PHONY: requirements + +################################################################################ +# sub-package specific + +trunk_screenpy: + poetry add screenpy git+ssh://git@github.com:ScreenPyHQ/screenpy.git#trunk + +local_screenpy: + pip uninstall screenpy + pip install -e ~/projects/screenpy + +.PHONY: trunk_screenpy local_screenpy diff --git a/docs/conf.py b/docs/conf.py index 94dcc1a..0b02a68 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,6 @@ # Configuration file for the Sphinx documentation builder. # -# This file only contains a selection of the most common options. For a full -# list see the documentation: +# For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- @@ -9,49 +8,40 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. - +# import os import sys - sys.path.insert(0, os.path.abspath("./ext")) sys.path.insert(0, os.path.abspath("../")) -from screenpy_selenium.__version__ import __version__, __author__, __copyright__ # noqa: need the path first +from screenpy_selenium.__version__ import __version__, __author__, __copyright__ autodoc_mock_imports = ["selenium", "screenpy", "screenpy_pyotp"] # -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'screenpy_selenium' +project = "screenpy_selenium" copyright = __copyright__ author = __author__ - -# The full version, including alpha/beta/rc tags release = __version__ # -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. extensions = [ - "sphinx.ext.intersphinx", "sphinx.ext.autodoc", "sphinx.ext.autosectionlabel", + "sphinx.ext.intersphinx", + "sphinx_rtd_theme", "autodoc_skip_protocols", ] -intersphinx_mapping = { - "screenpy": ("https://screenpy-docs.readthedocs.io/en/latest/", None), - "selenium": ("https://selenium-python.readthedocs.io/", None), - "screenpy_pyotp": ("https://screenpy-pyotp-docs.readthedocs.io/en/latest/", None), -} - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] rst_prolog = """.. Substitutions @@ -62,24 +52,21 @@ .. |ActionChains| replace:: :external+selenium:class:`~selenium.webdriver.common.action_chains.ActionChains` """ -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - - # -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'default' +html_theme = "sphinx_rtd_theme" +html_static_path = [] -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Other HTML settings autodoc_member_order = "bysource" add_module_names = False + + +# -- Options for intersphinx extension --------------------------------------- + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "screenpy": ("https://screenpy-docs.readthedocs.io/en/latest/", None), + "selenium": ("https://selenium-python.readthedocs.io/", None), + "screenpy_pyotp": ("https://screenpy-pyotp-docs.readthedocs.io/en/latest/", None), +} diff --git a/mypy.ini b/mypy.ini index ff3681c..8a39d78 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,7 +2,6 @@ show_error_codes = True exclude = (?x)( setup\.py -; | tests/ | docs/ ) @@ -10,4 +9,5 @@ exclude = (?x)( disallow_untyped_defs = True [mypy-tests.*] +disallow_untyped_defs = True ignore_missing_imports = True diff --git a/poetry.lock b/poetry.lock index 5313bf9..0136b4d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1285,6 +1285,25 @@ docs = ["sphinxcontrib-websupport"] lint = ["docutils-stubs", "flake8 (>=3.5.0)", "flake8-simplify", "isort", "mypy (>=0.990)", "ruff", "sphinx-lint", "types-requests"] test = ["cython", "filelock", "html5lib", "pytest (>=4.6)"] +[[package]] +name = "sphinx-rtd-theme" +version = "2.0.0" +description = "Read the Docs theme for Sphinx" +optional = true +python-versions = ">=3.6" +files = [ + {file = "sphinx_rtd_theme-2.0.0-py2.py3-none-any.whl", hash = "sha256:ec93d0856dc280cf3aee9a4c9807c60e027c7f7b461b77aeffed682e68f0e586"}, + {file = "sphinx_rtd_theme-2.0.0.tar.gz", hash = "sha256:bd5d7b80622406762073a04ef8fadc5f9151261563d47027de09910ce03afe6b"}, +] + +[package.dependencies] +docutils = "<0.21" +sphinx = ">=5,<8" +sphinxcontrib-jquery = ">=4,<5" + +[package.extras] +dev = ["bump2version", "sphinxcontrib-httpdomain", "transifex-client", "wheel"] + [[package]] name = "sphinxcontrib-applehelp" version = "1.0.4" @@ -1330,6 +1349,20 @@ files = [ lint = ["docutils-stubs", "flake8", "mypy"] test = ["html5lib", "pytest"] +[[package]] +name = "sphinxcontrib-jquery" +version = "4.1" +description = "Extension to include jQuery on newer Sphinx releases" +optional = true +python-versions = ">=2.7" +files = [ + {file = "sphinxcontrib-jquery-4.1.tar.gz", hash = "sha256:1620739f04e36a2c779f1a131a2dfd49b2fd07351bf1968ced074365933abc7a"}, + {file = "sphinxcontrib_jquery-4.1-py2.py3-none-any.whl", hash = "sha256:f936030d7d0147dd026a4f2b5a57343d233f1fc7b363f68b3d4f1cb0993878ae"}, +] + +[package.dependencies] +Sphinx = ">=1.8" + [[package]] name = "sphinxcontrib-jsmath" version = "1.0.1" @@ -1529,11 +1562,11 @@ docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.link testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] [extras] -dev = ["pre-commit", "pytest", "tox"] -dev-all = ["black", "coverage", "mypy", "pre-commit", "pytest", "ruff", "sphinx", "tox"] +dev = ["black", "coverage", "mypy", "pre-commit", "pytest", "ruff", "sphinx", "sphinx-rtd-theme", "tox"] +docs = ["sphinx", "sphinx-rtd-theme"] test = ["coverage", "pytest"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "58d914781efe541f9a8b6411a11276d3bcc2817e464a000da361624ff28d5034" +content-hash = "c0d2a1ed45a89c7d474720e5a8075f4cb4d3cbd286caaafb9061884b4dd73c65" diff --git a/pyproject.toml b/pyproject.toml index 16d87d2..c44b8c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,25 @@ +# This pyproject.toml is setup so it can be used with or without poetry and also +# supports editable installs (PEP 660) without breaking IDE and linter inspection. + +# DEVELOPER INSTALL INSTRUCTIONS (assuming current directory is at the top of the project) : +# Poetry: +# poetry install --extras dev +# PIP: +# pip install -e .[dev] + +# everything in the boilerplate *SHOULD* match between the ScreenPyHQ packages. +################################################################################ +# START OF BOILERPLATE ScreenPyHQ CONFIGURATIONS # +################################################################################ + + +[build-system] +requires = ["poetry-core>=1.6.1"] +build-backend = "poetry.core.masonry.api" + + [tool.black] target-version = ['py312'] - extend-exclude = ''' # A regex preceded with ^/ will apply only to files and directories # in the root of the project. @@ -15,107 +34,18 @@ extend-exclude = ''' ''' -# This pyproject.toml is setup so it can be used with or without poetry and also -# supports editable installs (PEP 660) without breaking IDE and linter inspection. - -# DEVELOPER INSTALL INSTRUCTIONS (assuming current directory is at the top of the project) : -# Poetry: -# poetry install --extras dev -# PIP: -# pip install -e .[dev] - -[tool.poetry] -name = "screenpy_selenium" -version = "4.0.4" -description = "ScreenPy extension to enable interacting with Selenium." -authors = ["Perry Goy "] -maintainers = ["Gabe Langton", "Marcel Wilson"] -license = "MIT" -repository = "https://github.com/ScreenPyHQ/screenpy_selenium" -documentation = "https://screenpy-selenium-docs.readthedocs.io" -readme = "README.md" -classifiers = [ - "Operating System :: OS Independent", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Topic :: Software Development :: Quality Assurance", - "Topic :: Software Development :: Testing", - "Topic :: Software Development :: Testing :: BDD", - "Natural Language :: English", - "License :: OSI Approved :: MIT License", -] - -# It's possible to add optional dependencies with the poetry CLI tool using: -# poetry add --optional some_dev_pkg -# This will set `optional = true` flag in [tool.poetry.dependencies], as seen below -# But then you need to remember to manually edit the [tool.poetry.extras] dev section -# and declare the package. This allows `pip install .[dev]` to work as expected -# Poetry users will need to use the `--extras dev` option rather than the `--with dev` -# so we dont have two different sets of package versions to update. - -[tool.poetry.dependencies] -python = "^3.8" -screenpy = ">=4.0.2" -screenpy_pyotp = ">=4.0.0" -selenium = ">=4.1.0" -importlib_metadata = {version = "*", python = "3.8.*"} - -# convenience packages for development of screenpy only -black = {version = "*", optional = true} -coverage = {version = "*", optional = true} -mypy = {version = "*", optional = true} -pre-commit = {version = "*", optional = true} -pytest = {version = "*", optional = true} -ruff = {version = ">=0.2.0", optional = true} -sphinx = {version = "*", optional = true} -tox = {version = "*", optional = true} - -[tool.poetry.extras] -dev = [ - "pre-commit", - "pytest", - "tox", -] -dev_all = [ - "black", - "coverage", - "mypy", - "pre-commit", - "pytest", - "ruff", - "sphinx", - "tox", -] -test = [ - "coverage", - "pytest", -] - -[build-system] -requires = ["poetry-core>=1.2.0"] -build-backend = "poetry.core.masonry.api" - [tool.ruff] target-version = "py38" # minimum supported version line-length = 88 # same as Black. - extend-exclude = [ - "screenpy_selenium/__init__.py", - "screenpy_selenium/__version__.py", "docs", ] [tool.ruff.lint] select = [ "A", # flake8-builtins - "ANN", # flake8-annotations # coming back to this one later to compare against mypy + "ANN", # flake8-annotations "ARG", # flake8-unused-arguments "B", # flake8-bugbear "BLE", # flake8-blind-except @@ -161,8 +91,7 @@ ignore = [ ] extend-safe-fixes = [ - "EM101", - "EM102", + "EM101", "EM102", "TCH001", "TCH002", "TCH003", "TCH004", "C419", "D200", "D205", "D415", @@ -171,30 +100,106 @@ extend-safe-fixes = [ "UP006", "UP007", ] +[tool.ruff.lint.flake8-pytest-style] +mark-parentheses = false + +[tool.ruff.lint.pycodestyle] +ignore-overlong-task-comments = true + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.flake8-type-checking] +strict = true + +[tool.ruff.lint.isort] +combine-as-imports = true +split-on-trailing-comma = false + [tool.ruff.lint.per-file-ignores] "tests/**" = [ "D", # we don't need public-API-polished docstrings in tests. "FBT", # using a boolean as a test object is useful! "PLR", # likewise using specific numbers and strings in tests. ] - -[tool.ruff.lint.isort] -combine-as-imports = true -split-on-trailing-comma = false -known-first-party = ["screenpy_selenium", "tests"] +"__version__.py" = ["D"] -[tool.ruff.lint.flake8-pytest-style] -mark-parentheses = false +################################################################################ +# END OF BOILERPLATE ScreenPyHQ CONFIGURATIONS # +################################################################################ +[tool.poetry] +name = "screenpy_selenium" +version = "4.0.4" +description = "ScreenPy extension to enable interacting with Selenium." +authors = ["Perry Goy "] +maintainers = ["Gabe Langton", "Marcel Wilson"] +license = "MIT" +repository = "https://github.com/ScreenPyHQ/screenpy_selenium" +documentation = "https://screenpy-selenium-docs.readthedocs.io" +readme = "README.md" +classifiers = [ + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", + "Topic :: Software Development :: Testing :: BDD", + "Natural Language :: English", + "License :: OSI Approved :: MIT License", +] -[tool.ruff.lint.pycodestyle] -ignore-overlong-task-comments = true +# It's possible to add optional dependencies with the poetry CLI tool using: +# poetry add --optional some_dev_pkg +# This will set `optional = true` flag in [tool.poetry.dependencies], as seen below +# But then you need to remember to manually edit the [tool.poetry.extras] dev section +# and declare the package. This allows `pip install .[dev]` to work as expected +# Poetry users will need to use the `--extras dev` option rather than the `--with dev` +# so we dont have two different sets of package versions to update. +[tool.poetry.dependencies] +python = "^3.8" -[tool.ruff.lint.pydocstyle] -convention = "google" +screenpy = ">=4.0.2" +screenpy_pyotp = ">=4.0.0" +selenium = ">=4.1.0" +importlib_metadata = {version = "*", python = "3.8.*"} +# convenience packages for development +black = {version = "*", optional = true} +coverage = {version = "*", optional = true} +mypy = {version = "*", optional = true} +pre-commit = {version = "*", optional = true} +pytest = {version = "*", optional = true} +ruff = {version = ">=0.2.0", optional = true} +sphinx = {version = "*", optional = true} +sphinx-rtd-theme = {version = "*", optional = true} +tox = {version = "*", optional = true} -[tool.ruff.lint.flake8-type-checking] -strict = true +[tool.poetry.extras] +dev = [ + "black", + "coverage", + "mypy", + "pre-commit", + "pytest", + "ruff", + "sphinx", + "sphinx-rtd-theme", + "tox", +] +test = [ + "coverage", + "pytest", +] +docs = [ + "sphinx", + "sphinx-rtd-theme", +] diff --git a/screenpy_selenium/__init__.py b/screenpy_selenium/__init__.py index 43e4413..6599584 100644 --- a/screenpy_selenium/__init__.py +++ b/screenpy_selenium/__init__.py @@ -1,28 +1,28 @@ -# -*- coding: utf-8 -*- - # ░█▀▀▀█ █▀▀ █▀▀█ █▀▀ █▀▀ █▀▀▄ ░█▀▀█ █ █ ░█▀▀▀█ █▀▀ █ █▀▀ █▀▀▄ ▀ █ █ █▀▄▀█ # ▀▀▀▄▄ █ █▄▄▀ █▀▀ █▀▀ █ █ ░█▄▄█ █▄▄█ ▀▀▀▄▄ █▀▀ █ █▀▀ █ █ ▀█▀ █ █ █ ▀ █ # ░█▄▄▄█ ▀▀▀ ▀ ▀▀ ▀▀▀ ▀▀▀ ▀ ▀ ░█ ▄▄▄█ ░█▄▄▄█ ▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀ ▀ ▀ """ - ScreenPy Selenium + ScreenPy Selenium. + FADE IN: -INT. SITEPACKAGES DIRECTORY + +INT. SITEPACKAGES DIRECTORY. ScreenPy Selenium is an extension for ScreenPy, enabling interaction with Selenium. -:copyright: (c) 2022–2023, Perry Goy. +:copyright: (c) 2022-2024, Perry Goy. :license: MIT, see LICENSE for more details. """ from . import abilities, actions, questions, resolutions -from .abilities import * # noqa: F401, F403 -from .actions import * # noqa: F401, F403 +from .abilities import * # noqa: F403 +from .actions import * # noqa: F403 from .exceptions import BrowsingError, TargetingError from .protocols import Chainable -from .questions import * # noqa: F401, F403 -from .resolutions import * # noqa: F401, F403 +from .questions import * # noqa: F403 +from .resolutions import * # noqa: F403 from .target import Target __all__ = [ diff --git a/screenpy_selenium/__version__.py b/screenpy_selenium/__version__.py index 8d7be54..956301e 100644 --- a/screenpy_selenium/__version__.py +++ b/screenpy_selenium/__version__.py @@ -1,17 +1,12 @@ """ - ░█▀▀▀█ █▀▀ █▀▀█ █▀▀ █▀▀ █▀▀▄ ░█▀▀█ █ █ ░█▀▀▀█ █▀▀ █ █▀▀ █▀▀▄ ▀ █ █ █▀▄▀█ - ▀▀▀▄▄ █ █▄▄▀ █▀▀ █▀▀ █ █ ░█▄▄█ █▄▄█ ▀▀▀▄▄ █▀▀ █ █▀▀ █ █ ▀█▀ █ █ █ ▀ █ - ░█▄▄▄█ ▀▀▀ ▀ ▀▀ ▀▀▀ ▀▀▀ ▀ ▀ ░█ ▄▄▄█ ░█▄▄▄█ ▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀ ▀ ▀ + ░█▀▀▀█ █▀▀ █▀▀█ █▀▀ █▀▀ █▀▀▄ ░█▀▀█ █ █ ░█▀▀▀█ █▀▀ █ █▀▀ █▀▀▄ ▀ █ █ █▀▄▀█ + ▀▀▀▄▄ █ █▄▄▀ █▀▀ █▀▀ █ █ ░█▄▄█ █▄▄█ ▀▀▀▄▄ █▀▀ █ █▀▀ █ █ ▀█▀ █ █ █ ▀ █ + ░█▄▄▄█ ▀▀▀ ▀ ▀▀ ▀▀▀ ▀▀▀ ▀ ▀ ░█ ▄▄▄█ ░█▄▄▄█ ▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀ ▀ ▀ """ -try: - # importlib.metadata is present in Python 3.8 and later - import importlib.metadata as importlib_metadata # type: ignore -except ImportError: - # use the shim package importlib-metadata pre-3.8 - import importlib_metadata # type: ignore +import importlib.metadata -metadata = importlib_metadata.metadata("screenpy_selenium") +metadata = importlib.metadata.metadata("screenpy_selenium") __title__ = metadata["Name"] __description__ = metadata["Summary"] @@ -20,4 +15,4 @@ __author__ = metadata["Author"] __author_email__ = metadata["Author-email"] __license__ = metadata["License"] -__copyright__ = f"2022-2023 {__author__}" +__copyright__ = f"2019-2024 {__author__}" diff --git a/tests/test_copyright.py b/tests/test_copyright.py new file mode 100644 index 0000000..f3b0784 --- /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_selenium 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__ diff --git a/tox.ini b/tox.ini index 1999d4b..0eedef2 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,9 @@ envlist = py39 py310 py311 + py312 isolated_build = True +skip_missing_interpreters = False [gh-actions] python = @@ -17,8 +19,11 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] +whitelist_externals = + coverage extras = test commands =