[Zope3-checkins] CVS: Zope3/src/zope/app/event/tests - test_directives.py:1.10.2.1

Philipp von Weitershausen philikon at philikon.de
Wed Aug 6 11:28:22 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/event/tests
In directory cvs.zope.org:/tmp/cvs-serv14946/event/tests

Modified Files:
      Tag: zcml-interface-field-branch
	test_directives.py 
Log Message:
Fix up tests to use the ConfigurationMachine from zope.app.configure which
is service-aware.


=== Zope3/src/zope/app/event/tests/test_directives.py 1.10 => 1.10.2.1 ===
--- Zope3/src/zope/app/event/tests/test_directives.py:1.10	Sun Aug  3 17:56:13 2003
+++ Zope3/src/zope/app/event/tests/test_directives.py	Wed Aug  6 10:27:48 2003
@@ -12,25 +12,25 @@
 #
 ##############################################################################
 """
-
-Revision information:
 $Id$
 """
 
 from unittest import TestCase, main, makeSuite
 
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
+from zope.configuration import xmlconfig
+from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component import getServiceManager
+from zope.exceptions import NotFoundError
+
 import zope.app.event
-from StringIO import StringIO
+import zope.app.configuration
+import zope.app.component.service
 
-from zope.exceptions import NotFoundError
 from zope.app.event import globalUnsubscribe, publish
 from zope.app.event.objectevent import ObjectAddedEvent
 from zope.app.event.objectevent import ObjectRemovedEvent
 from zope.app.event.objectevent import ObjectModifiedEvent
 from zope.app.event.tests.test_eventpublisher import DummyEvent
-from zope.component.tests.placelesssetup import PlacelessSetup
-from zope.component import getServiceManager
 from zope.app.services.servicenames import EventPublication
 from zope.app.interfaces.event import IEvent
 
@@ -43,14 +43,22 @@
         from zope.app.event.globalservice import eventPublisher
         getServiceManager(None).provideService(EventPublication, eventPublisher)
 
+    def _config(self):
+        sm = zope.app.component.service.globalServiceManager()
+        context = zope.app.configuration.ConfigurationMachine(sm)
+        xmlconfig.registerCommonDirectives(context)
+        xmlconfig.file('meta.zcml', package=zope.app.event,
+                       context=context)
+        self._context = context
+
     def testSubscribe(self):
         from zope.app.event.tests.subscriber import subscriber
         # This should do nothing silently, as the event_type is default
         globalUnsubscribe(subscriber)
         # This should fail, since we're not subscribed
         self.assertRaises(NotFoundError, globalUnsubscribe, subscriber, IEvent)
-        XMLConfig('meta.zcml', zope.app.event)()
-        xmlconfig(StringIO(
+        self._config()
+        xmlconfig.string(
             '''<configure xmlns='http://namespaces.zope.org/zope'
                               xmlns:test='http://namespaces.zope.org/event'>
             <test:subscribe
@@ -59,8 +67,9 @@
                        "zope.app.interfaces.event.IObjectAddedEvent
                         zope.app.interfaces.event.IObjectRemovedEvent"
                    filter="zope.app.event.tests.subscriber.filter" />
-            </configure>'''
-            ))
+            </configure>''',
+            context=self._context
+            )
 
         publish(None, ObjectAddedEvent(None, 'foo'))
         self.assertEqual(subscriber.notified, 1)




More information about the Zope3-Checkins mailing list