[Zope-Checkins]
SVN: Products.Five/branches/philikon-local-components/tests/
Better test setup (no ZCML,
no placelesssetup). Should be faster now :).
Philipp von Weitershausen
philikon at philikon.de
Wed Apr 19 14:11:46 EDT 2006
Log message for revision 67164:
Better test setup (no ZCML, no placelesssetup). Should be faster now :).
Changed:
U Products.Five/branches/philikon-local-components/tests/event.txt
U Products.Five/branches/philikon-local-components/tests/test_event.py
-=-
Modified: Products.Five/branches/philikon-local-components/tests/event.txt
===================================================================
--- Products.Five/branches/philikon-local-components/tests/event.txt 2006-04-19 18:05:47 UTC (rev 67163)
+++ Products.Five/branches/philikon-local-components/tests/event.txt 2006-04-19 18:11:46 UTC (rev 67164)
@@ -25,9 +25,6 @@
A bit of setup for the tests. Because we'll test copy/paste, we need to
work inside a database::
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
-
>>> import ZODB.tests.util
>>> db = ZODB.tests.util.DB()
>>> connection = db.open()
@@ -58,7 +55,7 @@
framework's ones, so ours will be called first. This has the effect that
printed events will be in their "natural" order::
- >>> from zope.component.interfaces import IObjectEvent
+ >>> from zope.component.interfaces import IObjectEvent, IRegistrationEvent
>>> from zope.app.container.interfaces import IObjectMovedEvent
>>> from OFS.interfaces import IObjectWillBeMovedEvent
>>> from OFS.interfaces import IObjectClonedEvent
@@ -68,7 +65,8 @@
>>> def printObjectEventExceptSome(object, event):
... if (IObjectMovedEvent.providedBy(event) or
... IObjectWillBeMovedEvent.providedBy(event) or
- ... IObjectClonedEvent.providedBy(event)):
+ ... IObjectClonedEvent.providedBy(event) or
+ ... IRegistrationEvent.providedBy(event)):
... return
... print event.__class__.__name__, object.getId()
@@ -80,11 +78,12 @@
Finally we need to load the subscribers configuration::
- >>> from Products.Five import zcml
- >>> import Products.Five
>>> import zope.component
- >>> zcml.load_config('meta.zcml', zope.component)
- >>> zcml.load_config('event.zcml', Products.Five)
+ >>> import OFS.subscribers
+ >>> zope.component.provideAdapter(OFS.subscribers.ObjectManagerSublocations)
+ >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectWillBeMovedEvent)
+ >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectMovedEvent)
+ >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectClonedEvent)
We need at least one fake deprecated method to tell the compatibility
framework that component architecture is initialized::
@@ -465,4 +464,3 @@
>>> import transaction
>>> transaction.abort()
- >>> tearDown()
Modified: Products.Five/branches/philikon-local-components/tests/test_event.py
===================================================================
--- Products.Five/branches/philikon-local-components/tests/test_event.py 2006-04-19 18:05:47 UTC (rev 67163)
+++ Products.Five/branches/philikon-local-components/tests/test_event.py 2006-04-19 18:11:46 UTC (rev 67164)
@@ -28,6 +28,8 @@
from OFS.OrderedFolder import OrderedFolder
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
+from zope.component.testing import setUp, tearDown
+
class DontComplain(object):
def _verifyObjectPaste(self, object, validate_src=1):
pass
@@ -82,7 +84,8 @@
def test_suite():
from zope.testing.doctest import DocFileSuite
- return DocFileSuite('event.txt', package="Products.Five.tests")
+ return DocFileSuite('event.txt', package="Products.Five.tests",
+ setUp=setUp, tearDown=tearDown)
if __name__ == '__main__':
framework()
More information about the Zope-Checkins
mailing list