|
@@ -5,7 +5,9 @@ import warnings
|
|
|
from django.test import SimpleTestCase
|
|
|
from django.test.utils import reset_warning_registry
|
|
|
from django.utils import six
|
|
|
-from django.utils.deprecation import RenameMethodsBase
|
|
|
+from django.utils.deprecation import (
|
|
|
+ DeprecationInstanceCheck, RemovedInNextVersionWarning, RenameMethodsBase,
|
|
|
+)
|
|
|
|
|
|
|
|
|
class RenameManagerMethods(RenameMethodsBase):
|
|
@@ -170,3 +172,16 @@ class RenameMethodsTests(SimpleTestCase):
|
|
|
'`DeprecatedMixin.old` is deprecated, use `new` instead.',
|
|
|
'`RenamedMixin.old` is deprecated, use `new` instead.',
|
|
|
])
|
|
|
+
|
|
|
+
|
|
|
+class DeprecationInstanceCheckTest(SimpleTestCase):
|
|
|
+ def test_warning(self):
|
|
|
+ class Manager(six.with_metaclass(DeprecationInstanceCheck)):
|
|
|
+ alternative = 'fake.path.Foo'
|
|
|
+ deprecation_warning = RemovedInNextVersionWarning
|
|
|
+
|
|
|
+ msg = '`Manager` is deprecated, use `fake.path.Foo` instead.'
|
|
|
+ with warnings.catch_warnings():
|
|
|
+ warnings.simplefilter('error', category=RemovedInNextVersionWarning)
|
|
|
+ with self.assertRaisesMessage(RemovedInNextVersionWarning, msg):
|
|
|
+ isinstance(object, Manager)
|