[Zope-Checkins] CVS: Zope3/lib/python/Zope/ObjectHub/tests - testObjectHub.py:1.6
Steve Alexander
steve@cat-box.net
Sun, 7 Jul 2002 16:32:33 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/ObjectHub/tests
In directory cvs.zope.org:/tmp/cvs-serv27091/tests
Modified Files:
testObjectHub.py
Log Message:
various reformatting of code, and small fix to location code and tests.
=== Zope3/lib/python/Zope/ObjectHub/tests/testObjectHub.py 1.5 => 1.6 ===
def notify(self, event):
self.events_received.append(event)
- # print 'notify :', id(self),self.__class__.__name__, event.__implements__.__name__
# see ObjectHub._canonical
def _canonical(location):
@@ -75,7 +74,8 @@
obj = None
ruid = None
location = self._canonical(location)
- testcase.assert_(interface.isImplementedBy(event), 'Interface %s' % interface.getName())
+ testcase.assert_(interface.isImplementedBy(event),
+ 'Interface %s' % interface.getName())
testcase.assertEqual(event.getLocation(), location)
if obj is not None:
@@ -105,7 +105,8 @@
else:
location = event.getLocation()
obj = event.getObject()
- removeEvent = RuidObjectEvent.RuidObjectRemovedEvent(obj, ruid, location)
+ removeEvent = RuidObjectEvent.RuidObjectRemovedEvent(
+ obj, ruid, location)
self.hub.notify(removeEvent)
self.hub.unregister(location)
@@ -119,13 +120,15 @@
def setUp(self):
self.object_hub = ObjectHub()
- self.ruidobject_event = self.klass(self.object_hub, self.ruid, self.location)
+ self.ruidobject_event = self.klass(self.object_hub,
+ self.ruid,
+ self.location)
self.subscriber = LoggingSubscriber()
self.object_hub.subscribe(self.subscriber)
def testTransmittedEvent(self):
- """Test that the RuidObjectEvents are transmitted by the notify method
+ """Test that the RuidObjectEvents are transmitted by the notify method
"""
self.object_hub.notify(self.ruidobject_event)
@@ -180,8 +183,9 @@
class TestRegistrationEvents(BasicHubTest):
def testRegistration(self):
- # check for notFoundError
- self.assertRaises(NotFoundError, self.object_hub.unregister, self.location)
+ self.assertRaises(NotFoundError,
+ self.object_hub.unregister,
+ self.location)
self.assertRaises(NotFoundError, self.object_hub.unregister, 42)
ruid = self.object_hub.register(self.location)
@@ -193,7 +197,9 @@
])
# register again and check for error
- self.assertRaises(ObjectHubError, self.object_hub.register, self.location)
+ self.assertRaises(ObjectHubError,
+ self.object_hub.register,
+ self.location)
# unregister first object by location
self.object_hub.unregister(self.location)
@@ -206,7 +212,8 @@
(IRuidObjectUnregisteredEvent, ruid2, self.new_location)
])
-
+ def testRegistrationRelativeLocation(self):
+ self.assertRaises(ValueError, self.object_hub.register, 'foo/bar')
class TestNoRegistration(BasicHubTest):