From f2cf86f7a637173499316e212f408a91e8f50a43 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 12 Feb 2016 19:42:48 +0100 Subject: [PATCH] add tox.ini to test on django 1.7, 1.8, 1.9 and with sqlite and pg --- .coveragerc | 2 ++ getlasso.sh | 20 ++++++++++++++++++++ testsettings.py | 6 ++++-- tox.ini | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 .coveragerc create mode 100755 getlasso.sh create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..c712d25 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = tests/* diff --git a/getlasso.sh b/getlasso.sh new file mode 100755 index 0000000..680da39 --- /dev/null +++ b/getlasso.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Get venv site-packages path +DSTDIR=`python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'` + +# Get not venv site-packages path +# Remove first path (assuming that is the venv path) +NONPATH=`echo $PATH | sed 's/^[^:]*://'` +SRCDIR=`PATH=$NONPATH python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'` + +# Clean up +rm -f $DSTDIR/lasso.* +rm -f $DSTDIR/_lasso.* + +# Link +ln -sv $SRCDIR/lasso.py $DSTDIR +ln -sv $SRCDIR/_lasso.* $DSTDIR + +exit 0 + diff --git a/testsettings.py b/testsettings.py index 5f7bb5c..5f40084 100644 --- a/testsettings.py +++ b/testsettings.py @@ -1,11 +1,12 @@ +import os from django.conf import global_settings DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', + 'ENGINE': 'django.db.backends.' + os.environ.get('DB_ENGINE', 'sqlite3'), 'NAME': 'mellon.sqlite3', 'TEST': { - 'NAME': 'mellon-test.sqlite', + 'NAME': 'mellon-test-' + os.environ.get('DB_ENGINE', 'sqlite3'), }, } } @@ -13,3 +14,4 @@ DEBUG = True SECRET_KEY='xx' INSTALLED_APPS = ('mellon', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions') MIDDLEWARE_CLASSES = global_settings.MIDDLEWARE_CLASSES +ROOT_URLCONF = 'mellon.urls' diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..8cb3fcc --- /dev/null +++ b/tox.ini @@ -0,0 +1,36 @@ +[tox] +envlist = {coverage-,}{dj17,dj18,dj19}-{pg,sqlite} + +[testenv] +whitelist_externals = + /bin/mv +setenv = + DJANGO_SETTINGS_MODULE=testsettings + PYTHONPATH=. + sqlite: DB_ENGINE=sqlite3 + pg: DB_ENGINE=postgresql_psycopg2 + coverage: COVERAGE=--junit-xml=junit-{envname}.xml --cov=mellon --cov-report xml +usedevelop = + coverage: true + nocoverage: false +deps = + dj17: django>1.7,<1.8 + dj18: django>1.8,<1.9 + dj19: django>1.9,<1.10 + pg: psycopg2 + httmock + pytest + pytest-cov + pytest-random + pytest-mock + pytest-django + pytest-capturelog + lxml + cssselect + django-webtest + WebTest + pyquery +commands = + ./getlasso.sh + py.test --random {env:COVERAGE:} {posargs:tests} + coverage: mv coverage.xml coverage-{envname}.xml