Commit 3a6a2eb9 authored by Bruno Renié's avatar Bruno Renié
Browse files

Fix tests on all py/django combinations

parent d033a52b
......@@ -15,3 +15,16 @@ INSTALLED_APPS = (
'auth': 'django.contrib.auth.tests.migrations',
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'loaders': (
......@@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import timezone
from django.utils.six import with_metaclass
from django.utils.unittest import SkipTest
from ..forms import PasswordRecoveryForm, PasswordResetForm
......@@ -23,7 +24,7 @@ class CustomUserVariants(type):
if django.VERSION >= (1, 5):
for custom_user in ['auth.CustomUser', 'auth.ExtensionUser']:
suffix = custom_user.lower().replace('.', '_')
for key, fn in dct.items():
for key, fn in list(dct.items()):
if key.startswith('test') and '_CUSTOM_' not in key:
name = '{0}_CUSTOM_{1}'.format(key, suffix)
dct[name] = override_settings(
......@@ -45,9 +46,7 @@ def create_user():
return get_user_model()._default_manager.create_user(*args, **kwargs)
class FormTests(TestCase):
__metaclass__ = CustomUserVariants
class FormTests(with_metaclass(CustomUserVariants, TestCase)):
def test_username_input(self):
User = get_user_model()
if User is CustomUser:
......@@ -208,9 +207,7 @@ class FormTests(TestCase):
class ViewTests(TestCase):
__metaclass__ = CustomUserVariants
class ViewTests(with_metaclass(CustomUserVariants, TestCase)):
def test_recover(self):
self.user = create_user()
url = reverse('password_reset_recover')
from django.conf.urls import url, patterns
from django.conf.urls import url
from ..urls import urlpatterns
from . import views
urlpatterns += patterns(
urlpatterns += [
url(r'^email_recover/$', views.email_recover, name='email_recover'),
url(r'^username_recover/$', views.username_recover,
url(r'^insensitive_recover/$', views.insensitive_recover,
import datetime
from django.conf import settings
from django.contrib.sites.models import Site, RequestSite
from django.contrib.sites.models import Site
from django.core import signing
from django.core.mail import send_mail
from django.core.urlresolvers import reverse, reverse_lazy
......@@ -11,6 +11,11 @@ from django.template import loader
from django.utils import timezone
from django.views import generic
from django.contrib.sites.requests import RequestSite
except ImportError:
from django.contrib.sites.models import RequestSite
from .forms import PasswordRecoveryForm, PasswordResetForm
from .utils import get_user_model, get_username
from .signals import user_recovers_password
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment