Commits

James Crasta committed 396390d Draft

Add DATABASES configuration to Django tests so they will run on Django 1.4. Fixes #109.

  • Participants
  • Parent commits 7a1d354

Comments (0)

Files changed (1)

File tests/ext_django/tests.py

 #!/usr/bin/env python
+
 from __future__ import unicode_literals
 
 import sys, os
 
 ##########################################################################
 # -- Django Initialization
-# 
+#
 # Unfortunately, we cannot do this in the setUp for a test case, as the
 # settings.configure method cannot be called more than once, and we cannot
 # control the order in which tests are run, so making a throwaway test won't
 # work either.
 
 from django.conf import settings
-settings.configure(INSTALLED_APPS=['ext_django', 'wtforms.ext.django'], DATABASE_ENGINE='sqlite3', TEST_DATABASE_NAME=':memory:')
+settings.configure(
+    INSTALLED_APPS = ['ext_django', 'wtforms.ext.django'],
+    # Django 1.0 to 1.3
+    DATABASE_ENGINE = 'sqlite3',
+    TEST_DATABASE_NAME = ':memory:',
+
+    # Django 1.4
+    DATABASES = {
+        'default': {
+            'ENGINE': 'django.db.backends.sqlite3',
+            'NAME': ':memory:'
+        }
+    }
+)
 
 from django.db import connection
 connection.creation.create_test_db(verbosity=0)
 
 from django.template import Context, Template
 from django.test import TestCase as DjangoTestCase
-from ext_django import models as test_models 
+from ext_django import models as test_models
 from unittest import TestCase
 from wtforms import Form, fields, validators
 from wtforms.compat import text_type
 
     def test_form_field(self):
         self.assertEqual(self._render('{% form_field form.a %}'), '<input id="a" name="a" type="text" value="">')
-        self.assertEqual(self._render('{% form_field a class=someclass onclick="alert()" %}'), 
+        self.assertEqual(self._render('{% form_field a class=someclass onclick="alert()" %}'),
                          '<input class="CLASSVAL&gt;!" id="a" name="a" onclick="alert()" type="text" value="">')
 
 class ModelFormTest(TestCase):