summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-12-31 11:46:40 -0500
committerTim Graham <timograham@gmail.com>2017-01-17 20:52:03 -0500
commiteba093e8b02989af1857b1915907ca0897f565ff (patch)
tree9168860253e3956ced80b9e639e8e1c36211057c /tests
parentb70094f0408384993e149ffcfc86cc2d405308d1 (diff)
Refs #25847 -- Removed support for User.is_(anonymous|authenticated) as methods.
Per deprecation timeline.
Diffstat (limited to 'tests')
-rw-r--r--tests/auth_tests/test_basic.py42
-rw-r--r--tests/utils_tests/test_deprecation.py31
2 files changed, 0 insertions, 73 deletions
diff --git a/tests/auth_tests/test_basic.py b/tests/auth_tests/test_basic.py
index 2e18260e4c..4555e28270 100644
--- a/tests/auth_tests/test_basic.py
+++ b/tests/auth_tests/test_basic.py
@@ -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')
diff --git a/tests/utils_tests/test_deprecation.py b/tests/utils_tests/test_deprecation.py
deleted file mode 100644
index 56ba259a2f..0000000000
--- a/tests/utils_tests/test_deprecation.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from django.test import SimpleTestCase
-from django.utils.deprecation import CallableFalse, CallableTrue
-
-
-class TestCallableBool(SimpleTestCase):
- def test_true(self):
- self.assertTrue(CallableTrue)
- self.assertEqual(CallableTrue, True)
- self.assertFalse(CallableTrue != True) # noqa: E712
- self.assertNotEqual(CallableTrue, False)
-
- def test_false(self):
- self.assertFalse(CallableFalse)
- self.assertEqual(CallableFalse, False)
- self.assertFalse(CallableFalse != False) # noqa: E712
- self.assertNotEqual(CallableFalse, True)
-
- def test_or(self):
- self.assertIs(CallableTrue | CallableTrue, True)
- self.assertIs(CallableTrue | CallableFalse, True)
- self.assertIs(CallableFalse | CallableTrue, True)
- self.assertIs(CallableFalse | CallableFalse, False)
-
- self.assertIs(CallableTrue | True, True)
- self.assertIs(CallableTrue | False, True)
- self.assertIs(CallableFalse | True, True)
- self.assertFalse(CallableFalse | False, False)
-
- def test_set_membership(self):
- self.assertIs(CallableTrue in {True}, True)
- self.assertIs(CallableFalse not in {True}, True)