[tox] Use the recommended coverage configuration

The OpenStack Governance repo states that stestr should be used for running tests [1]
pytest is used for coverage and in a standalone tox env, but doesn't run the coverage tests.

There is a recommended coverage target config in the governace repo, so
this has been added in place of the pytest config

The requirement for pytest has been removed from the repo.
The cover target runs the unittests using the same config as testenv
target

[1] https://github.com/openstack/governance/blob/master/reference/pti/python.rst#python-test-running

Change-Id: I284e564ab88e249b051538dc57f7cd9cec71bc2f
Signed-off-by: Emma Foley <efoley@redhat.com>
This commit is contained in:
Emma Foley
2025-10-30 13:58:01 +00:00
parent 2387b7614b
commit d03ed2fba7
2 changed files with 12 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
coverage>=4.4.1 # Apache-2.0
python-openstackclient>=6.3.0 # Apache-2.0
openstacksdk>=0.10.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0

23
tox.ini
View File

@@ -15,7 +15,7 @@ deps =
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = stestr run --slowest {posargs} --test-path {env:OS_TEST_PATH}
commands = stestr run --slowest --test-path {env:OS_TEST_PATH} {posargs}
[testenv:pep8]
skip_install = true
@@ -28,10 +28,16 @@ commands =
commands = {posargs}
[testenv:cover]
deps =
{[testenv]deps}
pytest-cov
commands = observabilityclient {posargs} {env:$OS_TEST_PATH}
setenv =
{[testenv]setenv}
PYTHON=coverage run --source observabilityclient --parallel-mode
commands =
coverage erase
{[testenv]commands}
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report
[testenv:functional]
setenv =
@@ -39,9 +45,6 @@ setenv =
OS_TESTENV_NAME = {envname}
allowlist_externals =
bash
deps =
{[testenv]deps}
pytest
commands =
bash tools/fix_ca_bundle.sh
stestr run --slowest {posargs} --test-path {env:OS_TEST_PATH}
@@ -74,10 +77,6 @@ exclude = .venv,.git,.tox,dist,doc,*egg,build,*lib/python*
enable-extensions=G,H101,H104,H106,H201,H202,H203,H204,H205,H23,H301,H303,H304,H306
application-import-names = observabilityclient
[pytest]
addopts = --verbose
norecursedirs = .tox
[testenv:releasenotes]
deps =
-r{toxinidir}/doc/requirements.txt