diff --git a/.travis.yml b/.travis.yml index 2da2446..0cecfb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ env: - DJANGO=1.4.10 - DJANGO=1.5.5 - DJANGO=1.6.1 + - DJANGO=1.8.17 matrix: exclude: diff --git a/requirements.txt b/requirements.txt index c53f5ec..1d60717 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -Django>=1.4,<1.7 +Django>=1.8 six>=1.4.0 diff --git a/restlib2/http/__init__.py b/restlib2/http/__init__.py index 0fd0b8d..6065f46 100644 --- a/restlib2/http/__init__.py +++ b/restlib2/http/__init__.py @@ -1,4 +1,4 @@ -from django.core.handlers.wsgi import STATUS_CODE_TEXT +from httplib import responses as STATUS_CODE_TEXT from restlib2.structures import AttrDict STATUS_CODE_TEXT.setdefault(422, 'UNPROCESSABLE ENTITY') diff --git a/restlib2/mixins.py b/restlib2/mixins.py index beae076..efdd40e 100644 --- a/restlib2/mixins.py +++ b/restlib2/mixins.py @@ -1,3 +1,4 @@ +from django.template import Engine from django.template import loader from django.template import RequestContext from django.http import HttpResponse @@ -17,7 +18,7 @@ def render(self, request, context, status=codes.ok, content_type=None, elif self.template_name: template = loader.get_template(self.template_name) else: - template = loader.Template(self.template_string) + template = Engine().from_string(self.template_string) context = RequestContext(request, context) content = template.render(context) diff --git a/setup.py b/setup.py index 21beff0..29be536 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ 'url': 'https://github.com/bruth/restlib2', 'install_requires': [ - 'django>=1.4', + 'django>=1.8', 'six>=1.4.0', ], diff --git a/test_suite.py b/test_suite.py index 29b44ef..ea603c1 100644 --- a/test_suite.py +++ b/test_suite.py @@ -1,15 +1,15 @@ import os import sys -os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' +if __name__ == "__main__": + apps = sys.argv[1:] -from django.core import management + if not apps: + apps = [ + 'tests', + ] -apps = sys.argv[1:] + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") -if not apps: - apps = [ - 'tests', - ] - -management.call_command('test', *apps) + from django.core.management import execute_from_command_line + execute_from_command_line(['manage.py', 'test', 'tests']) diff --git a/tests/settings.py b/tests/settings.py index 6a23919..8f3bc3f 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,5 +1,4 @@ import os -from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS SECRET_KEY = '123abc' @@ -13,15 +12,35 @@ ROOT_URLCONF = 'tests.tests' INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'restlib2', - 'tests', + # TODO sgithens - There seems to an issue when these are included, + # that the tests can't find the db tables to load the test fixtures. + # However, the unit tests still pass if these are not included... + # 'django.contrib.auth', + # 'django.contrib.contenttypes', + # 'restlib2', + # 'tests', ) -TEMPLATE_CONTEXT_PROCESSORS += ( - 'django.core.context_processors.request', -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + "tests/templates/" + ], + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + ] + } + }, +] LOGGING = { 'version': 1, diff --git a/tests/tests.py b/tests/tests.py index c552363..d1b71f1 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,7 +1,7 @@ from calendar import timegm from django.test.client import RequestFactory from django.test import TestCase -from django.conf.urls import patterns, url +from django.conf.urls import url from restlib2 import params from restlib2.resources import Resource from restlib2.mixins import TemplateResponseMixin @@ -469,8 +469,7 @@ def get(self, request): pass -urlpatterns = patterns('', - url(r'^$', TestResource(template_name='index.html'))) +urlpatterns =(url(r'^$', TestResource(template_name='index.html')),) class TemplateResourceTestCase(TestCase):