def test_grammar_invalidation(): """ Ensure that the grammar object doesn't get stale when operators change. """ jexl = JEXL() jexl.add_unary_operator('=', lambda x: x + 5) assert jexl.evaluate('=5') == 10 jexl.remove_unary_operator('=') with pytest.raises(ParseError): jexl.evaluate('=5')
def test_add_custom_unary_operator(): jexl = JEXL() jexl.add_unary_operator('=', lambda x: x + 5) assert jexl.evaluate('=5') == 10