Skip to content

Commit

Permalink
Update test environment
Browse files Browse the repository at this point in the history
 - Add python 3.6
 - Drop Python 3.4
 - Use tox on travis
 - Add chrome and gecko driver
 - Do not wait for chrome before quit
  • Loading branch information
codingjoe committed Dec 28, 2016
1 parent 9b15fd2 commit 5f6f35f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 32 deletions.
42 changes: 30 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
language: python
sudo: false
dist: trusty
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
cache:
- pip
- apt
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
env:
global:
- DISPLAY=:99.0
matrix:
- DJANGO="Django<1.9,>=1.8"
- DJANGO="Django<1.10,>=1.9"
- DJANGO="-e git+https://github.com/django/django.git@master#egg=Django"
- TOXENV=qa
- DJANGO=18
- DJANGO=19
- DJANGO=110
- DJANGO=master
matrix:
fast_finish: true
allow_failures:
- env: DJANGO="-e git+https://github.com/django/django.git@master#egg=Django"
- env: DJANGO=master
install:
- pip install --upgrade pip
- pip install -r requirements-dev.txt
- pip install $DJANGO
- 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 s3file
- coverage run --source=s3file -m 'pytest'
- |
if [[ $TOXENV == qa ]]; then
tox -e qa
else
tox -e py$(echo $TRAVIS_PYTHON_VERSION | sed -e 's/\.//g')-dj$DJANGO
fi
after_success:
- coveralls
8 changes: 3 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
# pip-compile requirements-dev.in
#
-e .
coverage==4.3
django-appconf==1.0.2
flake8==3.2.1
isort==4.2.5
mccabe==0.5.3 # via flake8
pep257==0.7.0
pydocstyle==1.1.1
pep8-naming==0.4.1
pep8==1.7.0 # via flake8
pluggy==0.4.0 # via tox
py==1.4.32 # via pytest, tox
py==1.4.32 # via pytest
pyflakes==1.3.0 # via flake8
pytest-django==3.1.2
pytest==3.0.5
selenium==3.0.2
six==1.10.0 # via django-appconf
tox==2.5.0
virtualenv==15.1.0 # via tox
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pytest]
[tool:pytest]
addopts = --tb=short -rxs
DJANGO_SETTINGS_MODULE=tests.testapp.settings
norecursedirs = env docs
Expand All @@ -10,8 +10,8 @@ statistics = true
show-source = true
exclude = */migrations/*,docs/*,env/*,.tox/*

[pep257]
add-ignore = D100,D102,D103,D104
[pydocstyle]
add-ignore = D100,D101,D102,D103,D104
match-dir = (?!tests|env|\.).*

[isort]
Expand Down
18 changes: 12 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@

import os
import tempfile
from time import sleep

import pytest
from django.core.files.base import ContentFile
from django.utils.encoding import force_text
from selenium import webdriver
from selenium.common.exceptions import WebDriverException


browsers = {
'firefox': webdriver.Firefox,
'phantomjs': webdriver.PhantomJS,
'chrome': webdriver.Chrome,
'firefox': webdriver.Firefox,
}


@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)')

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 isinstance(b, webdriver.Chrome):
# chrome needs a couple of seconds before it can be quit
sleep(5)
b.quit()


@pytest.fixture
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
[tox]
envlist = py{27,34,35}-django{18,19,master},qa
envlist = py{27,35,36}-dj{18,19,110,master},qa
[testenv]
setenv=
DISPLAY=:99.0
PYTHONPATH = {toxinidir}
deps=
-rrequirements-dev.txt
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
djangomaster: -egit+https://github.com/django/django.git@master#egg=Django
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=
py.test \
coverage run --source=s3file -m 'pytest' \
--basetemp={envtmpdir} \
--ignore=.tox \
{posargs}
Expand All @@ -22,4 +23,4 @@ deps=
commands=
isort --check-only --recursive --diff {posargs}
flake8 --jobs=2 {posargs}
pep257 --verbose --explain --source --count {posargs}
pydocstyle --verbose --explain --source --count {posargs}

0 comments on commit 5f6f35f

Please sign in to comment.