[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PageTemplates/tests/testZRPythonExpr.py Forward port fix for Collector #1914 (omitted test).

Tres Seaver tseaver at palladion.com
Tue Oct 11 11:37:04 EDT 2005


Log message for revision 39046:
  Forward port fix for Collector #1914 (omitted test).

Changed:
  A   Zope/trunk/lib/python/Products/PageTemplates/tests/testZRPythonExpr.py

-=-
Added: Zope/trunk/lib/python/Products/PageTemplates/tests/testZRPythonExpr.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/tests/testZRPythonExpr.py	2005-10-11 15:36:27 UTC (rev 39045)
+++ Zope/trunk/lib/python/Products/PageTemplates/tests/testZRPythonExpr.py	2005-10-11 15:37:04 UTC (rev 39046)
@@ -0,0 +1,48 @@
+""" Unit tests for Products.PageTemplates.ZRPythonExpr
+
+$Id
+"""
+import unittest
+
+class MiscTests(unittest.TestCase):
+
+    def test_call_with_ns_prefer_context_to_here(self):
+        from Products.PageTemplates.ZRPythonExpr import call_with_ns
+        context = ['context']
+        here = ['here']
+        request = {'request': 1}
+        names = {'context' : context, 'here': here, 'request' : request}
+        result = call_with_ns(lambda td: td.this, names)
+        self.failUnless(result is context, result)
+
+    def test_call_with_ns_no_context_or_here(self):
+        from Products.PageTemplates.ZRPythonExpr import call_with_ns
+        request = {'request': 1}
+        names = {'request' : request}
+        result = call_with_ns(lambda td: td.this, names)
+        self.failUnless(result is None, result)
+
+    def test_call_with_ns_no_request(self):
+        from Products.PageTemplates.ZRPythonExpr import call_with_ns
+        context = ['context']
+        here = ['here']
+        names = {'context' : context, 'here': here}
+
+        def _find_request(td):
+            ns = td._pop()              # peel off 'ns'
+            instance_dict = td._pop()   # peel off InstanceDict
+            request = td._pop()
+            td._push(request)
+            td._push(instance_dict)
+            td._push(ns)
+            return request
+
+        result = call_with_ns(_find_request, names)
+        self.assertEqual(result, {})
+ 
+def test_suite():
+    return unittest.makeSuite(MiscTests)
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+



More information about the Zope-Checkins mailing list