[Zope3-checkins] CVS: Zope3/lib/python/Zope/Event/tests - testDirectives.py:1.5

R. David Murray bitz@bitdance.com
Fri, 8 Nov 2002 13:53:36 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Event/tests
In directory cvs.zope.org:/tmp/cvs-serv1089/lib/python/Zope/Event/tests

Modified Files:
	testDirectives.py 
Log Message:
Refactor to eliminate use of top level directive directive and
simplify by using utility function from Zope.Configuration.tests.
Along the way, reformat test zcml to match style guide.


=== Zope3/lib/python/Zope/Event/tests/testDirectives.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/Event/tests/testDirectives.py:1.4	Thu Oct  3 16:53:22 2002
+++ Zope3/lib/python/Zope/Event/tests/testDirectives.py	Fri Nov  8 13:53:36 2002
@@ -30,12 +30,8 @@
 from testEventService import DummySubscriber, DummyFilter, DummyEvent
 from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
 from Zope.ComponentArchitecture import getServiceManager, getService
+from Zope.Configuration.tests.BaseTestDirectivesXML import makeconfig
 
-template = """<zopeConfigure
-  xmlns='http://namespaces.zope.org/zope'
-  xmlns:event='http://namespaces.zope.org/event'>
-  %s
-  </zopeConfigure>"""
 
 class Test(PlacelessSetup, TestCase):
     
@@ -51,19 +47,18 @@
         # This should fail, since we're not subscribed
         self.assertRaises(NotFoundError,unsubscribe,None,subscriber)
             
-        xmlconfig(StringIO(template % (
-            """
-            <directive name="subscribe"
-                       attributes="subscriber event_types filter"
-                       handler="Zope.Event.metaConfigure.subscribe"
-                       namespace="http://namespaces.zope.org/event"/>
-            <event:subscribe subscriber="Zope.Event.tests.subscriber.subscriber"
-                            
- event_types="Zope.Event.IObjectEvent.IObjectAddedEvent
-                                         
- Zope.Event.IObjectEvent.IObjectRemovedEvent"
-                             filter="Zope.Event.tests.subscriber.filter"/>
-            """)))
+        xmlconfig(makeconfig(
+            '''<directive
+                   name="subscribe"
+                   attributes="subscriber event_types filter"
+                   handler="Zope.Event.metaConfigure.subscribe" />''',
+            '''<test:subscribe
+                   subscriber="Zope.Event.tests.subscriber.subscriber"
+                   event_types=
+                       "Zope.Event.IObjectEvent.IObjectAddedEvent
+                        Zope.Event.IObjectEvent.IObjectRemovedEvent"
+                   filter="Zope.Event.tests.subscriber.filter" />'''
+            ))
 
         publishEvent(None,ObjectAddedEvent(None, 'foo'))
         self.assertEqual(subscriber.notified,1)