summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2020-02-06 10:59:25 -0600
committerJason Madden <jamadden@gmail.com>2020-02-07 10:59:11 -0600
commite8a4da9d5e48d036c2280be009f75b6416054a12 (patch)
tree1c5ca437b31fe40868f85c6358fb7c1fcb965537
parenta825e5f29e98c8c84076600323ffe791531ac765 (diff)
downloadzope-interface-e8a4da9d5e48d036c2280be009f75b6416054a12.tar.gz
Also document the not-a-method case.issue170
-rw-r--r--docs/verify.rst8
-rw-r--r--src/zope/interface/verify.py2
2 files changed, 9 insertions, 1 deletions
diff --git a/docs/verify.rst b/docs/verify.rst
index f400f23..364aedb 100644
--- a/docs/verify.rst
+++ b/docs/verify.rst
@@ -151,6 +151,14 @@ different type of exception, so we need an updated helper.
... except BrokenMethodImplementation as e:
... print(e)
+Not being callable is an error.
+
+.. doctest::
+
+ >>> Foo.simple = 42
+ >>> verify_foo()
+ The object <Foo...> violates its contract in IFoo.simple(arg1): implementation is not a method.
+
Taking too few arguments is an error.
.. doctest::
diff --git a/src/zope/interface/verify.py b/src/zope/interface/verify.py
index 77366be..40c0fb1 100644
--- a/src/zope/interface/verify.py
+++ b/src/zope/interface/verify.py
@@ -110,7 +110,7 @@ def _verify(iface, candidate, tentative=False, vtype=None):
continue
else:
if not callable(attr):
- raise BrokenMethodImplementation(name, "Not a method", candidate)
+ raise BrokenMethodImplementation(desc, "implementation is not a method", candidate)
# sigh, it's callable, but we don't know how to introspect it, so
# we have to give it a pass.
continue