From e00ae03370d606368133da5c9eb196ae4ff1bd10 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 15 Jul 2021 20:44:12 +0900 Subject: [PATCH] Switch get(full)argspec function according to python version inspect.getargspec was deprecated since Python 3.0 and inspect.getfullargspec is its replacement with correct handling of function annotations and keyword-only parameters[1]. This change ensures that inspect.getfullargspec is used in Python 3. [1] https://docs.python.org/3/library/inspect.html#inspect.getargspec Change-Id: I63a4fda4f5da00c0f752e58f2e7192baea5012bb --- test/unit/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/unit/__init__.py b/test/unit/__init__.py index 1b005cbaa7..d726cbf1c3 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -933,9 +933,15 @@ def fake_http_connect(*code_iter, **kwargs): if 'give_connect' in kwargs: give_conn_fn = kwargs['give_connect'] - argspec = inspect.getargspec(give_conn_fn) - if argspec.keywords or 'connection_id' in argspec.args: - ckwargs['connection_id'] = i + + if six.PY2: + argspec = inspect.getargspec(give_conn_fn) + if argspec.keywords or 'connection_id' in argspec.args: + ckwargs['connection_id'] = i + else: + argspec = inspect.getfullargspec(give_conn_fn) + if argspec.varkw or 'connection_id' in argspec.args: + ckwargs['connection_id'] = i give_conn_fn(*args, **ckwargs) etag = next(etag_iter) headers = next(headers_iter)