Added common patterns for template file names to ignore when testing template parsing and template test coverage.

- Legacy-Id: 12354
This commit is contained in:
Henrik Levkowetz 2016-11-16 02:14:32 +00:00
parent 8fcbf7507e
commit 964d34282f
3 changed files with 21 additions and 1 deletions

View file

@ -392,6 +392,14 @@ TEST_CODE_COVERAGE_EXCLUDE = [
"ietf/utils/templatetags/debug_filters.py",
]
# These are filename globs. They are used by test_parse_templates() and
# get_template_paths()
TEST_TEMPLATE_IGNORE = [
".*", # dot-files
"*~", # tilde temp-files
"#*", # files beginning with a hashmark
]
TEST_COVERAGE_MASTER_FILE = os.path.join(BASE_DIR, "../release-coverage.json.gz")
TEST_COVERAGE_LATEST_FILE = os.path.join(BASE_DIR, "../latest-coverage.json")

View file

@ -46,6 +46,7 @@ import datetime
import codecs
import gzip
import unittest
from fnmatch import fnmatch
from coverage.report import Reporter
from coverage.results import Numbers
@ -161,7 +162,12 @@ def get_template_paths(apps=None):
dirs.remove(".svn")
relative_path = dirpath[len(templatepath)+1:]
for file in files:
if file.endswith("~") or file.startswith("#"):
ignore = False
for pattern in settings.TEST_TEMPLATE_IGNORE:
if fnmatch(file, pattern):
ignore = True
break
if ignore:
continue
if relative_path != "":
file = os.path.join(relative_path, file)

View file

@ -5,6 +5,7 @@ import shutil
from StringIO import StringIO
from pipe import pipe
from unittest import skipIf
from fnmatch import fnmatch
from textwrap import dedent
from email.mime.text import MIMEText
@ -103,6 +104,7 @@ def get_callbacks(urllist):
return list(callbacks)
debug.debug = True
class TemplateChecksTestCase(TestCase):
paths = []
@ -124,7 +126,11 @@ class TemplateChecksTestCase(TestCase):
def test_parse_templates(self):
errors = []
for path in self.paths:
for pattern in settings.TEST_TEMPLATE_IGNORE:
if fnmatch(path, pattern):
continue
if not path in self.templates:
try:
self.loader.load_template(path)
except Exception as e: