Ejemplo n.º 1
0
def test_loads():
    with open(TEST_FILE) as fp:
        string = fp.read()

    loaded = loads(string)

    assert loaded == expected
Ejemplo n.º 2
0
    def wrapper(*args, **kwargs):
        string, expect = f(*args, **kwargs)

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

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