From d12d966218359e1a8d46db86fcc167fd751cb805 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Mon, 10 Sep 2018 12:51:52 +0200 Subject: [PATCH] Switch to stestr for unit tests Moves coverage to a separate test environment and CI job. Change-Id: I94697ba41afbae194136202dfab349eb0367a125 --- .gitignore | 2 +- .stestr.conf | 2 ++ .zuul.yaml | 1 + lower-constraints.txt | 1 + test-requirements.txt | 1 + tox.ini | 20 +++++++++++++++++--- 6 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 .stestr.conf diff --git a/.gitignore b/.gitignore index 372f4b8..765ace8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ develop-eggs # Other *.DS_Store .idea -.testrepository +.stestr .tox .venv .*.swp diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000..552cc81 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,2 @@ +[DEFAULT] +test_path=./metalsmith/test diff --git a/.zuul.yaml b/.zuul.yaml index bb2e186..eaa5178 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -172,6 +172,7 @@ - openstack-python35-jobs - openstack-python36-jobs - openstack-lower-constraints-jobs + - openstack-cover-jobs - docs-on-readthedocs vars: rtd_webhook_id: '37378' diff --git a/lower-constraints.txt b/lower-constraints.txt index 7a99004..0cbdc85 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -54,6 +54,7 @@ requestsexceptions==1.4.0 restructuredtext-lint==1.1.3 simplejson==3.15.0 six==1.10.0 +stestr==1.0.0 stevedore==1.28.0 testtools==2.2.0 traceback2==1.4.0 diff --git a/test-requirements.txt b/test-requirements.txt index 4106cf0..fffd808 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,5 +7,6 @@ flake8-import-order>=0.13 # LGPLv3 fixtures>=3.0.0 # Apache-2.0/BSD hacking>=1.0.0 # Apache-2.0 mock>=2.0 # BSD +stestr>=1.0.0 # Apache-2.0 testtools>=2.2.0 # MIT Pygments>=2.2.0 # BSD diff --git a/tox.ini b/tox.ini index 5cf1923..73d8a82 100644 --- a/tox.ini +++ b/tox.ini @@ -3,16 +3,30 @@ envlist = py3,py27,pep8 [testenv] usedevelop = True +setenv = VIRTUAL_ENV={envdir} + LANGUAGE=en_US + LC_ALL=en_US.UTF-8 + PYTHONWARNINGS=default::DeprecationWarning + PYTHONDONTWRITEBYTECODE=1 deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = - coverage run --branch --include "metalsmith*" -m unittest discover metalsmith.test - coverage report -m --fail-under 90 -setenv = PYTHONDONTWRITEBYTECODE=1 + stestr run {posargs} passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY +[testenv:cover] +basepython = python3 +setenv = {[testenv]setenv} + PYTHON=coverage run --branch --source metalsmith --parallel-mode +commands = + coverage erase + stestr run {posargs} + coverage combine + coverage report -m --fail-under 90 + coverage html -d ./cover --omit='*test*' + [testenv:venv] deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}