Use pytest instead of nosetests

Nose has been in maintenance mode for the past several years
and pytest is a good replacement.

Other changes:
- Replace deprecated assertRegexpMatches with assertRegex
- Replace deprecated assertRaisesRegexp with assertRaisesRegex
- Replace deprecated SafeConfigParser with ConfigParser
- Force reinstall pytest and mock in tox virtualenv. This is because
  the globally installed packages may not work as expected(occured in
  jenkins job).

JIRA: RHELCMP-1619
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2020-07-28 09:23:53 +08:00
parent 495a4c48b2
commit 3c72755814
13 changed files with 51 additions and 54 deletions

16
tox.ini
View file

@ -36,15 +36,18 @@ deps =
mmdzanata
parameterized
dict.sorted
urlgrabber
mock
nose
nose-cov
unittest2
pytest
pytest-cov
whitelist_externals =
sh
make
coverage
commands =
sh -c 'find . -name "*.pyc" -exec rm -f \{\} +'
pip install --force-reinstall pytest mock
make test-coverage
coverage xml
@ -68,12 +71,13 @@ deps =
parameterized
dict.sorted
mock
nose
pytest
whitelist_externals =
sh
make
commands =
sh -c 'find . -name "__pycache__" -exec rm -rf \{\} +'
pip install --force-reinstall pytest mock
make test
[flake8]
@ -89,7 +93,5 @@ max-line-length = 88
# E203: whitespace before ':'
ignore = E402,H301,H306,E226,W503,E203
[run]
omit =
tests/*
.tox/*
[pytest]
addopts = --ignore=tests/_composes