def test_multiple_strings_are_provided___result_is_join_by_join_str(
        join, elements):
    expected = join.join(elements)
    arg_elements = map(lambda o: f"'{o}'", elements)

    expr = f"join('{join}', {', '.join(arg_elements)})"
    assert run({}, expr) == expected
def test_multiple_objects_are_provided___result_is_join_by_join_str(
        join, elements):
    expected = join.join(map(str, elements))
    arg_elements = map(
        lambda o: f"'{o}'" if isinstance(o, str) else str(o),
        elements,
    )

    expr = f"join('{join}', {', '.join(arg_elements)})"
    assert run({}, expr) == expected
Exemple #3
0
def test_lookup_function_with_escaped_quote_returns_row_column_value(
    name_lhs, name_rhs, value
):
    assert (
        run(
            {f"{name_lhs}'{name_rhs}": value},
            rf"lookup('{name_lhs}`'{name_rhs}')",
        )
        == value
    )
Exemple #4
0
def test_list_is_parsed_correctly(values):
    assert run({}, f"[{', '.join(map(str, values))}]") == values
Exemple #5
0
def test_some_lhs_is_not_in_rhs___any_is_not_in_result_is_true():
    assert run({}, "any [1, 2] is not in [0, 2, 4]") is True
Exemple #6
0
def test_some_lhs_is_in_rhs___any_is_in_result_is_true():
    assert run({}, "any [1, 2, 3] is in [0, 1, 4]") is True
Exemple #7
0
def test_some_values_are_not_all_equal___any_is_result_is_true():
    assert run({}, "any [1, 0.9, 0.8] is 0.9") is True
Exemple #8
0
def test_some_values_are_gt_rhs___any_gte_result_is_true():
    assert run({}, "any [1, 0.8] gte 0.9") is True
Exemple #9
0
def test_some_values_are_gt_rhs___any_gt_result_is_true():
    assert run({}, "any [0.8, 1.1] gt 0.9") is True
Exemple #10
0
def test_some_values_are_eq_rhs___any_lte_result_is_true():
    assert run({}, "any [1, 0.9] lte 1") is True
Exemple #11
0
def test_string_addition(lhs, rhs):
    assert run({}, f"'{lhs}' + '{rhs}'") == lhs + rhs
Exemple #12
0
def test_int_addition(lhs, rhs):
    assert run({}, f"{lhs} + {rhs}") == lhs + rhs
def test_no_args_are_provided___error_is_raised():
    with pytest.raises(UnexpectedCharacters):
        run({}, "join()")
def test_no_strings_are_provided___result_is_empty():
    assert run({}, "join(', ')") == ""
Exemple #15
0
def test_regex_is_parsed_correctly(pattern):
    parsed = run({}, f"re'{pattern}'")

    assert isinstance(parsed, re.Pattern)
    assert parsed.pattern == pattern
    assert (parsed.flags & re.IGNORECASE) == 0
Exemple #16
0
def test_some_values_are_lt___any_lt_result_is_true():
    assert run({}, "any [1.1, 1, 0.9] lt 1") is True
Exemple #17
0
def test_all_values_are_gte___any_lt_result_is_false():
    assert run({}, "any [1.1, 1] lt 1") is False
Exemple #18
0
def test_int_subtraction(lhs, rhs):
    assert run({}, f"{lhs} - {rhs}") == lhs - rhs
Exemple #19
0
def test_all_values_are_gt_rhs___all_lte_result_is_false():
    assert run({}, "any [1.1, 1.2] lte 1") is False
Exemple #20
0
def test_int_multiplication(lhs, rhs):
    assert run({}, f"{lhs} * {rhs}") == lhs * rhs
Exemple #21
0
def test_all_values_are_equal___any_gt_result_is_false():
    assert run({}, "any [1, 1] gt 1") is False
Exemple #22
0
def test_int_division(lhs, rhs):
    assert run({}, f"{lhs} / {rhs}") == lhs / rhs
Exemple #23
0
def test_some_values_are_equal___any_gte_result_is_true():
    assert run({}, "any [1, 0.9] gte 1") is True
Exemple #24
0
def test_all_values_are_not_all_equal___any_is_result_is_false():
    assert run({}, "any [1, 0.8] is 0.9") is False
Exemple #25
0
def test_all_values_are_lt_rhs___any_gte_result_is_false():
    assert run({}, "any [1, 0.9] gte 1.1") is False
Exemple #26
0
def test_some_values_are_equal___any_is_not_result_is_true():
    assert run({}, "any [1.1, 1, 0.9] is not 1") is True
Exemple #27
0
def test_all_values_are_not_in_rhs___any_is_in_result_is_false():
    assert run({}, "any [0, 1, 5, 6] is in [2, 3, 4]") is False
Exemple #28
0
def test_all_values_are_lt_rhs___any_lt_result_is_true():
    assert run({}, "any [0.9, 0.8] lt 1") is True
Exemple #29
0
def test_all_values_are_in_rhs___any_is_not_in_result_is_false():
    assert run({}, "any [2, 4] is not in [0, 1, 2, 3, 4]") is False
Exemple #30
0
def test_values_are_all_equal___any_is_result_is_true():
    assert run({}, "any [1, 1] is 1") is True