From 15049895ee670f4a06d936a512a9dd187dfac102 Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Fri, 26 Jan 2018 09:53:46 +0200 Subject: [PATCH 1/6] requiremests: Update to newest versions Updates: * Django 1.11.8 to 1.11.9 * Django Rest Framework 3.7.3 to 3.7.7 * certifi 2017.11.5 to 2018.1.18 * owslib 0.15.0 to 0.16.0 * raven 6.3.0 to 6.5.0 --- requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index bf3b14d9..28f1ba8c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,21 +2,21 @@ # # prequ update # -certifi==2017.11.5 # via requests +certifi==2018.1.18 # via requests chardet==3.0.4 # via requests -django==1.11.8 +django==1.11.9 django-environ==0.4.4 django-filter==1.1.0 -djangorestframework==3.7.3 +djangorestframework==3.7.7 djangorestframework-gis==0.12 idna==2.6 # via requests lxml==4.1.1 -owslib==0.15.0 +owslib==0.16.0 psycopg2==2.7.3.2 pyproj==1.9.5.1 # via owslib python-dateutil==2.6.1 # via owslib pytz==2017.3 -raven==6.3.0 +raven==6.5.0 requests==2.18.4 # via owslib six==1.11.0 # via django-environ, djangorestframework-gis, python-dateutil urllib3==1.22 # via requests From 1994d2db80c808707cf5773c5b95c3989b8df07e Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Fri, 26 Jan 2018 09:56:36 +0200 Subject: [PATCH 2/6] requirements-dev: Update to newest versions Update all dev requirements to newest available versions. --- requirements-dev.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 4a2e038e..8afe099e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,24 +2,24 @@ # # prequ update # -attrs==17.3.0 # via pytest -autoflake==1.0 -autopep8==1.3.3 +attrs==17.4.0 # via pytest +autoflake==1.1 +autopep8==1.3.4 coverage==4.4.2 # via pytest-cov -decorator==4.1.2 # via ipython, traitlets -django-extensions==1.9.8 +decorator==4.2.1 # via ipython, traitlets +django-extensions==1.9.9 factory-boy==2.8.1 -faker==0.8.7 # via factory-boy +faker==0.8.10 # via factory-boy flake8==3.5.0 freezegun==0.3.9 inflection==0.3.1 # via pytest-factoryboy ipython==6.2.1 ipython-genutils==0.2.0 # via traitlets isort==4.2.15 -jedi==0.11.0 # via ipython +jedi==0.11.1 # via ipython mccabe==0.6.1 # via flake8 -parso==0.1.0 # via jedi -pexpect==4.3.0 # 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 pytest prompt-toolkit==1.0.15 # via ipython @@ -29,7 +29,7 @@ pycodestyle==2.3.1 # via autopep8, flake8 pydocstyle==2.1.1 pyflakes==1.6.0 # via autoflake, flake8 pygments==2.2.0 # via ipython -pytest==3.3.1 +pytest==3.3.2 pytest-cov==2.5.1 pytest-django==3.1.2 pytest-factoryboy==1.3.1 @@ -39,6 +39,6 @@ six==1.11.0 # via django-extensions, faker, freezegun, prompt-tool snowballstemmer==1.2.1 # via pydocstyle text-unidecode==1.1 # via faker traitlets==4.3.2 # via ipython -typing==3.6.2 # via django-extensions, ipython +typing==3.6.4 # via django-extensions, ipython wcwidth==0.1.7 # via prompt-toolkit -werkzeug==0.13 +werkzeug==0.14.1 From 8af98ed9d9ad438d551632a6839aa9c215f87a4a Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Fri, 26 Jan 2018 10:13:22 +0200 Subject: [PATCH 3/6] Travis: Run tests with DEBUG=0 Tests should be run for production code, not development code, so set DEBUG=0 when running tests. There might be many differences between production and development code. At least the following is known: In the development environment "django_extensions" is added to INSTALLED_APPS, but it's not used in production environment. --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index df1ea53d..dac664bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,11 @@ python: - '3.5' - '3.6' +env: + global: + - DEBUG=0 + - SECRET_KEY=topsecret123 + cache: pip # As of 2017-08 the new travis trusty images have broken postgis, @@ -35,6 +40,3 @@ script: fi after_success: codecov - -env: - - SECRET_KEY=topsecret123 From 0e43f54708a36e3055b51c5dc777883a3013a2ea Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Fri, 26 Jan 2018 10:21:35 +0200 Subject: [PATCH 4/6] Separate requirements-test from requirements-dev Tests should be ran with minimum set of extra requirements installed to make the tests more realistic. --- .travis.yml | 3 ++- requirements-dev.in | 10 ---------- requirements-dev.txt | 22 +++------------------- requirements-test.in | 10 ++++++++++ requirements-test.txt | 23 +++++++++++++++++++++++ 5 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 requirements-test.in create mode 100644 requirements-test.txt diff --git a/.travis.yml b/.travis.yml index dac664bc..cc675a0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,8 @@ addons: packages: - postgresql-9.6-postgis-2.3 -install: 'pip install codecov -r requirements.txt -r requirements-dev.txt' +install: + - pip install codecov -r requirements.txt -r requirements-test.txt before_script: - psql -c 'create database parkkihubi;' -U postgres diff --git a/requirements-dev.in b/requirements-dev.in index 41f9a446..74ac572a 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,17 +1,7 @@ autoflake autopep8 django-extensions -flake8 -freezegun ipython isort pydocstyle -pytest -pytest-cov -pytest-django -pytest-factoryboy werkzeug - -# Factory Boy 2.9.0 to 2.9.2 don't seem to work. See -# https://github.com/pytest-dev/pytest-factoryboy/issues/47 -factory-boy!=2.9.0,!=2.9.1,!=2.9.2 diff --git a/requirements-dev.txt b/requirements-dev.txt index 8afe099e..44c22d63 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,42 +2,26 @@ # # prequ update # -attrs==17.4.0 # via pytest autoflake==1.1 autopep8==1.3.4 -coverage==4.4.2 # via pytest-cov decorator==4.2.1 # via ipython, traitlets django-extensions==1.9.9 -factory-boy==2.8.1 -faker==0.8.10 # via factory-boy -flake8==3.5.0 -freezegun==0.3.9 -inflection==0.3.1 # via pytest-factoryboy ipython==6.2.1 ipython-genutils==0.2.0 # via traitlets isort==4.2.15 jedi==0.11.1 # via ipython -mccabe==0.6.1 # via flake8 parso==0.1.1 # via jedi pexpect==4.3.1 # via ipython pickleshare==0.7.4 # via ipython -pluggy==0.6.0 # via pytest prompt-toolkit==1.0.15 # via ipython ptyprocess==0.5.2 # via pexpect -py==1.5.2 # via pytest -pycodestyle==2.3.1 # via autopep8, flake8 +pycodestyle==2.3.1 # via autopep8 pydocstyle==2.1.1 -pyflakes==1.6.0 # via autoflake, flake8 +pyflakes==1.6.0 # via autoflake pygments==2.2.0 # via ipython -pytest==3.3.2 -pytest-cov==2.5.1 -pytest-django==3.1.2 -pytest-factoryboy==1.3.1 -python-dateutil==2.6.1 # via faker, freezegun simplegeneric==0.8.1 # via ipython -six==1.11.0 # via django-extensions, faker, freezegun, prompt-toolkit, pydocstyle, pytest, python-dateutil, traitlets +six==1.11.0 # via django-extensions, prompt-toolkit, pydocstyle, traitlets snowballstemmer==1.2.1 # via pydocstyle -text-unidecode==1.1 # via faker traitlets==4.3.2 # via ipython typing==3.6.4 # via django-extensions, ipython wcwidth==0.1.7 # via prompt-toolkit diff --git a/requirements-test.in b/requirements-test.in new file mode 100644 index 00000000..f68a6cd9 --- /dev/null +++ b/requirements-test.in @@ -0,0 +1,10 @@ +flake8 +freezegun +pytest +pytest-cov +pytest-django +pytest-factoryboy + +# Factory Boy 2.9.0 to 2.9.2 don't seem to work. See +# https://github.com/pytest-dev/pytest-factoryboy/issues/47 +factory-boy!=2.9.0,!=2.9.1,!=2.9.2 diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 00000000..4b4c31a2 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,23 @@ +# This file is autogenerated by Prequ. To update, run: +# +# prequ update +# +attrs==17.4.0 # via pytest +coverage==4.4.2 # via pytest-cov +factory-boy==2.8.1 +faker==0.8.10 # via factory-boy +flake8==3.5.0 +freezegun==0.3.9 +inflection==0.3.1 # via pytest-factoryboy +mccabe==0.6.1 # via flake8 +pluggy==0.6.0 # via pytest +py==1.5.2 # via pytest +pycodestyle==2.3.1 # via flake8 +pyflakes==1.6.0 # via flake8 +pytest==3.3.2 +pytest-cov==2.5.1 +pytest-django==3.1.2 +pytest-factoryboy==1.3.1 +python-dateutil==2.6.1 # via faker, freezegun +six==1.11.0 # via faker, freezegun, pytest, python-dateutil +text-unidecode==1.1 # via faker From 46b512e0bddb17176919731b2f347a8e9534b105 Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Fri, 26 Jan 2018 10:56:29 +0200 Subject: [PATCH 5/6] 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} From 7c05a3de854c9d8bdd34ae7fe9d2b63dd8247782 Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Fri, 26 Jan 2018 11:16:04 +0200 Subject: [PATCH 6/6] Separate requirements-style from requirements-test Make the requirements-test.txt even smaller so that there is a minimal set of dependencies installed while running the tests. --- requirements-style.in | 1 + requirements-style.txt | 8 ++++++++ requirements-test.in | 1 - requirements-test.txt | 4 ---- tox.ini | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 requirements-style.in create mode 100644 requirements-style.txt diff --git a/requirements-style.in b/requirements-style.in new file mode 100644 index 00000000..39304807 --- /dev/null +++ b/requirements-style.in @@ -0,0 +1 @@ +flake8 diff --git a/requirements-style.txt b/requirements-style.txt new file mode 100644 index 00000000..da70b1cf --- /dev/null +++ b/requirements-style.txt @@ -0,0 +1,8 @@ +# This file is autogenerated by Prequ. To update, run: +# +# prequ update +# +flake8==3.5.0 +mccabe==0.6.1 # via flake8 +pycodestyle==2.3.1 # via flake8 +pyflakes==1.6.0 # via flake8 diff --git a/requirements-test.in b/requirements-test.in index f68a6cd9..83dfad44 100644 --- a/requirements-test.in +++ b/requirements-test.in @@ -1,4 +1,3 @@ -flake8 freezegun pytest pytest-cov diff --git a/requirements-test.txt b/requirements-test.txt index 4b4c31a2..ecdb1dc0 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -6,14 +6,10 @@ attrs==17.4.0 # via pytest coverage==4.4.2 # via pytest-cov factory-boy==2.8.1 faker==0.8.10 # via factory-boy -flake8==3.5.0 freezegun==0.3.9 inflection==0.3.1 # via pytest-factoryboy -mccabe==0.6.1 # via flake8 pluggy==0.6.0 # via pytest py==1.5.2 # via pytest -pycodestyle==2.3.1 # via flake8 -pyflakes==1.6.0 # via flake8 pytest==3.3.2 pytest-cov==2.5.1 pytest-django==3.1.2 diff --git a/tox.ini b/tox.ini index 2fa29757..b4befcb6 100644 --- a/tox.ini +++ b/tox.ini @@ -19,5 +19,5 @@ commands = prequ check -v [testenv:style] basepython = python3.4 -deps = -rrequirements-test.txt +deps = -rrequirements-style.txt commands = flake8 {posargs}