#103 Use pytest inside tox and compute coverage
Merged 4 years ago by lsedlar. Opened 4 years ago by lsedlar.
lsedlar/compose-utils tox-pytest  into  master

file removed
-15
@@ -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

file modified
+2 -2
@@ -60,5 +60,5 @@ 

  

  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.

file modified
+24 -3
@@ -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

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.

Pull-Request has been merged by lsedlar

4 years ago