From 46b512e0bddb17176919731b2f347a8e9534b105 Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Fri, 26 Jan 2018 10:56:29 +0200 Subject: [PATCH] Travis: Use Tox for testing Using Tox for running the tests allows a bit cleaner setup and makes it possible to run all the same test environments locally too. --- .travis.yml | 44 ++++++++++++++++++++------------------------ requirements-dev.in | 1 + requirements-dev.txt | 6 +++++- setup.cfg | 4 ++-- tox.ini | 23 +++++++++++++++++++++++ 5 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index cc675a0b..c94f47b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,18 +4,24 @@ sudo: false dist: trusty language: python -python: - - '3.4' - - '3.5' - - '3.6' - -env: - global: - - DEBUG=0 - - SECRET_KEY=topsecret123 cache: pip +matrix: + include: + - python: "3.4" + - python: "3.5" + - python: "3.6" + - env: TOXENV=requirements + python: "3.4" + addons: null + before_script: null + - env: TOXENV=style + python: "3.4" + addons: null + before_script: null + + # As of 2017-08 the new travis trusty images have broken postgis, # so we have to specify the exact postgres version to install right addons addons: @@ -24,20 +30,10 @@ addons: packages: - postgresql-9.6-postgis-2.3 -install: - - pip install codecov -r requirements.txt -r requirements-test.txt - -before_script: - - psql -c 'create database parkkihubi;' -U postgres - - psql -U postgres -c "create extension postgis" - -script: - - flake8 - - pytest -ra -vvv --cov - - | - if [ "$TRAVIS_PYTHON_VERSION" = "3.4" ]; then - pip install -q prequ - prequ check -v - fi +install: pip install tox-travis codecov + +before_script: psql -U postgres -c "create extension postgis" + +script: tox after_success: codecov diff --git a/requirements-dev.in b/requirements-dev.in index 74ac572a..39ca22eb 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -4,4 +4,5 @@ django-extensions ipython isort pydocstyle +tox werkzeug diff --git a/requirements-dev.txt b/requirements-dev.txt index 44c22d63..b7691188 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -13,16 +13,20 @@ jedi==0.11.1 # via ipython parso==0.1.1 # via jedi pexpect==4.3.1 # via ipython pickleshare==0.7.4 # via ipython +pluggy==0.6.0 # via tox prompt-toolkit==1.0.15 # via ipython ptyprocess==0.5.2 # via pexpect +py==1.5.2 # via tox pycodestyle==2.3.1 # via autopep8 pydocstyle==2.1.1 pyflakes==1.6.0 # via autoflake pygments==2.2.0 # via ipython simplegeneric==0.8.1 # via ipython -six==1.11.0 # via django-extensions, prompt-toolkit, pydocstyle, traitlets +six==1.11.0 # via django-extensions, prompt-toolkit, pydocstyle, tox, traitlets snowballstemmer==1.2.1 # via pydocstyle +tox==2.9.1 traitlets==4.3.2 # via ipython typing==3.6.4 # via django-extensions, ipython +virtualenv==15.1.0 # via tox wcwidth==0.1.7 # via prompt-toolkit werkzeug==0.14.1 diff --git a/setup.cfg b/setup.cfg index a4b13812..eb04976a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ exclude = *migrations* ignore = E309 [flake8] -exclude = migrations +exclude = .tox,migrations max-line-length = 120 max-complexity = 10 @@ -27,7 +27,7 @@ line_length=120 multi_line_output=5 not_skip=__init__.py order_by_type=false -skip=migrations +skip=migrations,.tox wrap_length=120 [pydocstyle] diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..2fa29757 --- /dev/null +++ b/tox.ini @@ -0,0 +1,23 @@ +[tox] +envlist = py{34,35,36},requirements,style +skipsdist = True + +[testenv] +deps = + -rrequirements.txt + -rrequirements-test.txt +passenv = CI +setenv = + DEBUG=0 + SECRET_KEY=topsecret123 +commands = py.test -ra -vvv --strict --cov {posargs} + +[testenv:requirements] +basepython = python3.4 +deps = prequ==1.3.1 +commands = prequ check -v + +[testenv:style] +basepython = python3.4 +deps = -rrequirements-test.txt +commands = flake8 {posargs}