示例#1
0
def test_correctness(subtests, tests_path):
    for path in tests_path.glob('**/*.config'):
        with subtests.test(path=path):
            with open(path, 'r') as file:
                parents, scope = parse_string(file.read(), '.config')
                if not parents:
                    Semantics(scope, set(vars(builtins))).check()
示例#2
0
def standardize(source):
    parents, scope = parse_string(source, '.config')
    result = '\n'.join(f'from {"." * imp.dots}{".".join(imp.root)} import *'
                       for imp in parents) + '\n'
    return result + '\n'.join(
        render_scope(scope, {v: i
                             for i, v in enumerate(scope)})) + '\n'
示例#3
0
def validate_config(source: str):
    parents, scope = parse_string(source, '.config')
    assert not parents
    Semantics(scope, set(vars(builtins))).check()
示例#4
0
def test_unrecognized_token():
    with pytest.raises(SyntaxError):
        parse_string('$', '.config')
示例#5
0
def test_unexpected_eof():
    with pytest.raises(SyntaxError):
        parse_string('a = [1, 2', '.config')