Add pytest
to dev dependencies;
upgrade dev dependencies; remove unnecessary main test script entrypoint; remove unnecessary line from `.gitignore`; put repo description variable into top-level `__init__.py`; introduce syntax-error as a reminder to fix copyright; add CSS fix for broken inline-code segments; update `index.md` layout; reorder linting script calls and add a bit more output; support Python 3.8+ by default; fix wrong dependency file reference in `pyproject.toml`; add `pytest` config to `pyproject.toml`; call `pytest` in `coverage` config; add a few sensible rule-ignores to `ruff` config
This commit is contained in:
parent
1a293563d1
commit
c50cfe88d6
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,8 +18,5 @@
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# Testing:
|
||||
/.coverage
|
||||
|
||||
# Miscellaneous cache:
|
||||
.cache/
|
||||
|
@ -0,0 +1,3 @@
|
||||
.md-typeset code {
|
||||
word-break: keep-all; /* Prevent inline-code from being broken up. */
|
||||
}
|
@ -4,23 +4,25 @@
|
||||
|
||||
---
|
||||
|
||||
| [📑 Documentation][1] | [🧑💻 Source Code][2] | [🐛 Bug Tracker][3] |
|
||||
|-----------------------|------------------------|---------------------|
|
||||
[📑 Documentation][1] | [🧑💻 Source Code][2] | [🐛 Bug Tracker][3]
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
...
|
||||
|
||||
## Installation
|
||||
|
||||
`pip install ${REPO_NAME}`
|
||||
|
||||
## Usage
|
||||
|
||||
...
|
||||
|
||||
## Dependencies
|
||||
|
||||
Python Version ..., OS ...
|
||||
Python `>=3.8`, OS agnostic
|
||||
|
||||
---
|
||||
|
||||
© 2023 ...
|
||||
|
||||
[1]: https://${REPO_OWNER_LOWER}.github.io/${REPO_NAME_LOWER}
|
||||
[2]: https://github.com/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}
|
||||
|
@ -2,7 +2,10 @@
|
||||
# Python packaging: #
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools", "setuptools-scm"]
|
||||
requires = [
|
||||
"setuptools",
|
||||
"setuptools-scm",
|
||||
]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
@ -14,7 +17,7 @@ authors = [
|
||||
maintainers = [
|
||||
{ name = ..., email = ... },
|
||||
]
|
||||
requires-python = ">=3.9, <4.0"
|
||||
requires-python = ">=3.8, <4.0"
|
||||
keywords = [
|
||||
...
|
||||
]
|
||||
@ -41,14 +44,15 @@ dynamic = [
|
||||
[project.optional-dependencies]
|
||||
full = []
|
||||
dev = [
|
||||
"black==23.9.1",
|
||||
"black==23.10.1",
|
||||
"build==1.0.3",
|
||||
"coverage[toml]==7.3.2",
|
||||
"isort==5.12.0",
|
||||
"mkdocs-material==9.4.6",
|
||||
"mkdocstrings[python]==0.23.0",
|
||||
"mypy==1.5.1",
|
||||
"ruff==0.0.292",
|
||||
"pytest==7.4.3",
|
||||
"ruff==0.1.3",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
@ -57,9 +61,9 @@ dev = [
|
||||
"Documentation" = "http://${REPO_OWNER_LOWER}.github.io/${REPO_NAME_LOWER}"
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
dependencies = { file = "requirements/common.txt" }
|
||||
dependencies = { file = "requirements/base.txt" }
|
||||
readme = { file = ["README.md"], content-type = "text/markdown" }
|
||||
version = {attr = ..."${REPO_NAME}.__version__"}
|
||||
version = { attr = ..."${REPO_NAME}.__version__" }
|
||||
|
||||
#########################
|
||||
# Static type checking: #
|
||||
@ -75,6 +79,16 @@ strict = true
|
||||
show_error_codes = true
|
||||
plugins = []
|
||||
|
||||
############
|
||||
# Testing: #
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
cache_dir = ".cache/pytest"
|
||||
addopts = "-ra -v"
|
||||
testpaths = [
|
||||
"tests",
|
||||
]
|
||||
|
||||
#######################
|
||||
# Unit test coverage: #
|
||||
|
||||
@ -84,7 +98,7 @@ source = [
|
||||
"src/",
|
||||
]
|
||||
branch = true
|
||||
command_line = "-m tests"
|
||||
command_line = "-m pytest -qq"
|
||||
omit = [
|
||||
".venv*/*",
|
||||
]
|
||||
@ -140,6 +154,7 @@ ignore = [
|
||||
"ANN101", # Missing type annotation for self in method -> unnecessary
|
||||
"ANN102", # Missing type annotation for cls in classmethod -> unnecessary
|
||||
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed -> we'll use it sparingly
|
||||
"N818", # Exception name should be named with an Error suffix -> absolutely not
|
||||
]
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
@ -152,7 +167,11 @@ ignore = [
|
||||
"D100", # Missing docstring in public module
|
||||
"D101", # Missing docstring in public class
|
||||
"D102", # Missing docstring in public method
|
||||
"D103", # Missing docstring in public function
|
||||
"D104", # Missing docstring in public package
|
||||
"S101", # Use of `assert` detected
|
||||
"FBT", # flake8-boolean-trap
|
||||
"TRY", # tryceratops
|
||||
]
|
||||
|
||||
####################
|
||||
|
@ -1,9 +1,10 @@
|
||||
-r full.txt
|
||||
black==23.9.1
|
||||
black==23.10.1
|
||||
build==1.0.3
|
||||
coverage[toml]==7.3.2
|
||||
isort==5.12.0
|
||||
mkdocs-material==9.4.6
|
||||
mkdocstrings[python]==0.23.0
|
||||
mypy==1.5.1
|
||||
ruff==0.0.292
|
||||
pytest==7.4.3
|
||||
ruff==0.1.3
|
||||
|
@ -5,13 +5,13 @@ source "$(dirname $(realpath $0))/util.sh"
|
||||
|
||||
echo 'Linting source and test files...'
|
||||
|
||||
echo ' isort - consistent imports'
|
||||
isort src/ tests/ --check-only
|
||||
|
||||
echo ' ruff - extensive linting'
|
||||
echo ' ruff - Doing extensive linting'
|
||||
ruff src/ tests/
|
||||
|
||||
echo ' black - consistent style'
|
||||
echo ' black - Ensuring consistent code style'
|
||||
run_and_capture black src/ tests/ --check
|
||||
|
||||
echo ' isort - Ensuring consistent import structure'
|
||||
isort src/ tests/ --check-only
|
||||
|
||||
echo -e "${bold_green}No issues found${color_reset}\n"
|
||||
|
@ -1,4 +1,4 @@
|
||||
__copyright__ = "© 2023 ${REPO_OWNER_TITLE}"
|
||||
... __copyright__ = "© 2023 ..."
|
||||
__license__ = """Apache-2.0
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -16,5 +16,5 @@ limitations under the License."""
|
||||
__version__ = "0.0.1"
|
||||
|
||||
__doc__ = """
|
||||
PLACEHOLDER
|
||||
${REPO_DESCRIPTION}
|
||||
"""
|
||||
|
@ -1,13 +0,0 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
pattern = sys.argv[1]
|
||||
except IndexError:
|
||||
pattern = "test*.py"
|
||||
test_suite = unittest.defaultTestLoader.discover(".", pattern=pattern)
|
||||
test_runner = unittest.TextTestRunner(resultclass=unittest.TextTestResult)
|
||||
result = test_runner.run(test_suite)
|
||||
sys.exit(not result.wasSuccessful())
|
Loading…
Reference in New Issue
Block a user