[Checkins] SVN: zope.generic/trunk/src/zope/generic/ rewrite
placelesssetups using zope.app.setup.setUpTestAsModule
Dominik Huber
dominik.huber at perse.ch
Sun Apr 9 23:58:31 EDT 2006
Log message for revision 66757:
rewrite placelesssetups using zope.app.setup.setUpTestAsModule
Changed:
U zope.generic/trunk/src/zope/generic/configuration/README.txt
U zope.generic/trunk/src/zope/generic/configuration/testing.py
U zope.generic/trunk/src/zope/generic/directlyprovides/README.txt
U zope.generic/trunk/src/zope/generic/directlyprovides/testing.py
U zope.generic/trunk/src/zope/generic/directlyprovides/tests.py
U zope.generic/trunk/src/zope/generic/information/NEW_README.txt
U zope.generic/trunk/src/zope/generic/information/README.txt
U zope.generic/trunk/src/zope/generic/information/testing.py
U zope.generic/trunk/src/zope/generic/information/tests.py
U zope.generic/trunk/src/zope/generic/testing/testing.py
U zope.generic/trunk/src/zope/generic/type/README.txt
U zope.generic/trunk/src/zope/generic/type/testing.py
-=-
Modified: zope.generic/trunk/src/zope/generic/configuration/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/README.txt 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/configuration/README.txt 2006-04-10 03:58:30 UTC (rev 66757)
@@ -10,12 +10,9 @@
>>> class IMyConfiguration(interface.Interface):
... my = TextLine(title=u'My')
- # make available within the testing module
- >>> testing.IMyConfiguration = IMyConfiguration
-
>>> registerDirective('''
... <generic:configuration
- ... interface="zope.generic.configuration.testing.IMyConfiguration"
+ ... interface="example.IMyConfiguration"
... label='My' hint='My bla.'
... />
... ''')
@@ -62,9 +59,6 @@
Regularly Configurations are provided by objects marked with
IAttributeConfigurations automatically:
-
- >>> from zope.generic.configuration.testing import placelesssetup
- >>> placelesssetup.setUp()
>>> from zope.interface import implements
>>> from zope.generic.configuration import IAttributeConfigurable
@@ -100,11 +94,6 @@
... foo = TextLine(title=u'Foo')
... optional = TextLine(title=u'Optional', required=False, default=u'Bla')
- # make available within the module
- >>> from zope.generic.configuration import adapter
- >>> adapter.IFooConfiguration = IFooConfiguration
- >>> IFooConfiguration.__module__ = 'zope.generic.configuration.adapter'
-
The configuration interface-key is a regular schema, but it has to be typed
by IConfigurationType (Regularly typed by the configuration directive):
@@ -120,12 +109,12 @@
>>> configurations[IFooConfiguration]
Traceback (most recent call last):
...
- KeyError: <InterfaceClass zope.generic.configuration.adapter.IFooConfiguration>
+ KeyError: <InterfaceClass example.IFooConfiguration>
>>> del configurations[IFooConfiguration]
Traceback (most recent call last):
...
- KeyError: <InterfaceClass zope.generic.configuration.adapter.IFooConfiguration>
+ KeyError: <InterfaceClass example.IFooConfiguration>
>>> configurations.keys()
[]
@@ -153,7 +142,7 @@
>>> configurations.update(IFooConfiguration, {'foo': u'Foo!'})
Traceback (most recent call last):
...
- KeyError: <InterfaceClass zope.generic.configuration.adapter.IFooConfiguration>
+ KeyError: <InterfaceClass example.IFooConfiguration>
You can create valid configuration data using the generic ConfigurationData
implementation:
@@ -250,15 +239,11 @@
>>> def myConfigurationHandler(event, component, configurations=None, annotations=None):
... print event, component, configurations, annotations
- # make available within the testing module
- >>> testing.IMyConfigurationHandler = IMyConfigurationHandler
- >>> testing.myConfigurationHandler = myConfigurationHandler
-
>>> registerDirective('''
... <generic:configurationHandler
- ... interface='zope.generic.configuration.testing.IMyConfigurationHandler'
+ ... interface='example.IMyConfigurationHandler'
... label='My Configuration Handler' hint='Please use it'
- ... handler='zope.generic.configuration.testing.myConfigurationHandler'
+ ... handler='example.myConfigurationHandler'
... />
... ''')
Modified: zope.generic/trunk/src/zope/generic/configuration/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/testing.py 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/configuration/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
@@ -18,15 +18,15 @@
__docformat__ = 'restructuredtext'
-from zope.app.testing import setup
from zope.component import provideAdapter
from zope.configuration.xmlconfig import XMLConfig
from zope.interface import Interface
from zope.schema import TextLine
-from zope.generic.configuration import IConfigurations
-
+import zope.app.testing.placelesssetup
+import zope.generic.directlyprovides.testing
import zope.generic.information.testing
+import zope.generic.testing.testing
################################################################################
@@ -65,34 +65,41 @@
#
################################################################################
+# specific tests
+def setUp(doctest=None):
+ # register attribute configurations adapter
+ import zope.generic.configuration.adapter
+ from zope.generic.configuration import IConfigurations
+ provideAdapter(zope.generic.configuration.adapter.AttributeConfigurations,
+ provides=IConfigurations)
-class PlacelessSetup(zope.generic.information.testing.PlacelessSetup):
+ # register the directive of this package
+ import zope.generic.configuration
+ XMLConfig('meta.zcml', zope.generic.configuration)()
- def setUp(self, doctesttest=None):
- super(PlacelessSetup, self).setUp(doctesttest)
+def tearDown(doctest=None):
+ pass
- # register attribute configurations adapter
- import zope.generic.configuration.adapter
- provideAdapter(zope.generic.configuration.adapter.AttributeConfigurations,
- provides=IConfigurations)
- # register the directive of this package
- import zope.generic.configuration
- XMLConfig('meta.zcml', zope.generic.configuration)()
- def tearDown(self, doctesttest=None):
- super(PlacelessSetup, self).tearDown(doctesttest)
+class PlacelessSetup(zope.app.testing.placelesssetup.PlacelessSetup):
+ def setUp(self, doctest=None):
+ super(PlacelessSetup, self).setUp(doctest)
+ # external setup
+ zope.generic.testing.testing.setUp(doctest)
+ zope.generic.directlyprovides.testing.setUp(doctest)
+ zope.generic.information.testing.setUp(doctest)
+ # internal setup
+ setUp(doctest)
+ def tearDown(self, doctest=None):
+ super(PlacelessSetup, self).tearDown()
+ # external teardown
+ zope.generic.testing.testing.tearDown(doctest)
+ zope.generic.directlyprovides.testing.tearDown(doctest)
+ zope.generic.information.testing.tearDown(doctest)
+ # internal teardown
+ tearDown(doctest)
placelesssetup = PlacelessSetup()
-
-
-
-class PlacelessSetup2(PlacelessSetup):
-
- def setUp(self, doctesttest=None):
- super(PlacelessSetup2, self).setUp(doctesttest)
- setup.setUpTestAsModule(doctesttest, 'zope.generic.example')
-
-placelesssetup2 = PlacelessSetup2()
Modified: zope.generic/trunk/src/zope/generic/directlyprovides/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/directlyprovides/README.txt 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/directlyprovides/README.txt 2006-04-10 03:58:30 UTC (rev 66757)
@@ -82,18 +82,18 @@
>>> a = A()
>>> IResult(a)
- <ResultForA object at ...>
+ <example.ResultForA object at ...>
If we directly provides an interface, for example IB, the
corresponding adapter `ResultForB` will be looked up:
>>> interface.directlyProvides(a, IB)
>>> IResult(a)
- <ResultForB object at ...>
+ <example.ResultForB object at ...>
>>> interface.alsoProvides(a, IC)
>>> IResult(a)
- <ResultForB object at ...>
+ <example.ResultForB object at ...>
Given the fact that different orthagonal application such as the site
framework uses the directly provided mechanism it is not possible
@@ -104,11 +104,11 @@
>>> interface.directlyProvides(a, IC)
>>> IResult(a)
- <ResultForC object at ...>
+ <example.ResultForC object at ...>
>>> interface.alsoProvides(a, IB)
>>> IResult(a)
- <ResultForC object at ...>
+ <example.ResultForC object at ...>
As long as different directly provided interfaces do not overlap
features this unordered aspect is not relevant.
@@ -171,8 +171,8 @@
... print 'directlyProvided changed', str(tuple([iface.__name__
... for iface in interface.directlyProvidedBy(event.object)]))
- >>> ztapi.subscribe((api.IProvides, api.IDirectlyProvidesModifiedEvent), None,
- ... notifyDirectlyProvidesModifiedEvent)
+ >>> component.provideHandler(notifyDirectlyProvidesModifiedEvent,
+ ... (api.IProvides, api.IDirectlyProvidesModifiedEvent))
>>> from zope.app.event.interfaces import IObjectModifiedEvent
@@ -184,13 +184,12 @@
... print 'Object modified (single subscriber), ',
... description = first.descriptions[0]
... print description.interface.__name__, description.attributes
-
- >>> ztapi.subscribe((IObjectModifiedEvent,), None,
- ... notifyObjectModifiedEvent)
+ >>> component.provideHandler(notifyObjectModifiedEvent,
+ ... (IObjectModifiedEvent,))
- >>> ztapi.subscribe((IPrepender, IObjectModifiedEvent,), None,
- ... notifyObjectModifiedEvent)
+ >>> component.provideHandler(notifyObjectModifiedEvent,
+ ... (IPrepender, IObjectModifiedEvent))
Now we are implementing an example class using the before- and after-hook.
For documentation purposes we use for the `first` attribute the decorator and
@@ -235,7 +234,7 @@
>>> [iface.__name__ for iface in interface.directlyProvidedBy(p)]
['IB']
>>> IResult(p)
- <ResultForB object at ...>
+ <example.ResultForB object at ...>
Another assignment is appended:
@@ -246,7 +245,7 @@
['IB', 'IA']
>>> IResult(p)
- <ResultForB object at ...>
+ <example.ResultForB object at ...>
But if we use our prepend mechanism the interface is prepended:
@@ -259,7 +258,7 @@
['ID', 'IB', 'IA']
>>> IResult(p)
- <ResultForD object at ...>
+ <example.ResultForD object at ...>
>>> p.first = (IC, )
before
@@ -270,7 +269,7 @@
['IC', 'ID', 'IB', 'IA']
>>> IResult(p)
- <ResultForC object at ...>
+ <example.ResultForC object at ...>
The value of the decorated attribute or the property will be only set if the
old and new value differs:
@@ -289,7 +288,7 @@
['ID', 'IB', 'IA']
>>> IResult(p)
- <ResultForD object at ...>
+ <example.ResultForD object at ...>
If the twice the same interface is set only the first is accepted.
Attention, in this case no directly provides event is notified, because
@@ -312,7 +311,7 @@
>>> [iface.__name__ for iface in interface.directlyProvidedBy(p)]
['ID', 'IC', 'IB', 'IA']
>>> IResult(p)
- <ResultForD object at ...>
+ <example.ResultForD object at ...>
>>> p.first = (IC, ID)
before
@@ -322,7 +321,7 @@
>>> [iface.__name__ for iface in interface.directlyProvidedBy(p)]
['IC', 'ID', 'IB', 'IA']
>>> IResult(p)
- <ResultForC object at ...>
+ <example.ResultForC object at ...>
We can remove a regular directly provided:
@@ -332,7 +331,7 @@
>>> [iface.__name__ for iface in interface.directlyProvidedBy(p)]
['IC', 'ID', 'IA']
>>> IResult(p)
- <ResultForC object at ...>
+ <example.ResultForC object at ...>
But we cannot remove a prepended one. Attention, in this case no directly provides
event is notified, because the directly provided interfaces
@@ -343,7 +342,7 @@
>>> [iface.__name__ for iface in interface.directlyProvidedBy(p)]
['IC', 'ID', 'IA']
>>> IResult(p)
- <ResultForC object at ...>
+ <example.ResultForC object at ...>
If we like to remove prepended one, we have to set the corresponding attribute.
Take care, sometimes a second prepended still offfers an removed interface:
@@ -356,7 +355,7 @@
>>> [iface.__name__ for iface in interface.directlyProvidedBy(p)]
['IA', 'ID']
>>> IResult(p)
- <ResultForA object at ...>
+ <example.ResultForA object at ...>
There is event dispatcher to object modified events provided if the object
providing IProvides is marked by IObjectModifiedEventDispatchingProvides:
Modified: zope.generic/trunk/src/zope/generic/directlyprovides/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/directlyprovides/testing.py 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/directlyprovides/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
@@ -18,7 +18,8 @@
__docformat__ = 'restructuredtext'
-from zope.app.testing import ztapi
+from zope.component import provideHandler
+import zope.app.testing.placelesssetup
import zope.generic.testing.testing
@@ -36,22 +37,32 @@
#
################################################################################
+# specific tests
+def setUp(doctest=None):
+ # handlers
+ from zope.generic.directlyprovides.handler import notifyObjectModifiedEvent
+ from zope.generic.directlyprovides import IDirectlyProvidesModifiedEvent
+ provideHandler(notifyObjectModifiedEvent, [IDirectlyProvidesModifiedEvent])
+def tearDown(doctest=None):
+ pass
-class PlacelessSetup(zope.generic.testing.testing.PlacelessSetup):
- def setUp(self, doctesttest=None):
- super(PlacelessSetup, self).setUp(doctesttest)
- # handlers
- from zope.generic.directlyprovides.handler import notifyObjectModifiedEvent
- from zope.generic.directlyprovides import IDirectlyProvidesModifiedEvent
- ztapi.subscribe([IDirectlyProvidesModifiedEvent],
- None, notifyObjectModifiedEvent)
-
- def tearDown(self, doctesttest=None):
- super(PlacelessSetup, self).tearDown()
+class PlacelessSetup(zope.app.testing.placelesssetup.PlacelessSetup):
+ def setUp(self, doctest=None):
+ super(PlacelessSetup, self).setUp(doctest)
+ # external setup
+ zope.generic.testing.testing.setUp(doctest)
+ # internal setup
+ setUp(doctest)
+ def tearDown(self, doctest=None):
+ super(PlacelessSetup, self).tearDown()
+ # external teardown
+ zope.generic.testing.testing.tearDown(doctest)
+ # internal teardown
+ tearDown(doctest)
placelesssetup = PlacelessSetup()
Modified: zope.generic/trunk/src/zope/generic/directlyprovides/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/directlyprovides/tests.py 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/directlyprovides/tests.py 2006-04-10 03:58:30 UTC (rev 66757)
@@ -24,7 +24,7 @@
from zope import schema
from zope.testing import doctest
-from zope.generic.directlyprovides.testing import placelesssetup, ztapi
+from zope.generic.directlyprovides.testing import placelesssetup
from zope.generic.testing.testing import registerDirective
@@ -37,8 +37,7 @@
setUp=placelesssetup.setUp,
tearDown=placelesssetup.tearDown,
globs={'component': component, 'interface': interface,
- 'schema': schema, 'ztapi': ztapi,
- 'registerDirective': registerDirective},
+ 'schema': schema, 'registerDirective': registerDirective},
optionflags=doctest.NORMALIZE_WHITESPACE+
doctest.ELLIPSIS),
))
Modified: zope.generic/trunk/src/zope/generic/information/NEW_README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/information/NEW_README.txt 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/information/NEW_README.txt 2006-04-10 03:58:30 UTC (rev 66757)
@@ -46,7 +46,7 @@
>>> registerDirective('''
... <generic:configuration
- ... interface="zope.generic.example.ILogConfiguration"
+ ... interface="example.ILogConfiguration"
... />
... ''')
@@ -62,7 +62,7 @@
>>> registerDirective('''
... <generic:configuration
- ... interface="zope.generic.example.ILoggerConfiguration"
+ ... interface="example.ILoggerConfiguration"
... />
... ''')
@@ -70,13 +70,13 @@
>>> registerDirective('''
... <generic:informationRegistry
- ... interface='zope.generic.example.ILogSupplierInformation'
+ ... interface='example.ILogSupplierInformation'
... />
... ''')
>>> registerDirective('''
... <generic:informationRegistry
- ... interface='zope.generic.example.ILogUserInformation'
+ ... interface='example.ILogUserInformation'
... />
... ''')
Modified: zope.generic/trunk/src/zope/generic/information/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/information/README.txt 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/information/README.txt 2006-04-10 03:58:30 UTC (rev 66757)
@@ -24,14 +24,10 @@
>>> class IFooMarker(Interface):
... pass
- # make available within the testing module
- >>> testing.ISpecialInformation, testing.IFooMarker = ISpecialInformation, IFooMarker
- >>> IFooMarker.__module__ = ISpecialInformation.__module = 'zope.generic.information.testing'
-
>>> registerDirective('''
... <generic:information
- ... interface="zope.generic.information.testing.IFooMarker"
- ... registry="zope.generic.information.testing.ISpecialInformation"
+ ... interface="example.IFooMarker"
+ ... registry="example.ISpecialInformation"
... label='Foo Specials' hint='Bla bla foo.'
... />
... ''')
@@ -115,12 +111,9 @@
>>> class IMyConfiguration(interface.Interface):
... my = TextLine(title=u'My')
- # make available within the testing module
- >>> testing.IMyConfiguration = IMyConfiguration
-
>>> registerDirective('''
... <generic:configuration
- ... interface="zope.generic.information.testing.IMyConfiguration"
+ ... interface="example.IMyConfiguration"
... label='My' hint='My bla.'
... />
... ''')
@@ -161,18 +154,15 @@
>>> from zope.generic.configuration.api import ConfigurationData
>>> my_information_config = ConfigurationData(IMyConfiguration, {'my': u'My!'})
- # make available within the testing module
- >>> testing.my_information_config = my_information_config
-
>>> registerDirective('''
... <generic:information
- ... interface="zope.generic.information.testing.IFooMarker"
- ... registry="zope.generic.information.testing.ISpecialInformation"
+ ... interface="example.IFooMarker"
+ ... registry="example.ISpecialInformation"
... label='Foo Specials' hint='Bla bla foo.'
... >
... <configuration
- ... interface="zope.generic.information.testing.IMyConfiguration"
- ... data="zope.generic.information.testing.my_information_config"
+ ... interface="example.IMyConfiguration"
+ ... data="example.my_information_config"
... />
... </generic:information>
... ''')
Modified: zope.generic/trunk/src/zope/generic/information/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/testing.py 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/information/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
@@ -20,10 +20,10 @@
from zope.configuration.xmlconfig import XMLConfig
+import zope.app.testing.placelesssetup
+import zope.generic.directlyprovides.testing
import zope.generic.testing.testing
-from zope.app.testing import setup
-
################################################################################
#
# Public Test implementations
@@ -39,18 +39,34 @@
################################################################################
-class PlacelessSetup(zope.generic.testing.testing.PlacelessSetup):
- def setUp(self, doctesttest=None):
- super(PlacelessSetup, self).setUp(doctesttest)
+# specific tests
+def setUp(doctest=None):
+ # register the directive of this package
+ import zope.generic.information
+ XMLConfig('meta.zcml', zope.generic.information)()
- # register the directive of this package
- import zope.generic.information
- XMLConfig('meta.zcml', zope.generic.information)()
+def tearDown(doctest=None):
+ pass
- def tearDown(self, doctesttest=None):
- super(PlacelessSetup, self).tearDown(doctesttest)
+class PlacelessSetup(zope.app.testing.placelesssetup.PlacelessSetup):
+ def setUp(self, doctest=None):
+ super(PlacelessSetup, self).setUp(doctest)
+ # external setup
+ zope.generic.testing.testing.setUp(doctest)
+ zope.generic.directlyprovides.testing.setUp(doctest)
+ # internal setup
+ setUp(doctest)
+
+ def tearDown(self, doctest=None):
+ super(PlacelessSetup, self).tearDown()
+ # external teardown
+ zope.generic.testing.testing.tearDown(doctest)
+ zope.generic.directlyprovides.testing.tearDown(doctest)
+ # internal teardown
+ tearDown(doctest)
+
placelesssetup = PlacelessSetup()
Modified: zope.generic/trunk/src/zope/generic/information/tests.py
===================================================================
--- zope.generic/trunk/src/zope/generic/information/tests.py 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/information/tests.py 2006-04-10 03:58:30 UTC (rev 66757)
@@ -23,7 +23,6 @@
from zope.testing import doctest
from zope.generic.configuration.testing import placelesssetup
-from zope.generic.configuration.testing import placelesssetup2
from zope.generic.testing.testing import registerDirective
from zope.generic.information import testing
@@ -43,8 +42,8 @@
optionflags=doctest.NORMALIZE_WHITESPACE+
doctest.ELLIPSIS),
doctest.DocFileSuite('NEW_README.txt',
- setUp=placelesssetup2.setUp,
- tearDown=placelesssetup2.tearDown,
+ setUp=placelesssetup.setUp,
+ tearDown=placelesssetup.tearDown,
globs={'component': component, 'interface': interface,
'registerDirective': registerDirective,
'testing': testing},
Modified: zope.generic/trunk/src/zope/generic/testing/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/testing/testing.py 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/testing/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
@@ -20,8 +20,11 @@
from cStringIO import StringIO
+from zope.app.testing import setup
from zope.configuration.xmlconfig import XMLConfig
from zope.configuration.xmlconfig import xmlconfig
+from zope.interface import providedBy
+from zope.interface import implementedBy
from zope.interface.verify import verifyClass
from zope.interface.verify import verifyObject
import unittest
@@ -63,14 +66,22 @@
def test_verify_class(self):
if self._verify_class:
- self.assert_(verifyClass(self._test_interface, self._verify_class))
+ self.assert_(self._test_interface.implementedBy(self._verify_class))
+ # check all provided interfaces
+ for interface in implementedBy(self._verify_class):
+ self.assert_(verifyClass(interface, self._verify_class))
def test_verify_object(self):
if self._verify_object:
- self.assert_(verifyObject(self._test_interface, self.makeTestObject()))
+ obj = self.makeTestObject()
+ # check all provided interfaces
+ for interface in providedBy(obj):
+ self.assert_(verifyObject(interface, obj))
+ def test_is_interface_provided(self):
+ obj = self.makeTestObject()
+ self.assert_(self._test_interface.providedBy(obj))
-
################################################################################
#
# Placeless setup
@@ -87,33 +98,43 @@
</configure>"""
+
def registerDirective(direcitive):
xmlconfig(StringIO(template % direcitive))
+# specific tests
+def setUp(doctest=None):
+ # zope.app.annotations
+ from zope.app.annotation.interfaces import IAnnotations
+ from zope.app.annotation.interfaces import IAttributeAnnotatable
+ from zope.app.annotation.attribute import AttributeAnnotations
-class PlacelessSetup(zope.app.testing.placelesssetup.PlacelessSetup):
+ provideAdapter(AttributeAnnotations, adapts=[IAttributeAnnotatable],
+ provides=IAnnotations)
- def setUp(self, doctesttest=None):
- super(PlacelessSetup, self).setUp(doctesttest)
+ # zcml configurations
+ import zope.app.component
+ XMLConfig('meta.zcml', zope.app.component)()
+ import zope.app.security
+ XMLConfig('meta.zcml', zope.app.security)()
+
+ # provide artificial module for doctests
+ setup.setUpTestAsModule(doctest, 'example')
- # zope.app.annotations
- from zope.app.annotation.interfaces import IAnnotations
- from zope.app.annotation.interfaces import IAttributeAnnotatable
- from zope.app.annotation.attribute import AttributeAnnotations
+def tearDown(doctest=None):
+ pass
- provideAdapter(AttributeAnnotations, adapts=[IAttributeAnnotatable],
- provides=IAnnotations)
- # zcml configurations
- import zope.app.component
- XMLConfig('meta.zcml', zope.app.component)()
- import zope.app.security
- XMLConfig('meta.zcml', zope.app.security)()
- def tearDown(self, doctesttest=None):
- super(PlacelessSetup, self).tearDown()
+class PlacelessSetup(zope.app.testing.placelesssetup.PlacelessSetup):
+ def setUp(self, doctest=None):
+ super(PlacelessSetup, self).setUp(doctest)
+ setUp(doctest)
+ def tearDown(self, doctest=None):
+ super(PlacelessSetup, self).tearDown()
+ tearDown(doctest)
placelesssetup = PlacelessSetup()
Modified: zope.generic/trunk/src/zope/generic/type/README.txt
===================================================================
--- zope.generic/trunk/src/zope/generic/type/README.txt 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/type/README.txt 2006-04-10 03:58:30 UTC (rev 66757)
@@ -30,9 +30,6 @@
>>> class IFooMarker(interface.Interface):
... pass
- # make available within the testing module
- >>> testing.IFooMarker = IFooMarker
-
The only thing to register a specific logical type is this type marker interface.
The package offers four different generic implementation such as Object,
Contained, Container and Folder (Site) that you might use as implementation of
@@ -50,7 +47,7 @@
>>> registerDirective('''
... <generic:type
- ... interface="zope.generic.type.testing.IFooMarker"
+ ... interface="example.IFooMarker"
... label='Foo Type' hint='Bla bla bla.'
... class='zope.generic.type.api.Object'
... />
@@ -118,9 +115,6 @@
>>> class IBarMarker(interface.Interface):
... pass
- # make available within the testing module
- >>> testing.IBarMarker = IBarMarker
-
Then we provide two example configurations for our example:
>>> from zope.schema import TextLine
@@ -132,21 +126,16 @@
... other = TextLine(title=u'Other')
... optional = TextLine(title=u'Other', required=False, default=u'Default bla.')
- # make available within the testing module
- >>> testing.IAnyConfiguration = IAnyConfiguration
- >>> testing.IOtherConfiguration = IOtherConfiguration
- >>> IAnyConfiguration.__module__ = IOtherConfiguration.__module__ = 'zope.generic.type.testing'
-
>>> registerDirective('''
... <generic:configuration
- ... interface="zope.generic.type.testing.IAnyConfiguration"
+ ... interface="example.IAnyConfiguration"
... label='Any' hint='Any bla.'
... />
... ''')
>>> registerDirective('''
... <generic:configuration
- ... interface="zope.generic.type.testing.IOtherConfiguration"
+ ... interface="example.IOtherConfiguration"
... />
... ''')
@@ -155,32 +144,26 @@
>>> IAnyConfiguration.providedBy(typedata)
True
- # make available within the testing module
- >>> testing.typedata = typedata
-
We can provide a specific intializer:
>>> def barInitializer(context, *pos, **kws):
... print 'Initializing ...'
- # make available within the testing module
- >>> testing.barInitializer = barInitializer
-
After all we register our component using the type directive:
>>> registerDirective('''
... <generic:type
- ... interface="zope.generic.type.testing.IBarMarker"
+ ... interface="example.IBarMarker"
... label='Bar Type' hint='Bla bla bla.'
... class='zope.generic.type.api.Object'
... >
... <initializer
- ... interface='zope.generic.type.testing.IOtherConfiguration'
- ... handler='zope.generic.type.testing.barInitializer'
+ ... interface='example.IOtherConfiguration'
+ ... handler='example.barInitializer'
... />
... <configuration
- ... interface='zope.generic.type.testing.IAnyConfiguration'
- ... data='zope.generic.type.testing.typedata'
+ ... interface='example.IAnyConfiguration'
+ ... data='example.typedata'
... />
... </generic:type>
... ''')
Modified: zope.generic/trunk/src/zope/generic/type/testing.py
===================================================================
--- zope.generic/trunk/src/zope/generic/type/testing.py 2006-04-10 02:31:22 UTC (rev 66756)
+++ zope.generic/trunk/src/zope/generic/type/testing.py 2006-04-10 03:58:30 UTC (rev 66757)
@@ -20,7 +20,11 @@
from zope.configuration.xmlconfig import XMLConfig
+import zope.app.testing.placelesssetup
import zope.generic.configuration.testing
+import zope.generic.directlyprovides.testing
+import zope.generic.information.testing
+import zope.generic.testing.testing
################################################################################
#
@@ -38,19 +42,38 @@
# Placeless setup
#
################################################################################
-
-# helper for directive testing
-class PlacelessSetup(zope.generic.configuration.testing.PlacelessSetup):
- def setUp(self, doctesttest=None):
- super(PlacelessSetup, self).setUp(doctesttest)
- # register the directive of this package
- import zope.generic.type
- XMLConfig('meta.zcml', zope.generic.type)()
+# specific tests
+def setUp(doctest=None):
+ # register the directive of this package
+ import zope.generic.type
+ XMLConfig('meta.zcml', zope.generic.type)()
- def tearDown(self, doctesttest=None):
- super(PlacelessSetup, self).tearDown(doctesttest)
+def tearDown(doctest=None):
+ pass
+class PlacelessSetup(zope.app.testing.placelesssetup.PlacelessSetup):
+
+ def setUp(self, doctest=None):
+ super(PlacelessSetup, self).setUp(doctest)
+ # external setup
+ zope.generic.testing.testing.setUp(doctest)
+ zope.generic.directlyprovides.testing.setUp(doctest)
+ zope.generic.information.testing.setUp(doctest)
+ zope.generic.configuration.testing.setUp(doctest)
+ # internal setup
+ setUp(doctest)
+
+ def tearDown(self, doctest=None):
+ super(PlacelessSetup, self).tearDown()
+ # external teardown
+ zope.generic.testing.testing.tearDown(doctest)
+ zope.generic.directlyprovides.testing.tearDown(doctest)
+ zope.generic.information.testing.tearDown(doctest)
+ zope.generic.configuration.testing.tearDown(doctest)
+ # internal teardown
+ tearDown(doctest)
+
placelesssetup = PlacelessSetup()
More information about the Checkins
mailing list