From 3bda845310101265bcd72caf73418f9aefb9d3f7 Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Mon, 29 Sep 2014 20:41:34 +0200 Subject: [PATCH] Updates test runner for Django 1.7, PostgreSQL & Redis. --- README.rst | 5 +++-- requirements.txt | 1 + runtests.py | 41 +++++++++++++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index b99f6f9..d27541a 100644 --- a/README.rst +++ b/README.rst @@ -14,8 +14,9 @@ Quick start Requirements ............ -Django-cachalot currently requires Django 1.6 -and `django-redis `_ as your default +Django-cachalot currently requires Django 1.6 or 1.7 +and `locmem `_ +or `django-redis `_ as your default cache backend. It should work with both Python 2 & 3. Usage diff --git a/requirements.txt b/requirements.txt index d08919c..ba0a2f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ Django>=1.6 +django-redis diff --git a/runtests.py b/runtests.py index b6fa89b..2fd586d 100755 --- a/runtests.py +++ b/runtests.py @@ -2,26 +2,55 @@ # coding: utf-8 from __future__ import unicode_literals +import os import sys + +import django from django.conf import settings +from django.test.runner import DiscoverRunner + + +DATABASES = { + 'sqlite3': { + 'ENGINE': 'django.db.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'cachalot', + 'USER': 'cachalot', + 'HOST': 'localhost', + 'PORT': '5432', + }, +} + + +CACHES = { + 'locmem': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + }, + 'redis': { + 'BACKEND': 'redis_cache.cache.RedisCache', + 'LOCATION': '127.0.0.1:6379:0', + } +} settings.configure( DEBUG=True, - DATABASES={ - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - }, - }, + DATABASES={'default': DATABASES[os.environ.get('DB_BACKEND', 'sqlite3')]}, INSTALLED_APPS=( 'cachalot', 'django.contrib.auth', 'django.contrib.contenttypes', ), + CACHES={'default': CACHES[os.environ.get('CACHE_BACKEND', 'locmem')]}, + MIDDLEWARE_CLASSES=(), ) if __name__ == '__main__': - from django.test.runner import DiscoverRunner + if django.VERSION[:2] >= (1, 7): + django.setup() + test_runner = DiscoverRunner() failures = test_runner.run_tests(['cachalot']) if failures: