Skip to content

Instantly share code, notes, and snippets.

@jleclanche
Created March 13, 2018 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jleclanche/6e3ed8d7a0ddcc255a0e0d89a928e383 to your computer and use it in GitHub Desktop.
Save jleclanche/6e3ed8d7a0ddcc255a0e0d89a928e383 to your computer and use it in GitHub Desktop.
# License: CC0
# https://creativecommons.org/publicdomain/zero/1.0/
# https://creativecommons.org/share-your-work/public-domain/cc0/
import os
from django.template import Template
def test_compile_templates(settings):
for template_dir in settings.TEMPLATES[0]["DIRS"]:
for basepath, dirs, filenames in os.walk(template_dir):
for filename in filenames:
path = os.path.join(basepath, filename)
with open(path, "r") as f:
# This will fail if the template cannot compile
t = Template(f.read())
assert t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment