diff --git a/.travis.yml b/.travis.yml index 8eeea00f..94600828 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ python: - "3.4" env: + - DJANGO="django==1.7" - DJANGO="django==1.6.5" - DJANGO="django==1.5.8" - DJANGO="django==1.4.13" @@ -26,6 +27,8 @@ script: matrix: exclude: + - python: "2.6" + env: DJANGO="django==1.7" - python: "3.2" env: DJANGO="django==1.4.13" - python: "3.3" diff --git a/tests/conftest.py b/tests/conftest.py index 0c3a5759..986c4df6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,6 @@ +import django + + def pytest_configure(): from django.conf import settings @@ -32,7 +35,6 @@ def pytest_configure(): 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'tests', ), PASSWORD_HASHERS=( 'django.contrib.auth.hashers.SHA1PasswordHasher', @@ -64,8 +66,10 @@ def pytest_configure(): 'provider.oauth2', ) + if django.VERSION >= (1, 5): + settings.INSTALLED_APPS += ('tests',) + try: - import django django.setup() except AttributeError: pass diff --git a/tests/models.py b/tests/models.py index 91a02abe..fed7533a 100644 --- a/tests/models.py +++ b/tests/models.py @@ -1,5 +1,13 @@ -from django.contrib.auth.models import User +from django.db import models +from django.contrib.auth.models import AbstractBaseUser, BaseUserManager -class CustomUser(User): +class CustomUser(AbstractBaseUser): + email = models.EmailField(max_length=255, unique=True) + + objects = BaseUserManager() + USERNAME_FIELD = 'email' + + class Meta: + app_label = 'tests' diff --git a/tests/settings.py b/tests/settings.py index 0d837be0..e3dadd33 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -95,7 +95,6 @@ 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', - 'tests', ) # OAuth is optional and won't work if there is no oauth_provider & oauth2 @@ -134,5 +133,5 @@ import django -if django.VERSION < (1, 3): - INSTALLED_APPS += ('staticfiles',) +if django.VERSION >= (1, 5): + INSTALLED_APPS += ('tests',) diff --git a/tests/test_views.py b/tests/test_views.py index 45b23d55..34526f34 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -15,8 +15,6 @@ from rest_framework_jwt import utils from rest_framework_jwt.settings import api_settings, DEFAULTS -from .models import CustomUser - NO_CUSTOM_USER_MODEL = 'Custom User Model only supported after Django 1.5' @@ -123,6 +121,8 @@ class CustomUserObtainJSONWebTokenTests(TestCase): urls = 'tests.test_views' def setUp(self): + from .models import CustomUser + self.email = 'jpueblo@example.com' self.password = 'password' user = CustomUser.objects.create(email=self.email) diff --git a/tox.ini b/tox.ini index 2ee975d0..4350ac6c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,7 @@ [tox] downloadcache = {toxworkdir}/cache/ envlist = + py3.4-django1.7,py3.3-django1.7,py3.2-django1.7,py2.7-django1.7, py3.4-django1.6,py3.3-django1.6,py3.2-django1.6,py2.7-django1.6,py2.6-django1.6, py3.4-django1.5,py3.3-django1.5,py3.2-django1.5,py2.7-django1.5,py2.6-django1.5, py2.7-django1.4,py2.6-django1.4 @@ -14,6 +15,34 @@ deps = pytest==2.5.2 flake8==2.2.2 commands = ./runtests.py --lintonly +[testenv:py3.4-django1.7] +basepython = python3.4 +deps = Django==1.7 + djangorestframework>=2.3.11 + PyJWT>=0.1.8 + pytest-django==2.6.1 + +[testenv:py3.3-django1.7] +basepython = python3.3 +deps = Django==1.7 + djangorestframework>=2.3.11 + PyJWT>=0.1.8 + pytest-django==2.6.1 + +[testenv:py3.2-django1.7] +basepython = python3.2 +deps = Django==1.7 + djangorestframework>=2.3.11 + PyJWT>=0.1.8 + pytest-django==2.6.1 + +[testenv:py2.7-django1.7] +basepython = python2.7 +deps = Django==1.7 + djangorestframework>=2.3.11 + PyJWT>=0.1.8 + pytest-django==2.6.1 + [testenv:py3.4-django1.6] basepython = python3.4 deps = Django==1.6.3