From 61dc821d752f79eaa421e50e1782bcf8f47a24ea Mon Sep 17 00:00:00 2001 From: SeanXu1984 Date: Fri, 21 Feb 2020 10:35:09 +0800 Subject: [PATCH 1/4] Fix so the self of an instancemethod will not be removed again in getfuncargnames because it is already removed from signature(function) --- src/_pytest/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index d0add530268..66afb5640b3 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -163,7 +163,7 @@ 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 isinstance(cls.__dict__.get(function.__name__, None), staticmethod) and not function.__self__ ): arg_names = arg_names[1:] # Remove any names that will be replaced with mocks. From 346003686170ea9129cabfa088940f355cfbb15d Mon Sep 17 00:00:00 2001 From: SeanXu1984 Date: Fri, 21 Feb 2020 11:02:18 +0800 Subject: [PATCH 2/4] Fix so the self of an instancemethod will not be removed again in getfuncargnames because it is already removed from signature(function) --- src/_pytest/compat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 66afb5640b3..78ecd3be836 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) and not function.__self__ + cls + and not isinstance(cls.__dict__.get(function.__name__, None), staticmethod) + and not function.__self__ ): arg_names = arg_names[1:] # Remove any names that will be replaced with mocks. From 57aa4cf7802e4bae0d0c24ed0531983b08d33aae Mon Sep 17 00:00:00 2001 From: SeanXu1984 Date: Fri, 21 Feb 2020 14:31:50 +0800 Subject: [PATCH 3/4] Fix so the self of an instancemethod will not be removed again in getfuncargnames because it is already removed from signature(function) --- src/_pytest/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 78ecd3be836..3d1d1c2ec87 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -165,7 +165,7 @@ def getfuncargnames(function, is_method=False, cls=None): if is_method or ( cls and not isinstance(cls.__dict__.get(function.__name__, None), staticmethod) - and not function.__self__ + and (not hasattr(function, "__self__") or not function.__self__) ): arg_names = arg_names[1:] # Remove any names that will be replaced with mocks. From 19333f5aa52205571be6b1aecf66f49ae07f1468 Mon Sep 17 00:00:00 2001 From: SeanXu1984 Date: Wed, 26 Feb 2020 13:18:20 +0800 Subject: [PATCH 4/4] Fix so the self of an instancemethod will not be removed again in getfuncargnames because it is already removed from signature(function) --- src/_pytest/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 3d1d1c2ec87..113f44e6c90 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -164,8 +164,8 @@ def getfuncargnames(function, is_method=False, cls=None): # parameter name. if is_method or ( cls - and not isinstance(cls.__dict__.get(function.__name__, None), staticmethod) 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.