Use pytest instead of testr

- pytest is used by everybody
- pytest works on MacOS and Windows without any issues
- pytest doesn't require bash scripts in and .testrconfig in repo
- pytest has built-in colorizer
- pytest shows out of box slowest test
- pytest shows progress

This patch does 3 things:
1) Remove testr config file & requirments
2) Add pytest requirments
3) Change tox.ini to use pytest instead of testr

To add parameters to py.test you should add -- and than all args.
For example,
  tox -e py27 -- -k "db"

Change-Id: Ide3ddd58a2d1635651fc53404cb5cc7c1c4bab5e
This commit is contained in:
Boris Pavlovic 2016-06-11 20:27:58 -07:00 committed by Andrey Kurilin
parent fe1d52afbb
commit 4ceeb79646
5 changed files with 8 additions and 23 deletions

2
.gitignore vendored
View File

@ -31,6 +31,8 @@ cover
.testrepository
*.sqlite
.venv
.cache
pytest_results.html
# Docs
doc/source/_build/

View File

@ -1,4 +0,0 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ./tests/unit $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -2,12 +2,13 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking<0.10,>=0.9.2
pytest>=2.7
pytest-html
coverage>=3.6 # Apache-2.0
ddt>=1.0.1 # MIT
mock>=2.0 # BSD
python-dateutil>=2.4.2 # BSD
testrepository>=0.0.18 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0

View File

@ -1,15 +0,0 @@
#!/bin/bash -x
env
LOG=.testrepository/subunit.log
mkdir -p .testrepository
date "+Start tests at %Y-%m-%d %H:%M:%S"
python -m subunit.run discover tests/functional | tee ${LOG} | subunit2pyunit
cat ${LOG} | subunit-stats
cat ${LOG} | subunit-stats | grep -Eq "^Failed tests: 0$"

View File

@ -18,7 +18,7 @@ install_command = pip install -U {opts} {packages}
usedevelop = True
commands =
find . -type f -name "*.pyc" -delete
python setup.py testr --slowest --testr-args='{posargs}'
py.test --html=pytest_results.html --durations=10 "tests/unit" {posargs}
distribute = false
basepython = python2.7
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
@ -35,7 +35,6 @@ basepython = python3.4
[testenv:venv]
commands = {posargs}
[testenv:debug]
commands = oslo_debug_helper -t tests {posargs}
@ -45,7 +44,9 @@ commands = oslo_debug_helper -t tests {posargs}
[testenv:cli]
sitepackages = True
commands = {toxinidir}/tests/ci/rally-integrated.sh
commands =
find . -type f -name "*.pyc" -delete
py.test --html=pytest_results.html --durations=10 "tests/functional" {posargs}
[testenv:cover]