File: test_file_python_errors.py

package info (click to toggle)
parso 0.8.6-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,264 kB
  • sloc: python: 10,983; makefile: 135
file content (23 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (5)
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