Add a testing tool chain
- use pytest as the base, measure coverage with pytest-cov
+ configure coverage to include branches and specify source locations
+ configure pytest to enforce explicit markers
- add a package for the test suite under tests/
- add a `__version__` identifier at the package's root
+ it is dynamically assigned the version of the installed package
+ the version is PEP440 compliant and follows a strict subset of
semantic versioning: x.y.z[.devN] where x, y, z, and N are all
non-negative integers
+ add module with tests for the __version__
- add a nox session "test" that runs the test suite
- use flake8 to lint pytest for consistent style
This commit is contained in:
parent
c7989e0040
commit
9fc5b4816a
7 changed files with 406 additions and 3 deletions
50
setup.cfg
50
setup.cfg
|
|
@ -2,6 +2,23 @@
|
|||
# black's settings are in pyproject.toml => [tool.black]
|
||||
|
||||
|
||||
[coverage:paths]
|
||||
source =
|
||||
src/
|
||||
*/site-packages/
|
||||
|
||||
[coverage:report]
|
||||
show_missing = true
|
||||
skip_covered = true
|
||||
skip_empty = true
|
||||
|
||||
[coverage:run]
|
||||
branch = true
|
||||
data_file = .cache/coverage/data
|
||||
source =
|
||||
urban_meal_delivery
|
||||
|
||||
|
||||
[flake8]
|
||||
# Include error classes only explicitly
|
||||
# to avoid forward compatibility issues.
|
||||
|
|
@ -57,6 +74,8 @@ select =
|
|||
BLK1, BLK9,
|
||||
# flake8-expression-complexity => not too many expressions at once
|
||||
ECE001,
|
||||
# flake8-pytest-style => enforce a consistent style with pytest
|
||||
PT0,
|
||||
|
||||
# By default, flake8 ignores some errors.
|
||||
# Instead, do not ignore anything.
|
||||
|
|
@ -70,6 +89,10 @@ extend-ignore =
|
|||
E203, W503,
|
||||
# f-strings are ok.
|
||||
WPS305,
|
||||
# Classes should not have to specify a base class.
|
||||
WPS306,
|
||||
# Putting logic into __init__.py files may be justified.
|
||||
WPS412,
|
||||
|
||||
per-file-ignores =
|
||||
noxfile.py:
|
||||
|
|
@ -79,6 +102,11 @@ per-file-ignores =
|
|||
WPS213,
|
||||
# No overuse of string constants (e.g., '--version').
|
||||
WPS226,
|
||||
tests/*.py:
|
||||
# `assert` statements are ok in the test suite.
|
||||
S101,
|
||||
# Shadowing outer scopes occurs naturally with mocks.
|
||||
WPS442,
|
||||
|
||||
# Explicitly set mccabe's maximum complexity to 10 as recommended by
|
||||
# Thomas McCabe, the inventor of the McCabe complexity, and the NIST.
|
||||
|
|
@ -106,6 +134,17 @@ docstring-convention = google
|
|||
# flake8-eradicate
|
||||
eradicate-aggressive = true
|
||||
|
||||
# ==============================
|
||||
# flake8-pytest-style's settings
|
||||
# ==============================
|
||||
# Prefer @pytest.fixture over @pytest.fixture().
|
||||
pytest-fixture-no-parentheses = true
|
||||
# Prefer @pytest.mark.parametrize(['param1', 'param2'], [(1, 2), (3, 4)])
|
||||
# over @pytest.mark.parametrize(('param1', 'param2'), ([1, 2], [3, 4]))
|
||||
pytest-parametrize-names-type = list
|
||||
pytest-parametrize-values-row-type = tuple
|
||||
pytest-parametrize-values-type = list
|
||||
|
||||
|
||||
[isort]
|
||||
atomic = true
|
||||
|
|
@ -134,7 +173,7 @@ single_line_exclusions = typing
|
|||
[mypy]
|
||||
cache_dir = .cache/mypy
|
||||
|
||||
[mypy-nox.*]
|
||||
[mypy-nox.*,packaging.*,pytest]
|
||||
ignore_missing_imports = true
|
||||
|
||||
|
||||
|
|
@ -165,6 +204,15 @@ disable =
|
|||
missing-class-docstring, missing-function-docstring, missing-module-docstring,
|
||||
# pyflakes
|
||||
undefined-variable, unused-import, unused-variable,
|
||||
# wemake-python-styleguide
|
||||
redefined-outer-name,
|
||||
|
||||
[pylint.REPORTS]
|
||||
score = no
|
||||
|
||||
|
||||
[tool:pytest]
|
||||
addopts =
|
||||
--strict-markers
|
||||
cache_dir = .cache/pytest
|
||||
console_output_style = count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue