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

Philipp von Weitershausen philikon at philikon.de
Wed Mar 3 21:10:12 EST 2004


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

Modified Files:
	test_directives.py 
Log Message:
Added new ZCML directive for registering expression types.


=== Zope3/src/zope/app/pagetemplate/tests/test_directives.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/pagetemplate/tests/test_directives.py:1.8	Thu Nov 27 08:59:22 2003
+++ Zope3/src/zope/app/pagetemplate/tests/test_directives.py	Wed Mar  3 21:10:10 2004
@@ -24,6 +24,7 @@
 from zope.app.tests import ztapi
 
 import zope.app.pagetemplate
+from zope.app.pagetemplate.engine import Engine
 
 from zope.app.interfaces.traversing import ITraversable
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -35,10 +36,6 @@
    </configure>"""
 
 
-def definePermissions():
-    XMLConfig('meta.zcml', zope.app.pagetemplate)()
-
-
 class I(Interface):
     pass
 
@@ -54,37 +51,47 @@
     def traverse(self, name, *args):
         return getattr(self, name)
 
-class Test(PlacelessSetup, unittest.TestCase):
+class Handler:
+    pass
 
-    # XXX: tests for other directives needed
+class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
         super(Test, self).setUp()
         XMLConfig('meta.zcml', zope.app.pagetemplate)()
 
     def testTalesAPI1(self):
-        from zope.app.pagetemplate.engine import Engine
-
         ztapi.provideAdapter(None, I, Adapter)
 
         xmlconfig(StringIO(template % (
             """
-            <tales:namespace 
+            <tales:namespace
               prefix="zope"
               interface="zope.app.pagetemplate.tests.test_directives.I"
               />
             """
             )))
 
-
         e = Engine.compile('context/zope:title')
-        res = e(Engine.getContext(context = None))
+        res = e(Engine.getContext(context=None))
 
         self.assertEqual(res, '42')
 
+    def testExpressionType(self):
+        xmlconfig(StringIO(template % (
+            """
+            <tales:expressiontype
+              name="test"
+              handler="zope.app.pagetemplate.tests.test_directives.Handler"
+              />
+            """
+            )))
+        self.assert_("test" in Engine.getTypes())
+        self.assert_(Handler is Engine.getTypes()['test'])
 
 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