[Zope3-dev] Re: testing interfaces / Cookbook
Philipp von Weitershausen
philipp at weitershausen.de
Mon Apr 19 05:14:19 EDT 2004
Yuppie,
> The Cookbook uses this example
>
> def test_interface(self):
> self.assert_(IMessageBoard.isImplementedBy(
> self.makeTestObject()))
>
> Does it make sense to use providedBy (fka isImplementedBy) in unittests?
isImplementedBy is deprecated. providedBy should be used when checking
whether an object *provides* an interface. implementedBy should be used
when checking whether a class *implements* an interface.
> Wouldn't it be better to verify the interface?
I guess so, though I feel that makes interfaces quite a serious
contract. Oh well, I guess they *are* a contract, and checking that in
unit tests couldn't hurt.
However, sometimes you're just interested whether the object you get
from some machinery implements an interface, i.e. promises a contract.
That often is enough.
Philipp
More information about the Zope3-dev
mailing list