[Zope-Checkins] CVS: Zope3/lib/python/Zope/PageTemplate/tests - testBasicTemplate.py:1.1.2.3 testExpressions.py:1.1.2.6 testHTMLTests.py:1.1.2.8 test_binding.py:1.1.2.5 util.py:1.1.2.7
Shane Hathaway
shane@cvs.zope.org
Wed, 13 Mar 2002 23:07:29 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/PageTemplate/tests
In directory cvs.zope.org:/tmp/cvs-serv14781
Modified Files:
Tag: Zope-3x-branch
testBasicTemplate.py testExpressions.py testHTMLTests.py
test_binding.py util.py
Log Message:
- Used Zope.Testing.CleanUp to reset EngineConfig as needed.
- Explicitly used the unrestricted expression engine to avoid tripping over
security.
- Removed dependencies on Zope.App.Security.
=== Zope3/lib/python/Zope/PageTemplate/tests/testBasicTemplate.py 1.1.2.2 => 1.1.2.3 ===
from Zope.PageTemplate.tests import util
from Zope.PageTemplate.ZPT import ZPT
+from Zope.PageTemplate.EngineConfig import setDefaultEngine
+from Zope.Testing.CleanUp import CleanUp
-class BasicTemplateTests(unittest.TestCase):
+class BasicTemplateTests(unittest.TestCase, CleanUp):
def setUp(self):
+ CleanUp.setUp(self)
+ setDefaultEngine('unrestricted')
self.t = ZPT()
- self._oldPolicy = util.getDefaultPolicy()
- util.setPermissive()
-
- def tearDown(self):
- util.restoreDefaultPolicy(self._oldPolicy)
def check_if_in_var(self):
"""DTML test 1: if, in, and var:
@@ -90,8 +89,6 @@
And I\'m 100% sure!
</body></html>
"""
- util.setPermissive()
-
tal = util.read_input('DTML3.html')
self.t.write(tal)
=== Zope3/lib/python/Zope/PageTemplate/tests/testExpressions.py 1.1.2.5 => 1.1.2.6 ===
import os, sys, unittest
-from Zope.PageTemplate.Expressions import getEngine
+from Zope.PageTemplate.EngineConfig import getEngine
class ExpressionTests(unittest.TestCase):
def testCompile(self):
'''Test expression compilation'''
- e = getEngine()
+ e = getEngine('unrestricted')
for p in ('x', 'x/y', 'x/y/z'):
e.compile(p)
e.compile('path:a|b|c/d/e')
=== Zope3/lib/python/Zope/PageTemplate/tests/testHTMLTests.py 1.1.2.7 => 1.1.2.8 ===
from Zope.PageTemplate.tests import util
from Zope.PageTemplate.ZPT import ZPT
+from Zope.PageTemplate.EngineConfig import setDefaultEngine
+from Zope.Testing.CleanUp import CleanUp
class Folder:
def getContext(self):
return self
-class HTMLTests(unittest.TestCase):
+class HTMLTests(unittest.TestCase, CleanUp):
def setUp(self):
+ CleanUp.setUp(self)
+ setDefaultEngine('unrestricted')
self.folder = f = Folder()
f.laf = ZPT()
f.t = ZPT()
- self._oldPolicy = util.getDefaultPolicy()
-
- def tearDown(self):
- util.restoreDefaultPolicy(self._oldPolicy)
def getProducts(self):
return [
@@ -45,7 +45,6 @@
util.check_html(expect, laf())
def check2(self):
- util.setPermissive()
self.folder.laf.write(util.read_input('TeeShopLAF.html'))
t = self.folder.t.__get__(self.folder)
@@ -56,7 +55,6 @@
def check3(self):
- util.setPermissive()
self.folder.laf.write(util.read_input('TeeShopLAF.html'))
t = self.folder.t.__get__(self.folder)
@@ -66,7 +64,6 @@
util.check_html(expect, out)
def checkSimpleLoop(self):
- util.setPermissive()
t = self.folder.t.__get__(self.folder)
t.write(util.read_input('Loop1.html'))
expect = util.read_output('Loop1.html')
@@ -116,7 +113,6 @@
util.check_html(expect, out)
def checkPathAlt(self):
- util.setPermissive()
t = self.folder.t.__get__(self.folder)
t.write(util.read_input('CheckPathAlt.html'))
expect = util.read_output('CheckPathAlt.html')
=== Zope3/lib/python/Zope/PageTemplate/tests/test_binding.py 1.1.2.4 => 1.1.2.5 ===
class BindingTestCase(unittest.TestCase):
- def setUp(self):
- self._oldPolicy = util.getDefaultPolicy()
- util.setPermissive()
-
- def tearDown(self):
- util.restoreDefaultPolicy(self._oldPolicy)
-
def test_binding(self):
comp = PTComponent(Content())
self.assertEqual(comp.index(), "42\n")
=== Zope3/lib/python/Zope/PageTemplate/tests/util.py 1.1.2.6 => 1.1.2.7 ===
s1 = normalize_xml(s1)
s2 = normalize_xml(s2)
- assert s1==s2, "XML Output Changed"
+ assert s1==s2, ("XML Output Changed:\n%s\n\n%s" % (s1, s2))
def normalize_html(s):
s = re.sub(r"[ \t]+", " ", s)
@@ -109,34 +109,4 @@
def read_output(filename):
filename = os.path.join(output_dir, filename)
return open(filename, 'r').read()
-
-try:
- # Use Zope security.
- import Zope.App.Security.SecurityManager
- from Zope.App.Security.SecurityManager import setSecurityPolicy
- from Zope.App.Security.SecurityManagement import noSecurityManager
- from Zope.App.Security.SimpleSecurityPolicies import \
- PermissiveSecurityPolicy
-
- def getDefaultPolicy():
- return Zope.App.Security.SecurityManager._defaultPolicy
-
- def setPermissive():
- setSecurityPolicy(PermissiveSecurityPolicy())
- noSecurityManager()
-
- def restoreDefaultPolicy(p):
- setSecurityPolicy(p)
- noSecurityManager()
-
-except ImportError:
- # No Zope security.
- def getDefaultPolicy():
- return None
-
- def setPermissive():
- pass
-
- def restoreDefaultPolicy(p):
- pass