IMHO, the fact that test used to pass with the Zope 2 ZPT implementation

demonstrates a bug in the very same: The local variable bag was kept
when a new scope was opened, hence it could be polluted by lower scopes.
Zope 3 makes a copy of the local variable bag when it starts a new scope.
This is there Right Thing(tm) to do. This test is now identical to its
Zope 3 equivalent.
parent e01fe241
...@@ -104,23 +104,25 @@ class TALESTests(unittest.TestCase): ...@@ -104,23 +104,25 @@ class TALESTests(unittest.TestCase):
def testVariables(self): def testVariables(self):
'''Test variables''' '''Test variables'''
ctxt = self.getContext() ctxt = self.getContext()
c = ctxt.vars
ctxt.beginScope() ctxt.beginScope()
ctxt.setLocal('v1', 1) ctxt.setLocal('v1', 1)
ctxt.setLocal('v2', 2) ctxt.setLocal('v2', 2)
c = ctxt.vars
assert c['v1'] == 1, 'Variable "v1"' assert c['v1'] == 1, 'Variable "v1"'
ctxt.beginScope() ctxt.beginScope()
ctxt.setLocal('v1', 3) ctxt.setLocal('v1', 3)
ctxt.setGlobal('g', 1) ctxt.setGlobal('g', 1)
c = ctxt.vars
assert c['v1'] == 3, 'Inner scope' assert c['v1'] == 3, 'Inner scope'
assert c['v2'] == 2, 'Outer scope' assert c['v2'] == 2, 'Outer scope'
assert c['g'] == 1, 'Global' assert c['g'] == 1, 'Global'
ctxt.endScope() ctxt.endScope()
c = ctxt.vars
assert c['v1'] == 1, "Uncovered local" assert c['v1'] == 1, "Uncovered local"
assert c['g'] == 1, "Global from inner scope" assert c['g'] == 1, "Global from inner scope"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment