Use pytest to run test in tox

py.test gives more readable output for tests.

Change-Id: I134b122b5398c24e6012e26f384bc607753ec872
This commit is contained in:
Anton Studenov 2016-09-14 17:46:33 +03:00
parent 9520dcdde9
commit 27fe6b40ed
4 changed files with 22 additions and 4 deletions

View File

@ -1,7 +1,7 @@
[run]
branch = True
source = os_faults
omit = os_faults/openstack/*
omit = os_faults/tests/*
[report]
ignore_errors = True

1
.gitignore vendored
View File

@ -22,6 +22,7 @@ lib64
pip-log.txt
# Unit test / coverage reports
htmlcov/
cover/
.coverage*
!.coveragerc

View File

@ -3,6 +3,9 @@
# process, which may cause wedges in the gate later.
hacking<0.11,>=0.10.0
pytest>=2.7,<=3.0.2 # MIT
pytest-cov>=2.2.1,<=2.3.1 # MIT
pytest-html>=1.10.0,<=1.10.0 # Mozilla Public License 2.0 (MPL 2.0)
coverage>=3.6
ddt>=1.0.1

20
tox.ini
View File

@ -1,6 +1,6 @@
[tox]
minversion = 2.0
envlist = py35-constraints,py27-constraints,pep8-constraints
envlist = pep8-constraints,py27-constraints,py35-constraints,cover
skipsdist = True
[testenv]
@ -10,8 +10,13 @@ install_command =
pip install -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
whitelist_externals = find
deps = -r{toxinidir}/test-requirements.txt
commands = python setup.py test --slowest --testr-args='{posargs}'
commands =
find . -type f -name "*.pyc" -delete
py.test --html={envlogdir}/pytest_results.html --self-contained-html --durations=10 "os_faults/tests" {posargs}
basepython = python2.7
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
[testenv:common-constraints]
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
@ -30,8 +35,17 @@ commands = {posargs}
install_command = {[testenv:common-constraints]install_command}
commands = {posargs}
[testenv:py34]
basepython = python3.4
[testenv:py35]
basepython = python3.5
[testenv:cover]
commands = python setup.py test --coverage --testr-args='{posargs}'
commands =
py.test --cov-config .coveragerc --cov-report html --cov=os_faults "os_faults/tests"
coverage html -d {envlogdir}
coverage report
[testenv:cover-constraints]
install_command = {[testenv:common-constraints]install_command}