예제 #1
0
def test_args():
    expected = (1, 2)
    actual = eval_value("1, 2")

    assert actual == expected
    assert isinstance(actual[0], int)
    assert isinstance(actual[1], int)
예제 #2
0
def test_args_with_nested_dict():
    expected = (1, {"2": {"3": 4}})
    actual = eval_value("1, {'2': { '3': 4 }}")

    assert actual == expected
    assert isinstance(actual[1], dict)
    assert isinstance(actual[1].get("2"), dict)
예제 #3
0
def test_args_with_single_quote_dict():
    expected = (1, {"2": 3})
    actual = eval_value("1, {'2': 3}")

    assert actual == expected
    assert isinstance(actual[1], dict)
예제 #4
0
def test_double_quote_str_arg():
    expected = "string"
    actual = eval_value('"string"')

    assert actual == expected
    assert isinstance(actual, str)
예제 #5
0
def test_str_with_stop_character():
    expected = "'a'} b'"
    actual = eval_value("'a'} b'")

    assert actual == expected
    assert isinstance(actual[0], str)
예제 #6
0
def test_str_with_comma():
    expected = "'a', b'"
    actual = eval_value("'a', b'")

    assert actual == expected
    assert isinstance(actual[0], str)
예제 #7
0
def test_str_with_extra_double_quote():
    expected = 'django "unicorn"'
    actual = eval_value("'django \"unicorn\"'")

    assert actual == expected
    assert isinstance(actual[0], str)
예제 #8
0
def test_args_with_nested_objects():
    expected = ([0, 1], {"2 2": {"3": 4}}, (5, 6, [7, 8]))
    actual = eval_value("[0,  1], {'2 2': { '3': 4 }}, (5, 6, [7, 8])")

    assert actual == expected
예제 #9
0
def test_single_quote_str_arg():
    expected = "1"
    actual = eval_value("'1'")

    assert actual == expected
    assert isinstance(actual, str)
예제 #10
0
def test_set():
    expected = {1, 5}
    actual = eval_value("{1, 5}")

    assert actual == expected
    assert isinstance(actual, set)
예제 #11
0
def test_float():
    expected = [1, 5.4]
    actual = eval_value("[1, 5.4]")

    assert actual == expected
    assert isinstance(actual[1], float)
예제 #12
0
def test_uuid():
    expected = UUID("90144cb9-fc47-476d-b124-d543b0cff091")
    actual = eval_value("90144cb9-fc47-476d-b124-d543b0cff091")

    assert actual == expected
    assert isinstance(actual, UUID)
예제 #13
0
def test_datetime():
    expected = datetime(2020, 9, 12, 1, 1, 1)
    actual = eval_value("2020-09-12T01:01:01")

    assert actual == expected
    assert isinstance(actual, datetime)
예제 #14
0
def test_list_args():
    expected = (1, [2, "3"])
    actual = eval_value("1, [2, '3']")

    assert actual == expected
예제 #15
0
def test_str_with_space_arg():
    expected = "django unicorn"
    actual = eval_value("'django unicorn'")

    assert actual == expected
    assert isinstance(actual, str)
예제 #16
0
def test_args_with_double_quote_dict():
    expected = (1, {"2": 3})
    actual = eval_value('1, {"2": 3}')

    assert actual == expected
    assert isinstance(actual[1], dict)
예제 #17
0
def test_str_with_extra_single_quote():
    expected = "django's unicorn"
    actual = eval_value("'django\\'s unicorn'")

    assert actual == expected
    assert isinstance(actual, str)
예제 #18
0
def test_args_with_nested_list_3():
    expected = ([1, ["2", "3"], 4], 9)
    actual = eval_value("[1, ['2', '3'], 4], 9")

    assert actual == expected
예제 #19
0
def test_args_with_nested_tuple():
    expected = (9, (1, ("2", "3"), 4))
    actual = eval_value("9, (1, ('2', '3'), 4)")

    assert actual == expected