[Zope-CVS] CVS: Packages/pypes/pypes/tests - test_expression.py:1.9
Casey Duncan
casey at zope.com
Thu Apr 29 23:05:04 EDT 2004
Update of /cvs-repository/Packages/pypes/pypes/tests
In directory cvs.zope.org:/tmp/cvs-serv24622/tests
Modified Files:
test_expression.py
Log Message:
Make sure or/and operations on expressions copy embedded syntax tree nodes before combining them.
=== Packages/pypes/pypes/tests/test_expression.py 1.8 => 1.9 ===
--- Packages/pypes/pypes/tests/test_expression.py:1.8 Wed Apr 21 01:25:53 2004
+++ Packages/pypes/pypes/tests/test_expression.py Thu Apr 29 23:05:02 2004
@@ -147,6 +147,15 @@
self.assertRaises(PypesError, operator.or_,
Expression('x > z', {'x':100}), Expression('y < x', {'x': 1}))
+ def testOrCopiesAST(self):
+ left, right = Expression('x > 1'), Expression('y < 2')
+ e = left | right
+ left = left.ast().getChildNodes()[0]
+ right = right.ast().getChildNodes()[0]
+ left2, right2 = e.ast().getChildNodes()[0].getChildNodes()
+ self.failIf(left is left2)
+ self.failIf(right is right2)
+
def testAnd(self):
e = Expression('x > 1') & Expression('y < 2')
self.assertEqual(e, Expression('x > 1 and y < 2'))
@@ -158,6 +167,15 @@
Expression('x > z', {'x':100}), Expression('y < x'))
self.assertRaises(PypesError, operator.and_,
Expression('x > z', {'x':100}), Expression('y < x', {'x': 1}))
+
+ def testAndCopiesAST(self):
+ left, right = Expression('x > 1'), Expression('y < 2')
+ e = left & right
+ left = left.ast().getChildNodes()[0]
+ right = right.ast().getChildNodes()[0]
+ left2, right2 = e.ast().getChildNodes()[0].getChildNodes()
+ self.failIf(left is left2)
+ self.failIf(right is right2)
class WhiteTestExpression(unittest.TestCase):
More information about the Zope-CVS
mailing list