summaryrefslogtreecommitdiff
path: root/src/zope/interface
diff options
context:
space:
mode:
authorAlbertas Agejevas <alga@pov.lt>2013-02-28 18:44:21 +0200
committerAlbertas Agejevas <alga@pov.lt>2013-02-28 18:49:13 +0200
commitbd634caeefe21618b686ea2ddd3070622f4a39a2 (patch)
treea3ded4b886171ba0cd0f9e83d6c8f3e535b25c36 /src/zope/interface
parent019a065a5f9b4e95d1280b19e7f97e97f37d7e21 (diff)
downloadzope-interface-bd634caeefe21618b686ea2ddd3070622f4a39a2.tar.gz
Fixed a verifyClass false positive with a decorated method.
This bug was a reason (?) for a gratuitous fork of the _verify function in z3c.testing.verify.
Diffstat (limited to 'src/zope/interface')
-rw-r--r--src/zope/interface/tests/test_verify.py23
-rw-r--r--src/zope/interface/verify.py4
2 files changed, 27 insertions, 0 deletions
diff --git a/src/zope/interface/tests/test_verify.py b/src/zope/interface/tests/test_verify.py
index 83b3ada..d9c18d2 100644
--- a/src/zope/interface/tests/test_verify.py
+++ b/src/zope/interface/tests/test_verify.py
@@ -491,6 +491,29 @@ class Test_verifyClass(unittest.TestCase):
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):
diff --git a/src/zope/interface/verify.py b/src/zope/interface/verify.py
index 488bd88..af80116 100644
--- a/src/zope/interface/verify.py
+++ b/src/zope/interface/verify.py
@@ -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")