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
sudo: false
dist: trusty
cache:
- apt
- pip
services:
- memcached
python:
- '2.7'
- '3.4'
- '3.5'
- redis
addons:
apt:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
- python3-enchant
- python2-enchant
- python-enchant
- graphviz
python:
- "2.7"
- "3.5"
- "3.6"
env:
global:
- DISPLAY=:99.0
matrix:
- DJANGO="Django<1.9,>=1.8"
- DJANGO="Django<1.10,>=1.9"
- DJANGO="Django<1.11,>=1.10"
- DJANGO="https://github.com/django/django/archive/master.tar.gz#egg=django"
- TOXENV=qa
- TOXENV=docs
- DJANGO=18
- DJANGO=19
- DJANGO=110
- DJANGO=master
matrix:
fast_finish: true
allow_failures:
- env: DJANGO="https://github.com/django/django/archive/master.tar.gz#egg=django"
- env: DJANGO=master
install:
- pip install --upgrade pip
- pip install -r requirements_dev.txt
- 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
- pip install --upgrade pip tox
- pip install -U coveralls
- 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:
- isort --check-only --recursive --diff .
- flake8 --jobs=2 .
- pep257 --explain --source --count django_select2
- "(cd docs; make spelling)"
- coverage run --source=django_select2 -m py.test
- |
if [[ -z $DJANGO ]]; then
tox -e $TOXENV
else
tox -e py$(echo $TRAVIS_PYTHON_VERSION | sed -e 's/\.//g')-dj$DJANGO
fi
after_success:
- coveralls
deploy:

View File

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

View File

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

View File

@ -1,28 +1,31 @@
#
# 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
babel==2.2.0 # via sphinx
coverage==4.3
django-appconf==1.0.1
django-redis==4.6.0
docutils==0.12 # via sphinx
flake8==2.5.2
isort==4.2.2
Jinja2==2.8
MarkupSafe==0.23
jinja2==2.8 # via sphinx
markupsafe==0.23 # via jinja2
mccabe==0.4.0
pep257==0.7.0
pydocstyle==1.1.1
pep8-naming==0.3.3
pep8==1.7.0 # via flake8
py==1.4.31 # via pytest
pyenchant==1.6.6
pyflakes==1.0.0 # via flake8
Pygments==2.1
pygments==2.1 # via sphinx
pytest-django==2.9.1
pytest==2.8.7
pytz==2015.7 # via babel
redis==2.10.5 # via django-redis
selenium==2.50.1
six==1.10.0 # via django-appconf, sphinx, sphinxcontrib-spelling
snowballstemmer==1.2.1 # via sphinx

View File

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

View File

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

View File

@ -47,8 +47,11 @@ USE_L10N = True
if os.environ.get('TRAVIS'):
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'localhost:11211',
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"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