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:
parent
8fcbf7507e
commit
964d34282f
|
@ -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")
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue