Also document the not-a-method case.

This commit is contained in:
Jason Madden 2020-02-06 10:59:25 -06:00
parent a825e5f29e
commit e8a4da9d5e
No known key found for this signature in database
GPG Key ID: 349F84431A08B99E
2 changed files with 9 additions and 1 deletions

View File

@ -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::

View File

@ -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