test: check if created python files are parsable

This commit is contained in:
Ankush Menat 2021-05-07 10:34:46 +05:30
parent 835ed181b5
commit e9a3569bf7
No known key found for this signature in database
GPG key ID: 8EA82E09BBD13AAF

View file

@ -1,3 +1,5 @@
import ast
import glob
import os
import shutil
import unittest
@ -74,3 +76,13 @@ class TestBoilerPlate(unittest.TestCase):
for path in all_paths:
self.assertTrue(os.path.exists(path), msg=f"{path} should exist in new app")
# check if python files are parsable
python_files = glob.glob(new_app_dir + "**/*.py", recursive=True)
for python_file in python_files:
with open(python_file) as p:
try:
ast.parse(p.read())
except Exception as e:
self.fail(f"Can't parse python file in new app: {python_file}\n" + str(e))