Use pytest instead of nose for running tests via tox

- use pytest-sugar for pretty output
  - add linting to each python tox environment
  - drop lint as separate tox target
  - replace travis_selector.sh with shell magic
This commit is contained in:
Dana Powers
2016-01-01 15:04:51 -08:00
parent cb325af5ff
commit 1a6ff2615c
4 changed files with 12 additions and 54 deletions

3
.gitignore vendored
View File

@@ -6,6 +6,7 @@ dist
MANIFEST MANIFEST
env env
servers/*/kafka-bin servers/*/kafka-bin
.coverage .coverage*
.noseids .noseids
docs/_build docs/_build
.cache*

View File

@@ -48,7 +48,7 @@ deploy:
# branch: master # branch: master
script: script:
- if [ -n "$UNIT_AND_LINT_ONLY" ]; then tox -e lint,`./travis_selector.sh $TRAVIS_PYTHON_VERSION`; else tox -e `./travis_selector.sh $TRAVIS_PYTHON_VERSION`; fi - tox -e ${TRAVIS_PYTHON_VERSION/./}
after_success: after_success:
- coveralls - coveralls

43
tox.ini
View File

@@ -1,48 +1,23 @@
[tox] [tox]
envlist = lint, py26, py27, pypy, py33, py34, py35, docs envlist = py{26,27,py,33,34,35}, docs
[testenv] [testenv]
deps = deps =
nose pytest
nose-timer pytest-cov
coverage pytest-catchlog
pytest-pylint
pytest-sugar
mock mock
python-snappy python-snappy
py{26,27}: six
py26: unittest2
commands = commands =
nosetests {posargs:-v -x --with-id --id-file={envdir}/.noseids --with-timer --timer-top-n 10 --with-coverage --cover-erase --cover-package kafka} py.test {posargs:--pylint --pylint-rcfile=pylint.rc --pylint-error-types=EF --durations=10 --cov=kafka --doctest-modules kafka test}
setenv = setenv =
NOSE_LOGFORMAT = %(asctime)s - %(thread)d - %(name)s - %(levelname)s - %(message)s
PROJECT_ROOT = {toxinidir} PROJECT_ROOT = {toxinidir}
passenv = KAFKA_VERSION passenv = KAFKA_VERSION
[testenv:py26]
deps =
six
unittest2
nose
nose-timer
coverage
mock
python-snappy
[testenv:py27]
deps =
six
unittest2
nose
nose-timer
coverage
mock
python-snappy
[testenv:lint]
basepython = python2.7
deps =
unittest2
mock
pylint
commands = pylint --rcfile=pylint.rc {posargs: -E kafka test}
[testenv:docs] [testenv:docs]
deps = deps =
sphinxcontrib-napoleon sphinxcontrib-napoleon

View File

@@ -1,18 +0,0 @@
#!/bin/bash
# This works with the .travis.yml file to select a python version for testing
if [ $1 == "pypy" ]; then
echo "pypy"
elif [ $1 == "3.5" ]; then
echo "py35"
elif [ $1 == "3.4" ]; then
echo "py34"
elif [ $1 == "3.3" ]; then
echo "py33"
elif [ $1 == "2.7" ]; then
echo "py27"
elif [ $1 == "2.6" ]; then
echo "py26"
else
echo $1
fi;