def test_compare(): expr = "(x < 0)" node = parse_expression(expr) assert expr == node_to_string(node) expr = "((x < 0) >= 6)" node = parse_expression(expr) assert expr == node_to_string(node) expr = "(x // 10)" node = parse_expression(expr) assert expr == node_to_string(node)
def test_lists(): node = parse_expression( "searchsorted(['9E', 'AA', 'AQ', 'AS', 'B6', 'CO', 'DL', 'EV', 'F9', 'FL', 'HA', 'MQ', 'NW', 'OH', 'OO', 'UA', 'US', 'WN', 'XE', 'YV'], UniqueCarrier)" ) assert node is not None expr = "searchsorted(['9E', 'AA', 'AQ', 'AS', 'B6', 'CO', 'DL', 'EV', 'F9', 'FL', 'HA', 'MQ', 'NW', 'OH', 'OO', 'UA', 'US', 'WN', 'XE', 'YV'], UniqueCarrier)" expr_translate = translate(expr, lambda x: None) print(node) assert expr == expr_translate
def test_binary_ops(op): expression = f'(a {op["code"]} b)' node = parse_expression(expression) assert node_to_string(node) == expression validate_expression(expression, {'a', 'b'})
def test_unary_ops(op): expression = f'{op["code"]}a' node = parse_expression(expression) assert node_to_string(node) == expression