From c26786a10700342d891f39e4e71f61c72b1ebd1f Mon Sep 17 00:00:00 2001 From: Marie PUPO JEAMMET Date: Thu, 1 Aug 2024 12:27:04 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=BA(coverage)=20add=20config=20and=20m?= =?UTF-8?q?ake=20rule=20to=20compute=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configure pytest-cov settings in pyproject.toml and add make rule to compute test coverage. --- .gitignore | 1 + Makefile | 4 ++++ src/backend/pyproject.toml | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index a043ea1..231ed27 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ src/frontend/tsclient # Test & lint .coverage +coverage.json .pylint.d .pytest_cache db.sqlite3 diff --git a/Makefile b/Makefile index 4f099bb..c3e3289 100644 --- a/Makefile +++ b/Makefile @@ -166,6 +166,10 @@ test-back-parallel: ## run all back-end tests in parallel bin/pytest -n auto $${args:-${1}} .PHONY: test-back-parallel +test-coverage: ## compute, display and save test coverage + bin/pytest --cov=. --cov-report json . +.PHONY: test-coverage + makemigrations: ## run django makemigrations for the people project. @echo "$(BOLD)Running makemigrations$(RESET)" @$(COMPOSE) up -d postgresql diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index 8d30b90..762f090 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -137,3 +137,22 @@ python_files = [ "test_*.py", "tests.py", ] + +[tool.coverage.run] +branch = true +omit = [ + "*/admin.py", + "*/migrations/*", + "*/tests/*", + "*/urls.py", + "manage.py", + "celery_app.py", + "wsgi.py", + ] + +[tool.coverage.report] +show_missing = true +skip_empty = true + +[tool.coverage.json] +pretty_print = true