Unit tests: Avoid deprecation warning for getargspec()
inspect.getargspec() is deprecated in Python 3, but there is no equivalent of inspect.signature() in Python 2. Change-Id: I4793ac625c1b87e783718bfabe661ccc2ad5dcfd
This commit is contained in:
parent
e3cb8e05ad
commit
6447520273
|
@ -14,6 +14,7 @@
|
|||
import collections
|
||||
import functools
|
||||
import inspect
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_messaging import rpc
|
||||
|
@ -29,7 +30,12 @@ def asynchronous(function):
|
|||
run on a future iteration of the event loop.
|
||||
"""
|
||||
|
||||
arg_names = inspect.getargspec(function).args
|
||||
if six.PY2:
|
||||
arg_names = inspect.getargspec(function).args
|
||||
else:
|
||||
sig = inspect.signature(function)
|
||||
arg_names = [name for name, param in sig.parameters.items()
|
||||
if param.kind == param.POSITIONAL_OR_KEYWORD]
|
||||
MessageData = collections.namedtuple(function.__name__, arg_names[1:])
|
||||
|
||||
@functools.wraps(function)
|
||||
|
|
Loading…
Reference in New Issue