Self test on parsos files to check if there's no syntax errors.

This commit is contained in:
Dave Halter
2017-08-05 23:39:44 +02:00
parent db3c635fcd
commit 0e3e393f37
2 changed files with 28 additions and 2 deletions

View File

@@ -0,0 +1,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_parso_files(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(tree._iter_errors(grammar))
assert not errors