aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/parso/py3/tests/test_file_python_errors.py
blob: 7083dfeb46745cf8db04c30513f848d7f673e593 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os

import parso


def get_python_files(path):
    for dir_path, dir_names, file_names in os.walk(path):
        for file_name in file_names:
            if file_name.endswith('.py'):
                yield os.path.join(dir_path, file_name)


def test_on_itself(each_version):
    """
    There are obviously no syntax erros in the Python code of parso. However
    parso should output the same for all versions.
    """
    grammar = parso.load_grammar(version=each_version)
    path = os.path.dirname(os.path.dirname(__file__)) + '/parso'
    for file in get_python_files(path):
        tree = grammar.parse(path=file)
        errors = list(grammar.iter_errors(tree))
        assert not errors