Update test suite

- Add tox
- Add python 3.6
- Drop python 3.4
- Add chrome and gecko driver
- Switch tests from memcache to redis
This commit is contained in:
Johannes Hoppe 2016-12-28 19:43:59 +01:00
parent 9430a950c2
commit 6180846345
8 changed files with 105 additions and 46 deletions

View File

@ -1,48 +1,57 @@
language: python language: python
sudo: false sudo: false
dist: trusty
cache: cache:
- apt - apt
- pip - pip
services: services:
- memcached - redis
python:
- '2.7'
- '3.4'
- '3.5'
addons: addons:
apt: firefox: latest
apt:
sources:
- google-chrome
packages: packages:
- google-chrome-stable
- python3-enchant - python3-enchant
- python2-enchant - python-enchant
- graphviz - graphviz
python:
- "2.7"
- "3.5"
- "3.6"
env: env:
global: global:
- DISPLAY=:99.0 - DISPLAY=:99.0
matrix: matrix:
- DJANGO="Django<1.9,>=1.8" - TOXENV=qa
- DJANGO="Django<1.10,>=1.9" - TOXENV=docs
- DJANGO="Django<1.11,>=1.10" - DJANGO=18
- DJANGO="https://github.com/django/django/archive/master.tar.gz#egg=django" - DJANGO=19
- DJANGO=110
- DJANGO=master
matrix: matrix:
fast_finish: true fast_finish: true
allow_failures: allow_failures:
- env: DJANGO="https://github.com/django/django/archive/master.tar.gz#egg=django" - env: DJANGO=master
install: install:
- pip install --upgrade pip - pip install --upgrade pip tox
- pip install -r requirements_dev.txt - pip install -U coveralls
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]] || [[ $TRAVIS_PYTHON_VERSION == pypy ]]; then
pip install python-memcached; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3* ]] || [[ $TRAVIS_PYTHON_VERSION == pypy3 ]];
then pip install python3-memcached; fi
- pip install $DJANGO
- pip install coveralls
- sh -e /etc/init.d/xvfb start - sh -e /etc/init.d/xvfb start
before_script:
- mkdir bin
- curl -O https://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip -d bin
- curl -Lo geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz
- tar xzf geckodriver.tar.gz -C bin
- PATH=$PATH:$PWD/bin
script: script:
- isort --check-only --recursive --diff . - |
- flake8 --jobs=2 . if [[ -z $DJANGO ]]; then
- pep257 --explain --source --count django_select2 tox -e $TOXENV
- "(cd docs; make spelling)" else
- coverage run --source=django_select2 -m py.test tox -e py$(echo $TRAVIS_PYTHON_VERSION | sed -e 's/\.//g')-dj$DJANGO
fi
after_success: after_success:
- coveralls - coveralls
deploy: deploy:

View File

@ -75,4 +75,6 @@ class Select2Conf(AppConf):
""" """
class Meta: class Meta:
"""Prefix for all Django-Select2 settings."""
prefix = 'SELECT2' prefix = 'SELECT2'

View File

@ -1,12 +1,14 @@
coverage
django-appconf django-appconf
flake8 flake8
pep8-naming pep8-naming
mccabe mccabe
isort isort
pep257 pydocstyle
pytest pytest
pytest-django pytest-django
selenium selenium
sphinx sphinx
sphinxcontrib-spelling sphinxcontrib-spelling
pyenchant pyenchant
django-redis

View File

@ -1,28 +1,31 @@
# #
# This file is autogenerated by pip-compile # This file is autogenerated by pip-compile
# Make changes in requirements_dev.in, then run this to update: # To update, run:
# #
# pip-compile requirements_dev.in # pip-compile --output-file requirements-dev.txt requirements-dev.in
# #
alabaster==0.7.7 # via sphinx alabaster==0.7.7 # via sphinx
babel==2.2.0 # via sphinx babel==2.2.0 # via sphinx
coverage==4.3
django-appconf==1.0.1 django-appconf==1.0.1
django-redis==4.6.0
docutils==0.12 # via sphinx docutils==0.12 # via sphinx
flake8==2.5.2 flake8==2.5.2
isort==4.2.2 isort==4.2.2
Jinja2==2.8 jinja2==2.8 # via sphinx
MarkupSafe==0.23 markupsafe==0.23 # via jinja2
mccabe==0.4.0 mccabe==0.4.0
pep257==0.7.0 pydocstyle==1.1.1
pep8-naming==0.3.3 pep8-naming==0.3.3
pep8==1.7.0 # via flake8 pep8==1.7.0 # via flake8
py==1.4.31 # via pytest py==1.4.31 # via pytest
pyenchant==1.6.6 pyenchant==1.6.6
pyflakes==1.0.0 # via flake8 pyflakes==1.0.0 # via flake8
Pygments==2.1 pygments==2.1 # via sphinx
pytest-django==2.9.1 pytest-django==2.9.1
pytest==2.8.7 pytest==2.8.7
pytz==2015.7 # via babel pytz==2015.7 # via babel
redis==2.10.5 # via django-redis
selenium==2.50.1 selenium==2.50.1
six==1.10.0 # via django-appconf, sphinx, sphinxcontrib-spelling six==1.10.0 # via django-appconf, sphinx, sphinxcontrib-spelling
snowballstemmer==1.2.1 # via sphinx snowballstemmer==1.2.1 # via sphinx

View File

@ -1,5 +1,5 @@
[pytest] [pytest]
norecursedirs = env norecursedirs = env docs
addopts = --tb=short -rxs addopts = --tb=short -rxs
DJANGO_SETTINGS_MODULE=tests.testapp.settings DJANGO_SETTINGS_MODULE=tests.testapp.settings
@ -8,15 +8,17 @@ max-line-length = 120
max-complexity = 10 max-complexity = 10
statistics = true statistics = true
show-source = true show-source = true
exclude = docs,runtests.py,setup.py,env exclude = docs,runtests.py,setup.py,.tox,env
[pep257] [pep257]
match = (?!setup).*.py
match-dir = (?!tests|env|docs|\.).*
[isort] [isort]
atomic = true atomic = true
multi_line_output = 5 multi_line_output = 5
line_length = 79 line_length = 79
skip = manage.py,docs skip = manage.py,docs,.tox,env
known_first_party = django_select2, tests known_first_party = django_select2, tests
known_third_party = django known_third_party = django
combine_as_imports = true combine_as_imports = true

View File

@ -4,14 +4,16 @@ from __future__ import absolute_import, print_function, unicode_literals
import os import os
import random import random
import string import string
from time import sleep
import pytest import pytest
from django.utils.encoding import force_text
from selenium import webdriver from selenium import webdriver
from selenium.common.exceptions import WebDriverException from selenium.common.exceptions import WebDriverException
browsers = { browsers = {
# 'firefox': webdriver.Firefox, 'chrome': webdriver.Chrome,
# 'chrome': webdriver.Chrome, 'firefox': webdriver.Firefox,
'phantomjs': webdriver.PhantomJS, 'phantomjs': webdriver.PhantomJS,
} }
@ -23,8 +25,7 @@ def random_string(n):
) )
@pytest.fixture(scope='session', @pytest.yield_fixture(scope='session', params=sorted(browsers.keys()))
params=browsers.keys())
def driver(request): def driver(request):
if 'DISPLAY' not in os.environ: if 'DISPLAY' not in os.environ:
pytest.skip('Test requires display server (export DISPLAY)') pytest.skip('Test requires display server (export DISPLAY)')
@ -32,11 +33,14 @@ def driver(request):
try: try:
b = browsers[request.param]() b = browsers[request.param]()
except WebDriverException as e: except WebDriverException as e:
pytest.skip(e) pytest.skip(force_text(e))
else: else:
b.set_window_size(1200, 800) b.set_window_size(1200, 800)
request.addfinalizer(lambda *args: b.quit()) yield b
return b if request.param == 'chrome':
# chrome needs a couple of seconds before it can be quit
sleep(5)
b.quit()
@pytest.fixture @pytest.fixture

View File

@ -47,8 +47,11 @@ USE_L10N = True
if os.environ.get('TRAVIS'): if os.environ.get('TRAVIS'):
CACHES = { CACHES = {
'default': { "default": {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', "BACKEND": "django_redis.cache.RedisCache",
'LOCATION': 'localhost:11211', "LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
} }
} }

34
tox.ini Normal file
View File

@ -0,0 +1,34 @@
[tox]
envlist = py{27,35,36}-dj{18,19,110,master},qa,docs
[testenv]
setenv=
DISPLAY=:99.0
PYTHONPATH = {toxinidir}
deps=
-rrequirements-dev.txt
dj18: https://github.com/django/django/archive/stable/1.8.x.tar.gz#egg=django
dj19: https://github.com/django/django/archive/stable/1.9.x.tar.gz#egg=django
dj110: https://github.com/django/django/archive/stable/1.10.x.tar.gz#egg=django
djmaster: https://github.com/django/django/archive/master.tar.gz#egg=django
commands=
coverage run --source=s3file -m 'pytest' \
--basetemp={envtmpdir} \
--ignore=.tox \
{posargs}
[testenv:qa]
changedir={toxinidir}
deps=
-rrequirements-dev.txt
commands=
isort --check-only --recursive --diff {posargs}
flake8 --jobs=2 {posargs}
pydocstyle --verbose --explain --source --count {posargs}
[testenv:docs]
whitelist_externals=make
changedir={toxinidir}/docs
deps=
-rrequirements-dev.txt
https://github.com/django/django/archive/stable/1.10.x.tar.gz#egg=django
commands=make spelling