Add tests for wraps

During testing I also discovered that `_ignores_kwargs` was also missing
the @wraps decorator. Now it has it.
This commit is contained in:
Wayne Werner 2019-04-18 11:06:49 -04:00 committed by Pedro Algarvio
parent 1670b5d647
commit 0670614c6a
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF
2 changed files with 37 additions and 0 deletions

View file

@ -643,6 +643,7 @@ def ignores_kwargs(*kwarg_names):
List of argument names to ignore
'''
def _ignores_kwargs(fn):
@wraps(fn)
def __ignores_kwargs(*args, **kwargs):
kwargs_filtered = kwargs.copy()
for name in kwarg_names:

View file

@ -352,3 +352,39 @@ class DecoratorsTest(TestCase):
depr._curr_version = self._mk_version("Helium")[1]
with self.assertRaises(SaltConfigurationError):
assert depr(self.new_function)() == self.new_function()
def test_with_depreciated_should_wrap_function(self):
def func(): pass
wrapped = decorators.with_deprecated({}, "Beryllium")(func)
assert wrapped.__module__ == func.__module__
def test_is_deprecated_should_wrap_function(self):
def func(): pass
wrapped = decorators.is_deprecated({}, "Beryllium")(func)
assert wrapped.__module__ == func.__module__
def test_ensure_unicode_args_should_wrap_function(self):
def func(): pass
wrapped = decorators.ensure_unicode_args(func)
assert wrapped.__module__ == func.__module__
def test_ignores_kwargs_should_wrap_function(self):
def func(): pass
wrapped = decorators.ignores_kwargs('foo', 'bar')(func)
assert wrapped.__module__ == func.__module__
def test_memoize_should_wrap_function(self):
def func(): pass
wrapped = decorators.memoize(func)
assert wrapped.__module__ == func.__module__
def timing_should_wrap_function(self):
def func(): pass
wrapped = decorators.timing(func)
assert wrapped.__module__ == func.__module__