Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 40bd310

Browse files
committed
Add support for Django 1.7
1 parent 71ec0df commit 40bd310

File tree

6 files changed

+52
-9
lines changed

6 files changed

+52
-9
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ python:
88
- "3.4"
99

1010
env:
11+
- DJANGO="django==1.7"
1112
- DJANGO="django==1.6.5"
1213
- DJANGO="django==1.5.8"
1314
- DJANGO="django==1.4.13"
@@ -26,6 +27,8 @@ script:
2627

2728
matrix:
2829
exclude:
30+
- python: "2.6"
31+
env: DJANGO="django==1.7"
2932
- python: "3.2"
3033
env: DJANGO="django==1.4.13"
3134
- python: "3.3"

tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import django
2+
3+
14
def pytest_configure():
25
from django.conf import settings
36

@@ -32,7 +35,6 @@ def pytest_configure():
3235
'django.contrib.sessions',
3336
'django.contrib.messages',
3437
'django.contrib.staticfiles',
35-
'tests',
3638
),
3739
PASSWORD_HASHERS=(
3840
'django.contrib.auth.hashers.SHA1PasswordHasher',
@@ -64,8 +66,10 @@ def pytest_configure():
6466
'provider.oauth2',
6567
)
6668

69+
if django.VERSION >= (1, 5):
70+
settings.INSTALLED_APPS += ('tests',)
71+
6772
try:
68-
import django
6973
django.setup()
7074
except AttributeError:
7175
pass

tests/models.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
from django.contrib.auth.models import User
1+
from django.db import models
2+
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
23

34

4-
class CustomUser(User):
5+
class CustomUser(AbstractBaseUser):
6+
email = models.EmailField(max_length=255, unique=True)
7+
8+
objects = BaseUserManager()
9+
510
USERNAME_FIELD = 'email'
11+
12+
class Meta:
13+
app_label = 'tests'

tests/settings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
'django.contrib.sites',
9696
'django.contrib.messages',
9797
'django.contrib.staticfiles',
98-
'tests',
9998
)
10099

101100
# OAuth is optional and won't work if there is no oauth_provider & oauth2
@@ -134,5 +133,5 @@
134133

135134
import django
136135

137-
if django.VERSION < (1, 3):
138-
INSTALLED_APPS += ('staticfiles',)
136+
if django.VERSION >= (1, 5):
137+
INSTALLED_APPS += ('tests',)

tests/test_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from rest_framework_jwt import utils
1616
from rest_framework_jwt.settings import api_settings, DEFAULTS
1717

18-
from .models import CustomUser
19-
2018

2119
NO_CUSTOM_USER_MODEL = 'Custom User Model only supported after Django 1.5'
2220

@@ -123,6 +121,8 @@ class CustomUserObtainJSONWebTokenTests(TestCase):
123121
urls = 'tests.test_views'
124122

125123
def setUp(self):
124+
from .models import CustomUser
125+
126126
self.email = '[email protected]'
127127
self.password = 'password'
128128
user = CustomUser.objects.create(email=self.email)

tox.ini

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tox]
22
downloadcache = {toxworkdir}/cache/
33
envlist =
4+
py3.4-django1.7,py3.3-django1.7,py3.2-django1.7,py2.7-django1.7,
45
py3.4-django1.6,py3.3-django1.6,py3.2-django1.6,py2.7-django1.6,py2.6-django1.6,
56
py3.4-django1.5,py3.3-django1.5,py3.2-django1.5,py2.7-django1.5,py2.6-django1.5,
67
py2.7-django1.4,py2.6-django1.4
@@ -14,6 +15,34 @@ deps = pytest==2.5.2
1415
flake8==2.2.2
1516
commands = ./runtests.py --lintonly
1617

18+
[testenv:py3.4-django1.7]
19+
basepython = python3.4
20+
deps = Django==1.7
21+
djangorestframework>=2.3.11
22+
PyJWT>=0.1.8
23+
pytest-django==2.6.1
24+
25+
[testenv:py3.3-django1.7]
26+
basepython = python3.3
27+
deps = Django==1.7
28+
djangorestframework>=2.3.11
29+
PyJWT>=0.1.8
30+
pytest-django==2.6.1
31+
32+
[testenv:py3.2-django1.7]
33+
basepython = python3.2
34+
deps = Django==1.7
35+
djangorestframework>=2.3.11
36+
PyJWT>=0.1.8
37+
pytest-django==2.6.1
38+
39+
[testenv:py2.7-django1.7]
40+
basepython = python2.7
41+
deps = Django==1.7
42+
djangorestframework>=2.3.11
43+
PyJWT>=0.1.8
44+
pytest-django==2.6.1
45+
1746
[testenv:py3.4-django1.6]
1847
basepython = python3.4
1948
deps = Django==1.6.3

0 commit comments

Comments
 (0)