From 892093c19cafe1c90ec77f8647cfdabe85be0197 Mon Sep 17 00:00:00 2001 From: James Robert Date: Tue, 23 Sep 2014 12:49:43 -0400 Subject: [PATCH] fix tests --- .travis.yml | 2 +- jsonate/__init__.py | 3 ++- jsonate/fields.py | 14 ++++++++++---- jsonate/form_fields.py | 5 ++++- jsonate/json_encoder.py | 5 ++++- jsonate/models.py | 2 +- jsonate/utils.py | 5 ++++- jsonate/widgets.py | 5 ++++- test_project/manage.py | 9 +++++++-- test_project/settings.py | 7 ++++--- 10 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index e7ce04c..c73f0f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ matrix: - python: "2.6" env: DJANGO=dev install: - - pip install django==${DJANGO} + - pip install django==${DJANGO} Pillow - pip install . language: python python: diff --git a/jsonate/__init__.py b/jsonate/__init__.py index 57a653c..cb6b094 100644 --- a/jsonate/__init__.py +++ b/jsonate/__init__.py @@ -1 +1,2 @@ -from jsonate.utils import jsonate \ No newline at end of file +from jsonate.utils import jsonate +from . import monkey_patches \ No newline at end of file diff --git a/jsonate/fields.py b/jsonate/fields.py index 6fc5fed..ae86d6b 100644 --- a/jsonate/fields.py +++ b/jsonate/fields.py @@ -1,5 +1,8 @@ from django.db import models -from django.utils import simplejson as json +try: + import json +except ImportError: + from django.utils import simplejson as json from jsonate.utils import jsonate from jsonate.widgets import JsonateWidget from jsonate.form_fields import JsonateFormField @@ -31,6 +34,9 @@ def formfield(self, **kwargs): } defaults.update(kwargs) return super(JsonateField, self).formfield(**defaults) - -from south.modelsinspector import add_introspection_rules -add_introspection_rules([], ["^jsonate\.fields\.JsonateField"]) \ No newline at end of file + +try: + from south.modelsinspector import add_introspection_rules + add_introspection_rules([], ["^jsonate\.fields\.JsonateField"]) +except ImportError: + pass \ No newline at end of file diff --git a/jsonate/form_fields.py b/jsonate/form_fields.py index e4caf74..ab97e66 100644 --- a/jsonate/form_fields.py +++ b/jsonate/form_fields.py @@ -1,6 +1,9 @@ from django.forms import CharField, ValidationError from jsonate.widgets import JsonateWidget -from django.utils import simplejson as json +try: + import json +except ImportError: + from django.utils import simplejson as json def JsonateValidator(value): diff --git a/jsonate/json_encoder.py b/jsonate/json_encoder.py index cc3190e..ad2cd31 100644 --- a/jsonate/json_encoder.py +++ b/jsonate/json_encoder.py @@ -1,6 +1,9 @@ from datetime import datetime, date from decimal import Decimal -from django.utils import simplejson as json +try: + import json +except ImportError: + from django.utils import simplejson as json from django.db.models.query import QuerySet, ValuesQuerySet from django.db.models import Model from django.db.models.fields.related import ForeignKey diff --git a/jsonate/models.py b/jsonate/models.py index 3447dbb..5fcfd9c 100644 --- a/jsonate/models.py +++ b/jsonate/models.py @@ -1 +1 @@ -import jsonate.monkey_patches #@UnusedImport \ No newline at end of file +import jsonate.monkey_patches \ No newline at end of file diff --git a/jsonate/utils.py b/jsonate/utils.py index 8d0e6bb..affcc13 100644 --- a/jsonate/utils.py +++ b/jsonate/utils.py @@ -1,4 +1,7 @@ -from django.utils import simplejson as json +try: + import json +except ImportError: + from django.utils import simplejson as json from jsonate.json_encoder import JsonateEncoder diff --git a/jsonate/widgets.py b/jsonate/widgets.py index 0710bff..c569db7 100644 --- a/jsonate/widgets.py +++ b/jsonate/widgets.py @@ -1,5 +1,8 @@ from django import forms -from django.utils import simplejson as json +try: + import json +except ImportError: + from django.utils import simplejson as json from jsonate.utils import jsonate class JsonateWidget(forms.Textarea): diff --git a/test_project/manage.py b/test_project/manage.py index 5e78ea9..ea36995 100755 --- a/test_project/manage.py +++ b/test_project/manage.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from django.core.management import execute_manager + try: import settings # Assumed to be in the same directory. except ImportError: @@ -8,4 +8,9 @@ sys.exit(1) if __name__ == "__main__": - execute_manager(settings) + try: + from django.core.management import execute_from_command_line + execute_from_command_line() + except ImportError: + from django.core.management import execute_manager + execute_manager(settings) \ No newline at end of file diff --git a/test_project/settings.py b/test_project/settings.py index fcad034..39f9df5 100644 --- a/test_project/settings.py +++ b/test_project/settings.py @@ -7,11 +7,12 @@ DEBUG = True TEMPLATE_DEBUG = DEBUG +SECRET_KEY = "thisIsTotallyASecretJkLolHaHa!1!!1!" + DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'test_jsonate', - 'USER': 'root' + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'test_jsonate' } }