Пример #1
0
def test_loads():
    with open(TEST_FILE) as fp:
        string = fp.read()

    loaded = loads(string)

    assert loaded == expected
Пример #2
0
    def wrapper(*args, **kwargs):
        string, expect = f(*args, **kwargs)

        assert loads(string) == expect
Пример #3
0
def test_string_escaped():
    assert (loads('escaped = "this ""string"" is ""escaped"".";') == {
        'escaped': 'this "string" is "escaped".'
    })
Пример #4
0
def test_array_oned():
    assert loads('oned[] = {1, two, 3, "4", 5 six seven};') == {
        'oned': [1, 'two', 3, 4, '5 six seven']
    }
Пример #5
0
def test_string_unquoted():
    assert loads('unquoted = unquoted string;') == {
        'unquoted': 'unquoted string'
    }
Пример #6
0
def test_string_joined():
    assert (
        loads('joined = unquoted and "quoted" strings "joined" together;') == {
            'joined': 'unquoted and quoted strings joined together'
        })
Пример #7
0
def test_array_symbol():
    with pytest.raises(Unexpected):
        loads('array[] = 1;')

    assert loads('string = {"array"};') == {'string': '{array}'}
Пример #8
0
def test_string_quoted():
    assert loads('quoted = "quoted string";') == {'quoted': 'quoted string'}
Пример #9
0
def test_array_multi():
    assert loads('multi[] = {1, {2, 3}, {{4, 5, 6 seven, {}}}};') == {
        'multi': [1, [2, 3], [[4, 5, "6 seven", []]]]
    }
Пример #10
0
def test_missing_eq():
    with pytest.raises(UnexpectedValue):
        loads('prop } "3";')
Пример #11
0
def test_array_opener():
    with pytest.raises(UnexpectedValue):
        loads('array[] = [2, 1};')
Пример #12
0
def test_class_closer():
    with pytest.raises(UnexpectedType):
        loads('class test {property = 3;];')
Пример #13
0
def test_class_opener():
    with pytest.raises(UnexpectedValue):
        loads('class test [property = 3;};')