Example #1
0
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)
Example #2
0
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
Example #3
0
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'})
Example #4
0
def test_unary_ops(op):
    expression = f'{op["code"]}a'
    node = parse_expression(expression)
    assert node_to_string(node) == expression