tests: Migrate to pytest

nose is not compatible with Python 3.10 or later and stestr can't handle
multiple test directories nor test directories that are not importable
modules.

While here, we also fix the case for two other dependencies to prevent
test failures. We also update the tox file to reflect modern best
practices.

Change-Id: Ie7b57b1f34957459793bcaa5253ce1b446e36336
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-09-05 11:25:46 +01:00
parent a45e0af97e
commit e392656946
2 changed files with 12 additions and 18 deletions

View File

@ -2,7 +2,7 @@ transaction
pecan pecan
sphinx>=3.0.0 # BSD sphinx>=3.0.0 # BSD
Flask Flask
flask-restful Flask-RESTful # BSD
nose pytest # MIT
coverage!=4.4,>=4.0 # Apache-2.0 pytest-cov # MIT
webtest WebTest # MIT

22
tox.ini
View File

@ -1,29 +1,23 @@
[tox] [tox]
minversion = 3.1 minversion = 3.1
envlist = py36,py37,py38,py39,pypy,coverage,pep8 envlist = py3,coverage,pep8
ignore_basepython_conflict = true
[testenv] [testenv]
basepython = python3
setenv =
COVERAGE_FILE=.coverage.{envname}
deps = deps =
-r test-requirements.txt -r test-requirements.txt
commands = commands =
{envbindir}/coverage run {envbindir}/nosetests --nologcapture --with-xunit --xunit-file nosetests-{envname}.xml wsme/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py --verbose {posargs} pytest wsme/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py
{envbindir}/coverage report --show-missing --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
[testenv:coverage] [testenv:coverage]
setenv =
COVERAGE_FILE=.coverage
commands = commands =
{envbindir}/coverage erase coverage erase
{envbindir}/coverage combine pytest --cov=wsme --cov=wsme_ext wsme/tests tests/pecantest tests/test_sphinxext.py tests/test_flask.py
{envbindir}/coverage xml --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*" coverage combine
{envbindir}/coverage report --show-missing --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*" coverage xml --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
coverage report --show-missing --include="wsme/*.py","wsme/rest/*.py","wsmeext/*.py" --omit "wsme/tests/*"
[testenv:docs] [testenv:docs]
whitelist_externals = allowlist_externals =
rm rm
deps = deps =
-r doc/requirements.txt -r doc/requirements.txt