Add a makefile for running tests

Switch to pytest for running test as it has better fixtures then django
has by default.
This commit is contained in:
Jelle van der Waa 2021-09-13 22:16:21 +02:00
parent d36547f1a2
commit b41222d50e
No known key found for this signature in database
GPG Key ID: C06086337C50773E
2 changed files with 36 additions and 4 deletions

View File

@ -16,13 +16,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt && pip install coveralls flake8
pip install -r requirements.txt && pip install flake8 pytest pytest-cov pytest-django
- name: Lint with flake8
run: |
flake8 --exclude "*/migrations/" devel main mirrors news packages releng templates todolists visualize *.py
make lint
- name: Run collectstatic
run: |
python manage.py collectstatic --noinput
make collectstatic
- name: Run tests
run: |
coverage run --rcfile .coveragerc manage.py test
make coverage

32
Makefile Normal file
View File

@ -0,0 +1,32 @@
PYTHON>=python
PYTEST?=pytest
PYTEST_OPTIONS+=
PYTEST_INPUT?=.
PYTEST_COVERAGE_OPTIONS+=--cov-report=term-missing --cov-report=html:htmlcov --cov=.
PYTEST_PDB?=0
PYTEST_PDB_OPTIONS?=--pdb --pdbcls=IPython.terminal.debugger:TerminalPdb
ifeq (${PYTEST_PDB},1)
PYTEST_OPTIONS+= ${PYTEST_PDB_OPTIONS}
else
test-pdb: PYTEST_OPTIONS+= ${PYTEST_PDB_OPTIONS}
endif
test-pdb: test
.PHONY: test lint coverage
lint:
flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py
collectstatic:
python manage.py collectstatic --noinput
test: test-py
test-py coverage:
DJANGO_SETTINGS_MODULE=settings ${PYTEST} ${PYTEST_OPTIONS} ${PYTEST_COVERAGE_OPTIONS} ${PYTEST_INPUT}
open-coverage: coverage
${BROWSER} htmlcov/index.html