Remove use of deprecated APIs

inspect.getargspec is gone in Python 3.11.

unittest.TestCase.assertRaisesRegex is preferred to
unittest.TestCase.assertRaisesRegexp.

Change-Id: Ib6ec492e8c892424ab408a96696df346c3bbfde3
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-09-05 11:13:19 +01:00
parent 16eeb35127
commit 87c586051f
2 changed files with 9 additions and 8 deletions

View File

@ -177,13 +177,14 @@ class TestTypes(unittest.TestCase):
obj.a = 'v1' obj.a = 'v1'
assert obj.a == 'v1', repr(obj.a) assert obj.a == 'v1', repr(obj.a)
self.assertRaisesRegexp(exc.InvalidInput, self.assertRaisesRegex(
"Invalid input for field/attribute a. \ exc.InvalidInput,
Value: 'v3'. Value should be one of: v., v.", "Invalid input for field/attribute a. "
setattr, "Value: 'v3'. Value should be one of: v., v.",
obj, setattr,
'a', obj,
'v3') 'a',
'v3')
def test_attribute_validation(self): def test_attribute_validation(self):
class AType(object): class AType(object):

View File

@ -42,7 +42,7 @@ def signature(*args, **kw):
sig = wsme.signature(*args, **kw) sig = wsme.signature(*args, **kw)
def decorator(f): def decorator(f):
args = inspect.getargspec(f)[0] args = inspect.getfullargspec(f)[0]
ismethod = args and args[0] == 'self' ismethod = args and args[0] == 'self'
sig(f) sig(f)
funcdef = wsme.api.FunctionDefinition.get(f) funcdef = wsme.api.FunctionDefinition.get(f)