Files
python-observabilityclient/tox.ini
Emma Foley d03ed2fba7 [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>
2025-10-30 14:04:58 +00:00

87 lines
2.5 KiB
INI

[tox]
minversion = 4.2.5
envlist = py3,pep8
[testenv]
usedevelop = True
setenv =
VIRTUAL_ENV={envdir}
OBSERVABILITY_CLIENT_EXEC_DIR={envdir}/bin
OS_TEST_PATH = ./observabilityclient/tests/unit
passenv =
PROMETHEUS_*
OBSERVABILITY_*
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 --test-path {env:OS_TEST_PATH} {posargs}
[testenv:pep8]
skip_install = true
deps =
pre-commit
commands =
pre-commit run -a
[testenv:venv]
commands = {posargs}
[testenv:cover]
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 =
OS_TEST_PATH = ./observabilityclient/tests/functional
OS_TESTENV_NAME = {envname}
allowlist_externals =
bash
commands =
bash tools/fix_ca_bundle.sh
stestr run --slowest {posargs} --test-path {env:OS_TEST_PATH}
[testenv:docs]
deps =
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt
commands = sphinx-build --keep-going -b html doc/source doc/build/html
[flake8]
show-source = True
# W504 line break after binary operator
ignore = W504
exclude = .venv,.git,.tox,dist,doc,*egg,build,*lib/python*
# [H101] Include your name with TODOs as in # TODO(yourname).
# [H104] Empty files should not contain license or comments
# [H106] Do not put vim configuration in source files.
# [H201] Do not write except:, use except Exception: at the very least.
# [H202] Testing for Exception being raised
# [H203] Use assertIs(Not)None to check for None.
# [H204] Use assert(Not)Equal to check for equality.
# [H205] Use assert(Greater|Less)(Equal) for comparison.
# [H23] Py3 compat
# [H301] Do not import more than one module per line (*)
# [H303] Do not use wildcard * import (*)
# [H304] Do not make relative imports
# [H306] Alphabetically order your imports by the full module path.
enable-extensions=G,H101,H104,H106,H201,H202,H203,H204,H205,H23,H301,H303,H304,H306
application-import-names = observabilityclient
[testenv:releasenotes]
deps =
-r{toxinidir}/doc/requirements.txt
-r{toxinidir}/requirements.txt
allowlist_externals =
sphinx-build
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html