[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/app/versioncontrol/
sanitize tests regarding their event setup and test subscribers
Philipp von Weitershausen
philikon at philikon.de
Fri Apr 7 08:46:28 EDT 2006
Log message for revision 66644:
sanitize tests regarding their event setup and test subscribers
Changed:
U Zope3/branches/jim-adapter/src/zope/app/versioncontrol/README.txt
U Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/versioncontrol/README.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/versioncontrol/README.txt 2006-04-07 12:45:28 UTC (rev 66643)
+++ Zope3/branches/jim-adapter/src/zope/app/versioncontrol/README.txt 2006-04-07 12:46:28 UTC (rev 66644)
@@ -22,7 +22,8 @@
that contain their own location information.
>>> import persistent
- >>> from zope import component, interface
+ >>> import zope.interface
+ >>> import zope.component
>>> import zope.traversing.interfaces
>>> import zope.annotation.attribute
>>> import zope.annotation.interfaces
@@ -31,7 +32,7 @@
>>> marker = object()
>>> class Sample(persistent.Persistent):
- ... interface.implements(
+ ... zope.interface.implements(
... interfaces.IVersionable,
... interfaces.INonVersionedData,
... zope.annotation.interfaces.IAttributeAnnotatable,
@@ -69,12 +70,8 @@
... def __repr__(self):
... return "<%s object>" % self.__class__.__name__
- >>> component.provideAdapter(
+ >>> zope.component.provideAdapter(
... zope.annotation.attribute.AttributeAnnotations)
- ... # doctest: +NORMALIZE_WHITESPACE
- Registered event:
- AdapterRegistration(<BaseGlobalComponents base>,
- [IAttributeAnnotatable], IAnnotations, '', AttributeAnnotations, u'')
Now we need to create a database with an instance of our sample object to work
with:
@@ -120,8 +117,7 @@
>>> repository = zope.app.versioncontrol.repository.Repository()
>>> zope.interface.verify.verifyObject(
- ... interfaces.IRepository,
- ... repository)
+ ... interfaces.IRepository, repository)
True
In order to actually use version control, there must be an
@@ -138,17 +134,12 @@
Let's register some subscribers so we can check that interesting
events are being fired for version control actions:
- >>> def showEvent(label, object, event):
- ... print label, "for", object
+ >>> @zope.component.adapter(None, interfaces.IVersionEvent)
+ ... def printEvent(object, event):
+ ... print event
+ ...
+ >>> zope.component.provideHandler(printEvent)
- >>> component.provideHandler(
- ... (lambda ob, evt: showEvent("applied version control", ob, evt)),
- ... (interface.Interface, interfaces.IVersionControlApplied))
- ... # doctest: +NORMALIZE_WHITESPACE
- Registered event:
- HandlerRegistration(<BaseGlobalComponents base>,
- [Interface, IVersionControlApplied], u'', <lambda>, u'')
-
Now, let's put an object under version control and verify that we can
determine that fact by checking against the interface:
Modified: Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py 2006-04-07 12:45:28 UTC (rev 66643)
+++ Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py 2006-04-07 12:46:28 UTC (rev 66644)
@@ -25,8 +25,8 @@
import zope.traversing.interfaces
import zope.annotation.interfaces
import zope.annotation.attribute
-from zope import component, interface
-from zope.component.testing import PlacelessSetup
+import zope.component.testing
+from zope import interface
from zope.testing import doctest, module
import zope.app.versioncontrol.version
@@ -34,12 +34,9 @@
name = 'zope.app.versioncontrol.README'
-ps = PlacelessSetup()
-
def setUp(test):
- ps.setUp()
+ zope.component.testing.setUp(test)
module.setUp(test, name)
- zope.event.subscribers.append(eventHandler)
def tearDown(test):
module.tearDown(test, name)
@@ -47,19 +44,12 @@
db = test.globs.get('db')
if db is not None:
db.close()
- ps.tearDown()
- if eventHandler in zope.event.subscribers:
- zope.event.subscribers.remove(eventHandler)
+ zope.component.testing.tearDown(test)
-def eventHandler(event):
- print event
-
-
class L(persistent.Persistent, zope.location.Location):
interface.implements(interfaces.IVersionable,
zope.annotation.interfaces.IAttributeAnnotatable,
- zope.traversing.interfaces.IPhysicallyLocatable,
- )
+ zope.traversing.interfaces.IPhysicallyLocatable)
def getPath(self):
return 'whatever'
@@ -146,9 +136,9 @@
>>> from ZODB.tests import util
>>> import transaction
>>> db = util.DB()
- >>> component.provideAdapter(
+ >>> zope.component.provideAdapter(
... zope.annotation.attribute.AttributeAnnotations)
- >>> component.provideAdapter(
+ >>> zope.component.provideAdapter(
... nonversioned.StandardNonVersionedDataAdapter,
... [None])
>>> import zope.app.versioncontrol.repository
More information about the Zope3-Checkins
mailing list