From 7751a52b943f3243c85e5933926e1398e00303b9 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Feb 01 2017 18:05:50 +0000 Subject: Use tox to run the tests Tests can be run on different versions of Python. --- diff --git a/.gitignore b/.gitignore index 357e7b0..b3b67a9 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ Vagrantfile *.retry *.pem config + +# tox +.tox +.coverage diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..e35d885 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +_build diff --git a/docs/dev-guide.rst b/docs/dev-guide.rst index 715315b..2617a29 100644 --- a/docs/dev-guide.rst +++ b/docs/dev-guide.rst @@ -200,29 +200,18 @@ code, to make sure that nothing is broken before you start. And you should run it after you finish your change, before you push, to verify that your change didn't inadvertently break something else. -You can run it with:: +To run the test, you need to install Tox with the command:: - $ pip install -r test-requirements.txt - $ ./runtest.sh + $ pip install tox +Then you can run the tests with:: + $ tox --skip-missing-interpreters -If the unit tests are all failing and returning errors like this:: +It will run the Python tests with the supported versions you have on your +system, and it will also run the Javascript tests and try building the +documentation. It will report the error if any of those steps fail. - ImportError: cannot import name dummy - - -It most likely is a result of html5lib breaking api stability. Please downgrade to the version below:: - - pip install html5lib==0.9999999 - - -See the options available with:: - - $ ./runtest.sh --help - -You can run the JavaScript tests from ``hubs/static/client`` with:: - $ npm test Some credentials... ------------------- diff --git a/requirements.txt b/requirements.txt index d8d0088..092bd82 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ flask-oidc>=1.0.3 fmn.lib fmn.rules gunicorn -html5lib +html5lib==0.9999999 munch psycopg2 pytz diff --git a/runtest.sh b/runtest.sh index 87fd265..cac5a69 100755 --- a/runtest.sh +++ b/runtest.sh @@ -1,6 +1,3 @@ #!/bin/bash -. ~/.virtualenvs/hubs/bin/activate || /bin/bash ./setup_python_test_env.sh - -HUBS_CONFIG=`pwd`/hubs/tests/hubs_test.cfg PYTHONPATH=. ./nosetests \ - --with-coverage --cover-erase --cover-package=hubs $* +tox --skip-missing-interpreters diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..37dd0c2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,51 @@ +[tox] +envlist = py{27,34,35},js,docs +skipsdist = True + + +[testenv] +basepython = python2 +usedevelop = True +deps = + -rrequirements.txt + -rtest-requirements.txt +setenv = + HUBS_CONFIG={toxinidir}/hubs/tests/hubs_test.cfg + PYTHONPATH={toxinidir} +whitelist_externals = + rm +commands = + rm -f /var/tmp/fedora-hubs-cache.db* + nosetests --with-coverage --cover-erase --cover-package=hubs {posargs:hubs} + +[testenv:js] +skip_install = True +usedevelop = False +deps = +whitelist_externals = + npm +changedir = {toxinidir}/hubs/static/client +commands = + npm install + npm test + +[testenv:docs] +changedir = docs +deps = sphinx +whitelist_externals = + mkdir +commands= + mkdir -p _static + sphinx-build -W -b html -d {envtmpdir}/doctrees . _build/html + + +[testenv:lint] +deps = + flake8 > 3.0 +commands = + python -m flake8 {posargs} + + +[flake8] +show-source = True +exclude = .git,.tox,dist,*egg,doc