From 2ddd5e5ef89da7f1e3b3a7d081fbc7f5c46ac11c Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 25 Jul 2014 11:01:30 +0200 Subject: Use tox to easily run tests in venv tox https://pypi.python.org/pypi/tox is a thin wrapper around virtualenv which let you craft a fresh python environement to execute command in. It creates the env with virtualenv, install dependencies, run python setup.py install in it and then execute whatever command you want it to do and report status. To do so I simply: - listed tests dependencies in test-requirements.txt (which are just nose and mock) - provide a tox.ini file which describe how to install the dependencies and execute nosetests - added the module 'coverage' to the list of test dependencies To run tests simply: pip install tox && tox That will execute the test command 'nosetests' using python2.6 and then python 2.7. The additional env 'cover' can be run using: tox -ecover. --- tox.ini | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tox.ini (limited to 'tox.ini') diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..a89b1348 --- /dev/null +++ b/tox.ini @@ -0,0 +1,13 @@ +[tox] +envlist = py26,py27 + +[testenv] +commands = nosetests +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:cover] +commands = nosetests --with-coverage + +[testenv:venv] +commands = {posargs} -- cgit v1.2.3 From d43055d44e58e8f010a71ec974c6a26f091a0b7a Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 25 Jul 2014 11:10:52 +0200 Subject: tox env to easily run flake8 Most people know about pep8 which enforce coding style. pyflakes goes a step beyond by analyzing the code. flake8 is basically a wrapper around both pep8 and pyflakes and comes with some additional checks. I find it very useful since you only need to require one package to have a lot of code issues reported to you. This patch provides a 'flake8' tox environement to easily install and run the utility on the code base. One simply has to: tox -eflake8 The env has been added to the default list of environement to have flake8 run by default. The repository in its current state does not pass checks but I noticed a pull request fixing pep8 issues. We can later easily ensure there is no regression by adjusting Travis configuration to run this env. More informations about flake8: https://pypi.python.org/pypi/flake8 --- tox.ini | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tox.ini') diff --git a/tox.ini b/tox.ini index a89b1348..60bfb1d9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27 +envlist = py26,py27,flake8 [testenv] commands = nosetests @@ -9,5 +9,12 @@ deps = -r{toxinidir}/requirements.txt [testenv:cover] commands = nosetests --with-coverage +[testenv:flake8] +commands = flake8 + [testenv:venv] commands = {posargs} + +[flake8] +#show-source = True +exclude = .tox,.venv,build,dist,doc,git/ext/ -- cgit v1.2.3