From 5cd428232529362d207cc34e711af7cebb0e7942 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Mon, 22 Jun 2026 12:10:23 +0530 Subject: [PATCH] test: add backend coverage reporting --- CONTRIBUTING.md | 16 ++++++++++++++++ backend/.coveragerc | 14 ++++++++++++++ requirements.txt | 1 + 3 files changed, 31 insertions(+) create mode 100644 backend/.coveragerc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b242810..15b24b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,6 +35,12 @@ source .venv/bin/activate pip install -r requirements.txt ``` +If you are working on backend tests and coverage locally, install the coverage helper too: + +```bash +pip install coverage +``` + ### 5. Configure Environment Variables Create a `backend/.env` file and add the required environment variables as described in the README. @@ -112,6 +118,16 @@ python manage.py test Ensure all tests pass successfully. +To generate coverage data and a browsable HTML report: + +```bash +cd backend +coverage run manage.py test +coverage html +``` + +The backend coverage configuration lives in `backend/.coveragerc` and excludes virtual environments and migrations. + --- ## Code Style Guidelines diff --git a/backend/.coveragerc b/backend/.coveragerc new file mode 100644 index 0000000..ab8e14d --- /dev/null +++ b/backend/.coveragerc @@ -0,0 +1,14 @@ +[run] +branch = True +source = . +omit = + */venv/* + */.venv/* + */migrations/* + +[report] +exclude_lines = + pragma: no cover + def __repr__ + if TYPE_CHECKING: + if __name__ == .__main__.: diff --git a/requirements.txt b/requirements.txt index 6033172..59be323 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,4 @@ google-auth-oauthlib>=1.2,<2.0 firebase-admin>=6.5,<7.0 twilio>=9.0,<10.0 gunicorn>=20.1,<21.0 +coverage>=7.6,<8.0