diff --git a/rest_auth/runtests.py b/rest_auth/runtests.py index 3d7e413..380670e 100644 --- a/rest_auth/runtests.py +++ b/rest_auth/runtests.py @@ -1,4 +1,4 @@ -#This file mainly exists to allow python setup.py test to work. +# This file mainly exists to allow python setup.py test to work. import os import sys @@ -6,6 +6,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings' test_dir = os.path.dirname(__file__) sys.path.insert(0, test_dir) +import django from django.test.utils import get_runner from django.conf import settings @@ -13,6 +14,8 @@ from django.conf import settings def runtests(): TestRunner = get_runner(settings) test_runner = TestRunner(verbosity=1, interactive=True) + if hasattr(django, 'setup'): + django.setup() failures = test_runner.run_tests(['rest_auth']) sys.exit(bool(failures)) diff --git a/rest_auth/test_settings.py b/rest_auth/test_settings.py index 175f989..3d5e270 100644 --- a/rest_auth/test_settings.py +++ b/rest_auth/test_settings.py @@ -28,6 +28,14 @@ if django.VERSION[:2] >= (1, 3): else: DATABASE_ENGINE = 'sqlite3' +MIDDLEWARE_CLASSES = [ + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware' +] + INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', @@ -51,3 +59,7 @@ INSTALLED_APPS = [ SECRET_KEY = "38dh*skf8sjfhs287dh&^hd8&3hdg*j2&sd" ACCOUNT_ACTIVATION_DAYS = 1 SITE_ID = 1 + +MIGRATION_MODULES = { + 'authtoken': 'authtoken.migrations', +} diff --git a/rest_auth/tests.py b/rest_auth/tests.py index d2677d2..b0905cd 100644 --- a/rest_auth/tests.py +++ b/rest_auth/tests.py @@ -170,12 +170,12 @@ class APITestCase1(TestCase, BaseAPITestCase): from django.utils.encoding import force_bytes from django.contrib.auth.tokens import default_token_generator from django import VERSION - if VERSION[1] == 6: - from django.utils.http import urlsafe_base64_encode - result['uid'] = urlsafe_base64_encode(force_bytes(user.pk)) - elif VERSION[1] == 5: + if VERSION[1] == 5: from django.utils.http import int_to_base36 result['uid'] = int_to_base36(user.pk) + else: + from django.utils.http import urlsafe_base64_encode + result['uid'] = urlsafe_base64_encode(force_bytes(user.pk)) result['token'] = default_token_generator.make_token(user) return result