From 5c3426f7fc69060e3e468a4e8927ca29024ed243 Mon Sep 17 00:00:00 2001 From: Kai Schlamp Date: Sat, 2 Sep 2023 08:27:18 +0000 Subject: [PATCH] Improve coverage setup --- pyproject.toml | 8 ++++++++ tasks.py | 15 ++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index eb48fcc1..37360357 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,6 +102,14 @@ filterwarnings = [ ] timeout = 60 +[tool.coverage.run] +branch = true +source = "adit" + +[tool.coverage.report] +skip_empty = true +show_missing = true + [tool.ruff] exclude = ["migrations"] line-length = 100 diff --git a/tasks.py b/tasks.py index 0f2276be..15fb8dcc 100644 --- a/tasks.py +++ b/tasks.py @@ -196,8 +196,9 @@ def lint(ctx: Context): @task def test( ctx: Context, - path: str = "./adit", - cov: bool = False, + path: str | None = None, + cov: bool | str = False, + html: bool = False, keyword: str | None = None, mark: str | None = None, stdout: bool = False, @@ -213,15 +214,19 @@ def test( "--env DJANGO_SETTINGS_MODULE=adit.settings.test web pytest " ) if cov: - cmd += "--cov=adit " + cmd += "--cov " + if isinstance(cov, str): + cmd += f"={cov} " + if html: + cmd += "--cov-report=html" if keyword: cmd += f"-k {keyword} " if mark: cmd += f"-m {mark} " if stdout: cmd += "-s " - - cmd += path + if path: + cmd += path run_cmd(ctx, cmd)