From 386ff377d9c34915e368d6cbef1f8604f525b197 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 29 Jul 2019 21:36:12 +0200 Subject: [PATCH] Add pytest integration files --- .coveragerc | 1 + .gitignore | 1 + .travis.yml | 6 +++--- Makefile | 32 ++++++++++++++++++++++++++++++++ pytest.ini | 2 ++ 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Makefile create mode 100644 pytest.ini diff --git a/.coveragerc b/.coveragerc index 02b787e9b..4664e2bc1 100644 --- a/.coveragerc +++ b/.coveragerc @@ -7,5 +7,6 @@ omit = **/tests/*.py env* settings.py + conftest.py local_settings.py /home/travis/virtualenv* diff --git a/.gitignore b/.gitignore index e047ef4a5..b6abcfbc5 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ env/ # coverage .coverage +htmlcov diff --git a/.travis.yml b/.travis.yml index 99a551d14..ba89fb559 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,9 @@ cache: pip install: "pip install -r requirements.txt && pip install coveralls pylint" script: - - python manage.py collectstatic --noinput - - coverage run --rcfile .coveragerc manage.py test - - pylint devel main mirrors news packages releng templates todolists visualize *.py + - make collectstatic + - make lint + - make coverage after_success: - coveralls diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..950bc3eae --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +PYTHON>=python +PYTEST?=pytest +PYTEST_OPTIONS+=-s +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 + +lint: + pylint devel main mirrors news packages releng templates todolists visualize *.py + +collecstatic: + python manage.py collecstatic --noinput + +test: test-py + +test-py coverage: + ${PYTEST} ${PYTEST_INPUT} ${PYTEST_OPTIONS} ${PYTEST_COVERAGE_OPTIONS} + +open-coverage: coverage + ${BROWSER} htmlcov/index.html diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..4e22ea20d --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +DJANGO_SETTINGS_MODULE = settings