@ -134,19 +134,18 @@ class TestPredicate(unittest.TestCase):
with self . assertRaises ( SyntaxError ) :
with self . assertRaises ( SyntaxError ) :
util . FilterPredicate ( " ( " )
util . FilterPredicate ( " ( " )
with self . assertRaises ( exception . FilterError ) :
self . assertFalse (
util . FilterPredicate ( " a > 1 " ) ( url , { " a " : None } )
util . FilterPredicate ( " a > 1 " ) ( url , { " a " : None } ) )
self . assertFalse (
with self . assertRaises ( exception . FilterError ) :
util . FilterPredicate ( " b > 1 " ) ( url , { " a " : 2 } ) )
util . FilterPredicate ( " b > 1 " ) ( url , { " a " : 2 } )
pred = util . FilterPredicate ( [ " a < 3 " , " b < 4 " , " c < 5 " ] )
pred = util . FilterPredicate ( [ " a < 3 " , " b < 4 " , " c < 5 " ] )
self . assertTrue ( pred ( url , { " a " : 2 , " b " : 3 , " c " : 4 } ) )
self . assertTrue ( pred ( url , { " a " : 2 , " b " : 3 , " c " : 4 } ) )
self . assertFalse ( pred ( url , { " a " : 3 , " b " : 3 , " c " : 4 } ) )
self . assertFalse ( pred ( url , { " a " : 3 , " b " : 3 , " c " : 4 } ) )
self . assertFalse ( pred ( url , { " a " : 2 , " b " : 4 , " c " : 4 } ) )
self . assertFalse ( pred ( url , { " a " : 2 , " b " : 4 , " c " : 4 } ) )
self . assertFalse ( pred ( url , { " a " : 2 , " b " : 3 , " c " : 5 } ) )
self . assertFalse ( pred ( url , { " a " : 2 , " b " : 3 , " c " : 5 } ) )
with self . assertRaises ( exception . FilterError ) :
pred ( url , { " a " : 2 } )
self . assertFalse ( pred ( url , { " a " : 2 } ) )
def test_build_predicate ( self ) :
def test_build_predicate ( self ) :
pred = util . build_predicate ( [ ] )
pred = util . build_predicate ( [ ] )
@ -445,6 +444,7 @@ class TestOther(unittest.TestCase):
self . assertEqual ( expr ( { " a " : 1 , " b " : 2 , " c " : 3 } ) , 7 )
self . assertEqual ( expr ( { " a " : 1 , " b " : 2 , " c " : 3 } ) , 7 )
self . assertEqual ( expr ( { " a " : 9 , " b " : 9 , " c " : 9 } ) , 90 )
self . assertEqual ( expr ( { " a " : 9 , " b " : 9 , " c " : 9 } ) , 90 )
expr = util . compile_expression_raw ( " a + b * c " )
with self . assertRaises ( NameError ) :
with self . assertRaises ( NameError ) :
expr ( )
expr ( )
with self . assertRaises ( NameError ) :
with self . assertRaises ( NameError ) :