|
@@ -1,8 +1,6 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
-import warnings
|
|
|
-
|
|
|
from django.contrib.auth import get_user, get_user_model
|
|
|
from django.contrib.auth.models import AnonymousUser, User
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
@@ -56,26 +54,6 @@ class BasicTestCase(TestCase):
|
|
|
with self.assertRaises(IntegrityError):
|
|
|
User.objects.create_user(omega_username)
|
|
|
|
|
|
- def test_is_anonymous_authenticated_method_deprecation(self):
|
|
|
- deprecation_message = (
|
|
|
- 'Using user.is_authenticated() and user.is_anonymous() as a '
|
|
|
- 'method is deprecated. Remove the parentheses to use it as an '
|
|
|
- 'attribute.'
|
|
|
- )
|
|
|
- u = User.objects.create_user('testuser', 'test@example.com', 'testpw')
|
|
|
- # Backwards-compatibility callables
|
|
|
- with warnings.catch_warnings(record=True) as warns:
|
|
|
- warnings.simplefilter('always')
|
|
|
- self.assertFalse(u.is_anonymous())
|
|
|
- self.assertEqual(len(warns), 1)
|
|
|
- self.assertEqual(str(warns[0].message), deprecation_message)
|
|
|
-
|
|
|
- with warnings.catch_warnings(record=True) as warns:
|
|
|
- warnings.simplefilter('always')
|
|
|
- self.assertTrue(u.is_authenticated())
|
|
|
- self.assertEqual(len(warns), 1)
|
|
|
- self.assertEqual(str(warns[0].message), deprecation_message)
|
|
|
-
|
|
|
def test_user_no_email(self):
|
|
|
"Users can be created without an email"
|
|
|
u = User.objects.create_user('testuser1')
|
|
@@ -101,26 +79,6 @@ class BasicTestCase(TestCase):
|
|
|
self.assertEqual(a.groups.all().count(), 0)
|
|
|
self.assertEqual(a.user_permissions.all().count(), 0)
|
|
|
|
|
|
- def test_anonymous_user_is_anonymous_authenticated_method_deprecation(self):
|
|
|
- a = AnonymousUser()
|
|
|
- deprecation_message = (
|
|
|
- 'Using user.is_authenticated() and user.is_anonymous() as a '
|
|
|
- 'method is deprecated. Remove the parentheses to use it as an '
|
|
|
- 'attribute.'
|
|
|
- )
|
|
|
- # Backwards-compatibility callables
|
|
|
- with warnings.catch_warnings(record=True) as warns:
|
|
|
- warnings.simplefilter('always') # prevent warnings from appearing as errors
|
|
|
- self.assertTrue(a.is_anonymous())
|
|
|
- self.assertEqual(len(warns), 1)
|
|
|
- self.assertEqual(str(warns[0].message), deprecation_message)
|
|
|
-
|
|
|
- with warnings.catch_warnings(record=True) as warns:
|
|
|
- warnings.simplefilter('always') # prevent warnings from appearing as errors
|
|
|
- self.assertFalse(a.is_authenticated())
|
|
|
- self.assertEqual(len(warns), 1)
|
|
|
- self.assertEqual(str(warns[0].message), deprecation_message)
|
|
|
-
|
|
|
def test_superuser(self):
|
|
|
"Check the creation and properties of a superuser"
|
|
|
super = User.objects.create_superuser('super', 'super@example.com', 'super')
|