From 6447520273a792707b0039da0ea6c0626af13ada Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Wed, 16 May 2018 13:01:27 -0400 Subject: [PATCH] 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 --- heat/tests/convergence/framework/message_processor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/heat/tests/convergence/framework/message_processor.py b/heat/tests/convergence/framework/message_processor.py index 3ac2a38100..99d0bf2813 100644 --- a/heat/tests/convergence/framework/message_processor.py +++ b/heat/tests/convergence/framework/message_processor.py @@ -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)