From d2483b841c4b1a9c650e99f2befc98d41c772dc3 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Sep 05 2019 11:41:50 +0000 Subject: Use pytest inside tox and compute coverage This should simplify running the tests in jenkins, as well as provide better user experience for developers. The make targets are not longer useful and deleted. Signed-off-by: Lubomír Sedlář --- diff --git a/Makefile b/Makefile deleted file mode 100644 index 32fb894..0000000 --- a/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -help: - @echo 'Available targets:' - @awk -F ':|##' '/^[^\t].+?:.*?##/ {printf "%-15s %s\n", $$1, $$NF}' $(MAKEFILE_LIST) - -test: ## Run all tests, needs to be run after make test-data - nosetests - -test-coverage: ## Run tests and compute code coverage - nosetests --with-cov --cov-report html --cov-config tox.ini - -test-data: ## Prepare test data - bash tests/specs/build.sh - - -.PHONY: help test test-data diff --git a/README.rst b/README.rst index 28b6f95..04b53db 100644 --- a/README.rst +++ b/README.rst @@ -60,5 +60,5 @@ Contributing Feel free to open pull requests on Pagure. -Tests can be run by ``tox``. That should take care of all dependencies. Use -``detox`` if you're in a hurry. +Tests can be run by ``tox``. That should take care of all dependencies, run +tests on multiple versions of Python and also compute coverage report. diff --git a/tox.ini b/tox.ini index 3463948..c8c9522 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,39 @@ [tox] -envlist=py27,py35,py36,py37,py38 +envlist=py27,py35,py36,py37,py38,coverage skip_missing_interpreters = true minversion=3.12.0 [testenv] deps= - nose + pytest + pytest-cov mock freezegun unittest2 koji kobo>=0.10.0 +setenv = + COVERAGE_FILE={env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} commands= - nosetests + pytest \ + --cov "{toxinidir}/compose_utils" \ + --cov-config "{toxinidir}/tox.ini" \ + --junitxml {toxworkdir}/junit.{envname}.xml \ + {posargs:.} + +[testenv:coverage] +skip_install = true +deps = + {[testenv]deps} + coverage +setenv = COVERAGE_FILE={toxworkdir}/.coverage +commands = + coverage combine + coverage report -m + coverage xml -o {toxworkdir}/coverage.xml + coverage html -d {toxworkdir}/htmlcov +depends = py27, py35, py36, py37 +parallel_show_output = True [flake8] exclude = doc,*.pyc,*.py~,*.in,*.spec,*.sh,*.rst