Skip to content

Commit b41222d

Browse files
committed
Add a makefile for running tests
Switch to pytest for running test as it has better fixtures then django has by default.
1 parent d36547f commit b41222d

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
- name: Install dependencies
1717
run: |
1818
python -m pip install --upgrade pip
19-
pip install -r requirements.txt && pip install coveralls flake8
19+
pip install -r requirements.txt && pip install flake8 pytest pytest-cov pytest-django
2020
- name: Lint with flake8
2121
run: |
22-
flake8 --exclude "*/migrations/" devel main mirrors news packages releng templates todolists visualize *.py
22+
make lint
2323
- name: Run collectstatic
2424
run: |
25-
python manage.py collectstatic --noinput
25+
make collectstatic
2626
- name: Run tests
2727
run: |
28-
coverage run --rcfile .coveragerc manage.py test
28+
make coverage

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
PYTHON>=python
2+
PYTEST?=pytest
3+
PYTEST_OPTIONS+=
4+
PYTEST_INPUT?=.
5+
PYTEST_COVERAGE_OPTIONS+=--cov-report=term-missing --cov-report=html:htmlcov --cov=.
6+
PYTEST_PDB?=0
7+
PYTEST_PDB_OPTIONS?=--pdb --pdbcls=IPython.terminal.debugger:TerminalPdb
8+
9+
10+
ifeq (${PYTEST_PDB},1)
11+
PYTEST_OPTIONS+= ${PYTEST_PDB_OPTIONS}
12+
else
13+
test-pdb: PYTEST_OPTIONS+= ${PYTEST_PDB_OPTIONS}
14+
endif
15+
test-pdb: test
16+
17+
18+
.PHONY: test lint coverage
19+
20+
lint:
21+
flake8 --extend-exclude "*/migrations/,local_settings.py" devel main mirrors news packages releng templates todolists visualize *.py
22+
23+
collectstatic:
24+
python manage.py collectstatic --noinput
25+
26+
test: test-py
27+
28+
test-py coverage:
29+
DJANGO_SETTINGS_MODULE=settings ${PYTEST} ${PYTEST_OPTIONS} ${PYTEST_COVERAGE_OPTIONS} ${PYTEST_INPUT}
30+
31+
open-coverage: coverage
32+
${BROWSER} htmlcov/index.html

0 commit comments

Comments
 (0)