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:
Zane Bitter 2018-05-16 13:01:27 -04:00
parent e3cb8e05ad
commit 6447520273
1 changed files with 7 additions and 1 deletions

View File

@ -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)