From 8224c46c84bc0d25c36d49d13610e8c4d02e2c5c Mon Sep 17 00:00:00 2001 From: Tim Bell Date: Wed, 21 Oct 2015 09:35:36 +1100 Subject: Enable tests to run with Django >= 1.7 and silence warnings --- wkhtmltopdf/tests/run.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wkhtmltopdf/tests/run.py b/wkhtmltopdf/tests/run.py index a840e68..5004ee1 100644 --- a/wkhtmltopdf/tests/run.py +++ b/wkhtmltopdf/tests/run.py @@ -2,10 +2,12 @@ import os import sys +import django from django.conf import settings DIRNAME = os.path.abspath(os.path.dirname(__file__)) +sys.path.insert(0, os.getcwd()) settings.configure( DEBUG=True, @@ -19,6 +21,10 @@ settings.configure( 'wkhtmltopdf.tests', 'wkhtmltopdf', ), + MIDDLEWARE_CLASSES=( + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + ), MEDIA_ROOT=os.path.join(DIRNAME, 'media'), MEDIA_URL='/media/', STATIC_ROOT=os.path.join(DIRNAME, 'static'), @@ -26,6 +32,12 @@ settings.configure( WKHTMLTOPDF_DEBUG=True, ) +try: + django.setup() +except AttributeError: + pass # Django < 1.7; okay to ignore + + try: from django.test.runner import DiscoverRunner except ImportError: -- cgit v1.2.3