Trees | Index | Help |
|
---|
Package zope ::
Package interface ::
Package tests ::
Module test_interface
|
|
Test Interface implementation
$Id: test_interface.py,v 1.2 2005/06/24 16:52:47 nyergler Exp $Classes | |
---|---|
_I1 |
|
_I1_ |
|
_I1__ |
|
_I2 |
|
InterfaceTests |
Function Summary | |
---|---|
main()
| |
Invaiants can be deined in line | |
test_suite()
|
Function Details |
---|
test_invariant_as_decorator()Invaiants can be deined in line>>> class IRange(interface.Interface):
... min = interface.Attribute("Lower bound")
... max = interface.Attribute("Upper bound")
...
... @interface.invariant
... def range_invariant(ob):
... if ob.max < ob.min:
... raise Invalid('max < min')
>>> class Range(object):
... interface.implements(IRange)
...
... def __init__(self, min, max):
... self.min, self.max = min, max
>>> IRange.validateInvariants(Range(1,2)) >>> IRange.validateInvariants(Range(1,1)) >>> IRange.validateInvariants(Range(2,1)) Traceback (most recent call last): ... Invalid: max < min |
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jun 24 12:01:20 2005 | http://epydoc.sf.net |