[Zope-CVS] CVS: Packages/pypes/pypes/tests - test_expression.py:1.14
Casey Duncan
casey at zope.com
Fri Jul 23 01:03:09 EDT 2004
Update of /cvs-repository/Packages/pypes/pypes/tests
In directory cvs.zope.org:/tmp/cvs-serv9532/tests
Modified Files:
test_expression.py
Log Message:
Add combineOrderExprs() function for use by sort implementation
Make sure order expressions with different order directions never compare equal
Remove uneeded getCallerNamespace() function
=== Packages/pypes/pypes/tests/test_expression.py 1.13 => 1.14 ===
--- Packages/pypes/pypes/tests/test_expression.py:1.13 Thu Jul 1 23:14:21 2004
+++ Packages/pypes/pypes/tests/test_expression.py Fri Jul 23 01:03:09 2004
@@ -226,7 +226,6 @@
self.failUnless(f(1))
self.failIf(f(z=6))
-
class WhiteTestExpression(unittest.TestCase):
"""Whitebox expression tests"""
@@ -263,6 +262,11 @@
def test_order_value(self):
self.assertEqual(self.expr_factory('x').order, 1)
+
+ def test_compare(self):
+ self.assertEqual(self.expr_factory('x+1'), self.expr_factory('x+1'))
+ self.assertNotEqual(self.expr_factory('x+1'), self.expr_factory('x-1'))
+ self.assertNotEqual(self.expr_factory('x+1'), Desc('x+1'))
class TestDesc(TestAsc):
@@ -270,6 +274,38 @@
def test_order_value(self):
self.assertEqual(self.expr_factory('x').order, -1)
+
+ def test_compare(self):
+ self.assertEqual(self.expr_factory('x+1'), self.expr_factory('x+1'))
+ self.assertNotEqual(self.expr_factory('x+1'), self.expr_factory('x-1'))
+ self.assertNotEqual(self.expr_factory('x+1'), Asc('x+1'))
+
+class TestCombineOrderExprs(unittest.TestCase):
+
+ def test_combine_asc(self):
+ from pypes.expression import combineOrderExprs
+ combined = combineOrderExprs(
+ Asc('p.lname'), Asc('p.fname'), Asc('x.p.mname'))
+ self.failUnless(isinstance(combined, Asc))
+ self.assertEqual(combined, Asc('(p.lname, p.fname, x.p.mname)'))
+
+ def test_combine_desc(self):
+ from pypes.expression import combineOrderExprs
+ combined = combineOrderExprs(Desc('d.day'), Desc('d.hour'))
+ self.failUnless(isinstance(combined, Desc))
+ self.assertEqual(combined, Desc('(d.day, d.hour)'))
+
+ def test_combine_bindings(self):
+ from pypes.expression import combineOrderExprs
+ combined = combineOrderExprs(
+ Desc('x+y', {'y':4}), Desc('x[z]', {'z':1000}), Desc('x.uber'))
+ self.assertEqual(combined.bindings(), {'y':4, 'z':1000})
+
+ def test_combine_different_orders(self):
+ from pypes.expression import combineOrderExprs
+ self.assertRaises(
+ PypesError, combineOrderExprs, Asc('foo'), Desc('bar'))
+
if __name__ == '__main__':
unittest.main()
More information about the Zope-CVS
mailing list