From f50fe604acf2f32ab1300ca433f25bd386d117f7 Mon Sep 17 00:00:00 2001 From: Dantali0n Date: Fri, 2 Jul 2021 10:55:58 +0200 Subject: [PATCH] Manage constraints with testenv install_command This prevents having to duplicate the -c{} deps argument across all environments in tox.ini In addition this switches to stestr instead of testing through setup.py Change-Id: I3d0b6ca81be88660dcbbbeed0c3705771b258cb2 --- .gitignore | 1 + .stestr.conf | 3 +++ test-requirements.txt | 2 +- tox.ini | 37 +++++++++++++++++++++---------------- 4 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 .stestr.conf diff --git a/.gitignore b/.gitignore index 6f2c0e3..6ae9021 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ cover/ .coverage* !.coveragerc .tox +.stestr nosetests.xml .testrepository .venv diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000..4913583 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=${OS_TEST_PATH:-./watcher_tempest_plugin} +top_dir=./ \ No newline at end of file diff --git a/test-requirements.txt b/test-requirements.txt index 9ac9b7f..3c655da 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. hacking>=3.2.,<3.3 # Apache-2.0 - +stestr>=1.0.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0 python-subunit>=1.0.0 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index 35e1f79..6d7f5b9 100644 --- a/tox.ini +++ b/tox.ini @@ -7,14 +7,13 @@ ignore_basepython_conflict = True [testenv] basepython = python3 usedevelop = True -install_command = pip install {opts} {packages} +install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages} setenv = VIRTUAL_ENV={envdir} PYTHONWARNINGS=default::DeprecationWarning deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/test-requirements.txt -commands = python setup.py test --slowest --testr-args='{posargs}' +commands = stestr run --slowest {posargs} [testenv:pep8] commands = @@ -22,15 +21,21 @@ commands = flake8 bandit -r watcher_tempest_plugin -x tests -n5 -ll -s B320 +[testenv:cover] +setenv = + {[testenv]setenv} + PYTHON=coverage run --source ironic_tempest_plugin --parallel-mode +commands = + stestr run {posargs} + coverage combine + coverage html -d cover + coverage xml -o cover/coverage.xml + [testenv:venv] commands = {posargs} -[testenv:cover] -commands = python setup.py test --coverage --testr-args='{posargs}' - [testenv:docs] deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt -r{toxinidir}/doc/requirements.txt commands = sphinx-build -W -b html doc/source doc/build/html @@ -53,6 +58,15 @@ commands = [testenv:debug] commands = oslo_debug_helper {posargs} +[testenv:bandit] +deps = -r{toxinidir}/test-requirements.txt +commands = bandit -r watcher_tempest_plugin -x tests -n5 -ll -s B320 + +show-source = True +ignore = E123,E125 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build + [flake8] show-source=True ignore= H105,E123,E226,N320,H202,W503 @@ -62,12 +76,3 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,demo/,releasenotes [doc8] extension=.rst - -[testenv:bandit] -deps = -r{toxinidir}/test-requirements.txt -commands = bandit -r watcher_tempest_plugin -x tests -n5 -ll -s B320 - -show-source = True -ignore = E123,E125 -builtins = _ -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build