[Zope3-checkins] CVS: Zope3/src/zope/app/pagetemplate/tests - test_directives.py:1.4.2.1

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


Update of /cvs-repository/Zope3/src/zope/app/pagetemplate/tests
In directory cvs.zope.org:/tmp/cvs-serv14946/pagetemplate/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/pagetemplate/tests/test_directives.py 1.4 => 1.4.2.1 ===
--- Zope3/src/zope/app/pagetemplate/tests/test_directives.py:1.4	Mon Jul 28 18:20:04 2003
+++ Zope3/src/zope/app/pagetemplate/tests/test_directives.py	Wed Aug  6 10:27:53 2003
@@ -17,14 +17,16 @@
 """
 
 import unittest
-from cStringIO import StringIO
-
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
-
-from zope.app.tests.placelesssetup import PlacelessSetup
 
+from zope.configuration import xmlconfig
 from zope.interface import Interface, implements
 from zope.component.adapter import provideAdapter
+
+import zope.app.pagetemplate
+import zope.app.configuration
+import zope.app.component.service
+
+from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.interfaces.traversing import ITraversable
 
 template = """<zopeConfigure 
@@ -33,11 +35,6 @@
    %s
    </zopeConfigure>"""
 
-
-def definePermissions():
-    XMLConfig('meta.zcml', zope.app.pagetemplate)()
-
-
 class I(Interface):
     pass
 
@@ -55,36 +52,38 @@
 
 class Test(PlacelessSetup, unittest.TestCase):
 
-    # XXX: tests for other directives needed
-
     def setUp(self):
         import zope.configuration
         PlacelessSetup.setUp(self)
-        XMLConfig('meta.zcml', zope.app.pagetemplate)()
+        self._config()
+
+    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.pagetemplate,
+                       context=context)
+        self._context = context
 
     def testTalesAPI1(self):
         from zope.app.pagetemplate.engine import Engine
-
         provideAdapter(None, I, Adapter)
-
-        xmlconfig(StringIO(template % (
+        xmlconfig.string(template % (
             """
             <tales:namespace 
               prefix="zope"
               interface="zope.app.pagetemplate.tests.test_directives.I"
               />
-            """
-            )))
-
+            """),
+                         context=self._context)
 
         e = Engine.compile('context/zope:title')
         res = e(Engine.getContext(context = None))
-
         self.assertEqual(res, '42')
 
-
 def test_suite():
     loader=unittest.TestLoader()
     return loader.loadTestsFromTestCase(Test)
+
 if __name__=='__main__':
     unittest.TextTestRunner().run(test_suite())




More information about the Zope3-Checkins mailing list