diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index d0add530268..113f44e6c90 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -163,7 +163,9 @@ def getfuncargnames(function, is_method=False, cls=None): # it's passed as an unbound method or function, remove the first # parameter name. if is_method or ( - cls and not isinstance(cls.__dict__.get(function.__name__, None), staticmethod) + cls + and (not hasattr(function, "__self__") or not function.__self__) + and not isinstance(cls.__dict__.get(function.__name__, None), staticmethod) ): arg_names = arg_names[1:] # Remove any names that will be replaced with mocks.