diff --git a/py/_test/pluginmanager.py b/py/_test/pluginmanager.py index e6a0895ce..629498e26 100644 --- a/py/_test/pluginmanager.py +++ b/py/_test/pluginmanager.py @@ -259,6 +259,8 @@ class MultiCall: return kwargs def varnames(func): + if not inspect.isfunction(func) and not inspect.ismethod(func): + func = getattr(func, '__call__', func) ismethod = inspect.ismethod(func) rawcode = py.code.getrawcode(func) try: diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index ee919d95c..8b705d7b3 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -340,8 +340,12 @@ def test_varnames(): class A: def f(self, y): pass + class B(object): + def __call__(self, z): + pass assert varnames(f) == ("x",) assert varnames(A().f) == ('y',) + assert varnames(B()) == ('z',) class TestMultiCall: def test_uses_copy_of_methods(self):