summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLaurent Peuch <cortex@worlddomination.be>2020-04-16 04:14:52 +0200
committerLaurent Peuch <cortex@worlddomination.be>2020-04-16 04:14:52 +0200
commitd26a1b969f632b5511bd72c82a36fbc92ecfdee5 (patch)
treeed74ad260dc3b8c12995ba0a86e31024f563f733 /test
parent8f56c90309db2353470a03650ee56cec5215ed44 (diff)
downloadlogilab-common-d26a1b969f632b5511bd72c82a36fbc92ecfdee5.tar.gz
add depreciation.argument_renamed
Diffstat (limited to 'test')
-rw-r--r--test/unittest_deprecation.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unittest_deprecation.py b/test/unittest_deprecation.py
index 7778325..7881252 100644
--- a/test/unittest_deprecation.py
+++ b/test/unittest_deprecation.py
@@ -93,6 +93,20 @@ class RawInputTC(TestCase):
self.assertFalse(hasattr(some_class, "new"))
self.assertFalse(hasattr(some_class, "old"))
+ def test_argument_renamed(self):
+ @deprecation.argument_renamed(old_name="old", new_name="new")
+ def some_function(new):
+ return new
+
+ self.assertEqual(some_function(new=42), 42)
+ self.assertEqual(some_function(old=42), 42)
+ self.assertEqual(self.messages,
+ ['argument old of callable some_function has been renamed and is '
+ 'deprecated, use keyword argument new instead'])
+
+ with self.assertRaises(ValueError):
+ some_function(new=42, old=42)
+
def test_renamed(self):
def any_func():
pass