Merge "Handle deprecation of inspect.getargspec"
This commit is contained in:
commit
ffff95557d
@ -19,6 +19,11 @@ import inspect
|
||||
|
||||
import six
|
||||
|
||||
if hasattr(inspect, 'getfullargspec'):
|
||||
getargspec = inspect.getfullargspec
|
||||
else:
|
||||
getargspec = inspect.getargspec
|
||||
|
||||
|
||||
def _get_arg_count(method):
|
||||
"""Get the number of args for a method.
|
||||
@ -29,7 +34,7 @@ def _get_arg_count(method):
|
||||
if not method:
|
||||
return 0
|
||||
|
||||
arg_spec = inspect.getargspec(method)
|
||||
arg_spec = getargspec(method)
|
||||
return len(arg_spec[0])
|
||||
|
||||
|
||||
|
@ -22,6 +22,11 @@ import tooz.locking
|
||||
from cinder import coordination
|
||||
from cinder import test
|
||||
|
||||
if hasattr(inspect, 'getfullargspec'):
|
||||
getargspec = inspect.getfullargspec
|
||||
else:
|
||||
getargspec = inspect.getargspec
|
||||
|
||||
|
||||
class Locked(Exception):
|
||||
pass
|
||||
@ -106,4 +111,4 @@ class CoordinationTestCase(test.TestCase):
|
||||
bar.__getitem__.return_value = 8
|
||||
func(foo, bar)
|
||||
get_lock.assert_called_with('lock-func-7-8')
|
||||
self.assertEqual(['foo', 'bar'], inspect.getargspec(func)[0])
|
||||
self.assertEqual(['foo', 'bar'], getargspec(func)[0])
|
||||
|
@ -24,6 +24,11 @@ from cinder.volume.flows.api import manage_existing
|
||||
from cinder.volume.flows import common as flow_common
|
||||
from cinder.volume.flows.manager import manage_existing as manager
|
||||
|
||||
if hasattr(inspect, 'getfullargspec'):
|
||||
getargspec = inspect.getfullargspec
|
||||
else:
|
||||
getargspec = inspect.getargspec
|
||||
|
||||
|
||||
class ManageVolumeFlowTestCase(test.TestCase):
|
||||
|
||||
@ -151,10 +156,10 @@ class ManageVolumeFlowTestCase(test.TestCase):
|
||||
for p in task.default_provides:
|
||||
provides.add(p)
|
||||
|
||||
execute_args = inspect.getargspec(task.execute)[0]
|
||||
execute_args = getargspec(task.execute)[0]
|
||||
execute_args = [x for x in execute_args if x not in provides]
|
||||
[self.assertIn(arg, param_names) for arg in execute_args]
|
||||
|
||||
revert_args = inspect.getargspec(task.revert)[0]
|
||||
revert_args = getargspec(task.revert)[0]
|
||||
revert_args = [x for x in revert_args if x not in revert_provides]
|
||||
[self.assertIn(arg, param_names) for arg in revert_args]
|
||||
|
Loading…
x
Reference in New Issue
Block a user