diff --git a/.copier-answers.yml b/.copier-answers.yml index b79f5b7..e794a55 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: 6e49531 +_commit: 322f694 _src_path: gh:pawamoy/copier-poetry author_email: pawamoy@pm.me author_fullname: "Timoth\xE9e Mazzucotelli" diff --git a/config/pytest.ini b/config/pytest.ini index 79b7979..015b0e5 100644 --- a/config/pytest.ini +++ b/config/pytest.ini @@ -9,3 +9,6 @@ python_files = test_*.py *_test.py tests.py +addopts = + --cov + --cov-config config/coverage.ini diff --git a/pyproject.toml b/pyproject.toml index f866e48..c0f78bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,12 +25,13 @@ coverage = {version = "^5.2.1", optional = true} invoke = {version = "^1.4.1", optional = true} mypy = {version = "^0.782", optional = true} pytest = {version = "^6.0.1", optional = true} +pytest-cov = {version = "^2.10.1", optional = true} pytest-randomly = {version = "^3.4.1", optional = true} pytest-sugar = {version = "^0.9.4", optional = true} pytest-xdist = {version = "^2.1.0", optional = true} [tool.poetry.extras] -tests = ["coverage", "invoke", "mypy", "pytest", "pytest-randomly", "pytest-sugar", "pytest-xdist"] +tests = ["coverage", "invoke", "mypy", "pytest", "pytest-cov", "pytest-randomly", "pytest-sugar", "pytest-xdist"] [tool.poetry.dev-dependencies] autoflake = "^1.4" @@ -57,6 +58,7 @@ mkdocstrings = "^0.13.1" mypy = "^0.782" pydantic = "^1.5.1" pytest = "^6.0.1" +pytest-cov = "^2.10.1" pytest-randomly = "^3.4.1" pytest-sugar = "^0.9.4" pytest-xdist = "^2.1.0" diff --git a/tasks.py b/tasks.py index 3083a78..ae73fca 100644 --- a/tasks.py +++ b/tasks.py @@ -53,7 +53,6 @@ def setpath(path: str) -> Generator: os.environ["PATH"] = current_path - def _python_ci_decorator(func: Callable) -> Callable: """ Decorate a task to add `python_version` and `skip` attributes to the context. @@ -64,6 +63,7 @@ def _python_ci_decorator(func: Callable) -> Callable: Returns: The wrapped function. """ + @wraps(func) # noqa: WPS430 (nested function) def wrapper(context, *args, **kwargs): context.python_version = which("python") @@ -333,9 +333,7 @@ def test(context, match=""): match: A pytest expression to filter selected tests. """ title = f"Running tests ({context.python_version})" - command = ( - f"coverage run --rcfile=config/coverage.ini -m pytest -c config/pytest.ini -k '{match}' {PY_SRC} 2>/dev/null" - ) + command = f"pytest -c config/pytest.ini -n auto -k '{match}' {PY_SRC} 2>/dev/null" if context.skip: title += " (missing interpreter)" command = "true"