summaryrefslogtreecommitdiff
path: root/test/unittest_deprecation.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/unittest_deprecation.py')
-rw-r--r--test/unittest_deprecation.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/unittest_deprecation.py b/test/unittest_deprecation.py
index 172b9fb..07988c4 100644
--- a/test/unittest_deprecation.py
+++ b/test/unittest_deprecation.py
@@ -20,6 +20,7 @@
import warnings
from logilab.common.testlib import TestCase, unittest_main
+from logilab.common.modutils import LazyObject
from logilab.common import deprecation
@@ -109,6 +110,20 @@ class RawInputTC(TestCase):
self.assertEqual(self.messages,
['[logilab.common] The function "any_func" is deprecated', '[logilab.common] message'])
+ def test_deprecated_decorator_bad_lazyobject(self):
+ # this should not raised an ImportationError
+ deprecation.deprecated("foobar")(LazyObject("cubes.localperms", "xperm"))
+
+ # with or without giving it a message (because it shouldn't access
+ # attributes of the wrapped object before the object is called)
+ deprecation.deprecated()(LazyObject("cubes.localperms", "xperm"))
+
+ # all of this is done because of the magical way LazyObject is working
+ # and that sometime CW used to use it to do fake import on deprecated
+ # modules to raise a warning if they were used but not importing them
+ # by default.
+ # See: https://forge.extranet.logilab.fr/cubicweb/cubicweb/blob/3.24.0/cubicweb/schemas/__init__.py#L51 # noqa
+
def test_attribute_renamed(self):
@deprecation.attribute_renamed(old_name="old", new_name="new")
class SomeClass: