From d04dca264625a8ffb69d2c56712575c8e11a24fe Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Sun, 21 Jun 2026 14:25:02 +0330 Subject: [PATCH] test: add coverage reporting --- README.md | 7 +++++++ backend/README.md | 7 +++++++ backend/pyproject.toml | 22 ++++++++++++++++++++++ backend/requirements.txt | 1 + 4 files changed, 37 insertions(+) diff --git a/README.md b/README.md index 1b19678..8f886fd 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,13 @@ $env:TEST_DATABASE_ENGINE="sqlite" python -m pytest ``` +Run pytest with coverage: + +```powershell +$env:TEST_DATABASE_ENGINE="sqlite" +python -m pytest --cov --cov-report=term-missing +``` + Run worker locally: ```powershell diff --git a/backend/README.md b/backend/README.md index e52be15..0241bc4 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1012,6 +1012,13 @@ cd backend $env:TEST_DATABASE_ENGINE='sqlite'; .\.venv\Scripts\python.exe -m pytest ``` +Run backend tests with coverage: + +```powershell +cd backend +$env:TEST_DATABASE_ENGINE='sqlite'; .\.venv\Scripts\python.exe -m pytest --cov --cov-report=term-missing +``` + The test suite covers: - successful claim diff --git a/backend/pyproject.toml b/backend/pyproject.toml index c337f5a..2678766 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -9,3 +9,25 @@ select = ["E", "W", "F", "I", "B", "C4", "UP", "DJ", "SIM"] "jobs/models.py" = ["DJ001"] "jobs/migrations/*.py" = ["E501"] "jobs/tests/*.py" = ["DJ001"] + +[tool.coverage.run] +branch = true +source = ["config", "jobs"] +omit = [ + "config/asgi.py", + "config/wsgi.py", + "jobs/management/*", + "*/migrations/*", + "*/tests/*", + "manage.py", +] + +[tool.coverage.report] +show_missing = true +skip_covered = true +fail_under = 60 +exclude_lines = [ + "pragma: no cover", + "if __name__ == .__main__.:", + "raise NotImplementedError", +] diff --git a/backend/requirements.txt b/backend/requirements.txt index a1c8be0..f4d76bf 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,4 +7,5 @@ psycopg[binary]>=3.2,<4.0 django-unfold>=0.76,<1.0 pytest>=8.0,<9.0 pytest-django>=4.9,<5.0 +pytest-cov>=6.0,<7.0 ruff>=0.15,<0.16