[py-svn] py-trunk commit 04b17770932e: patch from flub to allow callable objects as hook implementations
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 7 10:06:36 CEST 2010
# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User holger krekel <holger at merlinux.eu>
# Date 1283846591 -7200
# Node ID 04b17770932e208406d8bf0d4ba890c6a61da614
# Parent d30992862e8c305d7b4545a69917fab32e82f1e7
patch from flub to allow callable objects as hook implementations
--- 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:
--- 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):
More information about the pytest-commit
mailing list