Skip to content

Commit

Permalink
Fixed a verifyClass false positive with a decorated method.
Browse files Browse the repository at this point in the history
This bug was a reason (?) for a gratuitous fork of the _verify
function in z3c.testing.verify.
  • Loading branch information
alga committed Feb 28, 2013
1 parent 019a065 commit bd634ca
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/zope/interface/tests/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,29 @@ class Current:

self._callFUT(ICurrent, Current)


def test_w_decorated_method(self):
from zope.interface import Interface
from zope.interface import implementer

def decorator(func):
# this is, in fact, zope.proxy.non_overridable
return property(lambda self: func.__get__(self))

class ICurrent(Interface):

def method(a):
pass

@implementer(ICurrent)
class Current(object):

@decorator
def method(self, a):
pass

self._callFUT(ICurrent, Current)

class Test_verifyObject(Test_verifyClass):

def _callFUT(self, iface, target):
Expand Down
4 changes: 4 additions & 0 deletions src/zope/interface/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def _verify(iface, candidate, tentative=0, vtype=None):
elif (isinstance(attr, MethodTypes)
and type(attr.__func__) is FunctionType):
meth = fromMethod(attr, iface, name)
elif isinstance(attr, property) and vtype == 'c':
# We without an instance we cannot be sure it's not a
# callable.
continue
else:
if not callable(attr):
raise BrokenMethodImplementation(name, "Not a method")
Expand Down

0 comments on commit bd634ca

Please sign in to comment.