test_file_python_errors.py 702 B

1234567891011121314151617181920212223
  1. import os
  2. import parso
  3. def get_python_files(path):
  4. for dir_path, dir_names, file_names in os.walk(path):
  5. for file_name in file_names:
  6. if file_name.endswith('.py'):
  7. yield os.path.join(dir_path, file_name)
  8. def test_on_itself(each_version):
  9. """
  10. There are obviously no syntax erros in the Python code of parso. However
  11. parso should output the same for all versions.
  12. """
  13. grammar = parso.load_grammar(version=each_version)
  14. path = os.path.dirname(os.path.dirname(__file__)) + '/parso'
  15. for file in get_python_files(path):
  16. tree = grammar.parse(path=file)
  17. errors = list(grammar.iter_errors(tree))
  18. assert not errors