Skip to content

Commit

Permalink
add getfullargspec() for python3 (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
wallacbe authored and Kenadia committed Jan 17, 2018
1 parent e1f9c1e commit 655151d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions openhtf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,16 @@ def __call__(self, test_state):
kwargs = dict(self.extra_kwargs)
kwargs.update(test_state.plug_manager.provide_plugs(
(plug.name, plug.cls) for plug in self.plugs if plug.update_kwargs))
arg_info = inspect.getargspec(self.func)

if sys.version_info[0] < 3:
arg_info = inspect.getargspec(self.func)
keywords = arg_info.keywords
else:
arg_info = inspect.getfullargspec(self.func)
keywords = arg_info.varkw
# Pass in test_api if the phase takes *args, or **kwargs with at least 1
# positional, or more positional args than we have keyword args.
if arg_info.varargs or (arg_info.keywords and len(arg_info.args) >= 1) or (
if arg_info.varargs or (keywords and len(arg_info.args) >= 1) or (
len(arg_info.args) > len(kwargs)):
# Underlying function has room for test_api as an arg. If it doesn't
# expect it but we miscounted args, we'll get another error farther down.
Expand Down

0 comments on commit 655151d

Please sign in to comment.