45
45
implements_test(src)
47
def test_implementer():
51
class IFoo(zope.interface.Interface):
53
class IBar(zope.interface.Interface):
56
@zope.interface.implementer(IFoo)
59
@zope.interface.implementer(IBar)
63
zope.interface.implementsOnly(IBar)
48
67
def implements_test(src):
49
68
mod = fromText(src, 'zi', systemcls=ZopeInterfaceSystem)
82
mod = fromText(src, 'zi', systemcls=ZopeInterfaceSystem)
101
fromText(src, 'zi', systemcls=ZopeInterfaceSystem)
84
103
def test_multiply_inheriting_interfaces():
104
123
assert len(mod.contents['C'].contents) == 1
106
125
def test_interfaceclass():
108
import zope.interface as zi
109
class MyInterfaceClass(zi.interface.InterfaceClass):
111
MyInterface = MyInterfaceClass("MyInterface")
112
class AnInterface(MyInterface):
115
126
system = processPackage('interfaceclass', systemcls=ZopeInterfaceSystem)
116
127
mod = system.allobjects['interfaceclass.mod']
117
128
assert mod.contents['AnInterface'].isinterface
131
142
from zope import schema, interface
132
143
class IMyInterface(interface.Interface):
133
text = zope.schema.TextLine(description="fun in a bun")
144
text = schema.TextLine(description="fun in a bun")
135
146
mod = fromText(src, systemcls=ZopeInterfaceSystem)
136
147
text = mod.contents['IMyInterface'].contents['text']
142
153
from zope import schema, interface
143
154
class IMyInterface(interface.Interface):
144
attribute = zope.interface.Attribute(_("fun in a bun"))
145
text = zope.schema.TextLine(description=_("fun in a bap"))
155
attribute = interface.Attribute(_("fun in a bun"))
156
text = schema.TextLine(description=_("fun in a bap"))
147
158
mod = fromText(src, systemcls=ZopeInterfaceSystem)
148
159
text = mod.contents['IMyInterface'].contents['attribute']
158
169
from zope import schema, interface
159
170
from zope.schema import Int as INTEGERSCHMEMAFIELD
160
class MyTextLine(zope.schema.TextLine):
171
class MyTextLine(schema.TextLine):
162
173
class MyOtherTextLine(MyTextLine):
175
186
assert myothertext.kind == "MyOtherTextLine"
176
187
myint = mod.contents['IMyInterface'].contents['myint']
177
188
assert myint.kind == "Int"
190
def test_docsources_includes_interface():
192
from zope import interface
193
class IInterface(interface.Interface):
196
class Implementation:
197
interface.implements(IInterface)
201
mod = fromText(src, systemcls=ZopeInterfaceSystem)
202
imethod = mod.contents['IInterface'].contents['method']
203
method = mod.contents['Implementation'].contents['method']
204
assert imethod in method.docsources(), list(method.docsources())
206
def test_docsources_includes_baseinterface():
208
from zope import interface
209
class IBase(interface.Interface):
212
class IExtended(IBase):
214
class Implementation:
215
interface.implements(IExtended)
219
mod = fromText(src, systemcls=ZopeInterfaceSystem)
220
imethod = mod.contents['IBase'].contents['method']
221
method = mod.contents['Implementation'].contents['method']
222
assert imethod in method.docsources(), list(method.docsources())
224
def test_docsources_from_moduleprovides():
226
from zope import interface
228
class IBase(interface.Interface):
232
interface.moduleProvides(IBase)
237
mod = fromText(src, systemcls=ZopeInterfaceSystem)
238
imethod = mod.contents['IBase'].contents['bar']
239
function = mod.contents['bar']
240
assert imethod in function.docsources(), list(function.docsources())