Skip to content

Commit 964d342

Browse files
committed
Added common patterns for template file names to ignore when testing template parsing and template test coverage.
- Legacy-Id: 12354
1 parent 8fcbf75 commit 964d342

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

ietf/settings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,14 @@ def skip_unreadable_post(record):
392392
"ietf/utils/templatetags/debug_filters.py",
393393
]
394394

395+
# These are filename globs. They are used by test_parse_templates() and
396+
# get_template_paths()
397+
TEST_TEMPLATE_IGNORE = [
398+
".*", # dot-files
399+
"*~", # tilde temp-files
400+
"#*", # files beginning with a hashmark
401+
]
402+
395403
TEST_COVERAGE_MASTER_FILE = os.path.join(BASE_DIR, "../release-coverage.json.gz")
396404
TEST_COVERAGE_LATEST_FILE = os.path.join(BASE_DIR, "../latest-coverage.json")
397405

ietf/utils/test_runner.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import codecs
4747
import gzip
4848
import unittest
49+
from fnmatch import fnmatch
4950

5051
from coverage.report import Reporter
5152
from coverage.results import Numbers
@@ -161,7 +162,12 @@ def get_template_paths(apps=None):
161162
dirs.remove(".svn")
162163
relative_path = dirpath[len(templatepath)+1:]
163164
for file in files:
164-
if file.endswith("~") or file.startswith("#"):
165+
ignore = False
166+
for pattern in settings.TEST_TEMPLATE_IGNORE:
167+
if fnmatch(file, pattern):
168+
ignore = True
169+
break
170+
if ignore:
165171
continue
166172
if relative_path != "":
167173
file = os.path.join(relative_path, file)

ietf/utils/tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from StringIO import StringIO
66
from pipe import pipe
77
from unittest import skipIf
8+
from fnmatch import fnmatch
89

910
from textwrap import dedent
1011
from email.mime.text import MIMEText
@@ -103,6 +104,7 @@ def get_callbacks(urllist):
103104

104105
return list(callbacks)
105106

107+
debug.debug = True
106108
class TemplateChecksTestCase(TestCase):
107109

108110
paths = []
@@ -124,7 +126,11 @@ def tearDown(self):
124126
def test_parse_templates(self):
125127
errors = []
126128
for path in self.paths:
129+
for pattern in settings.TEST_TEMPLATE_IGNORE:
130+
if fnmatch(path, pattern):
131+
continue
127132
if not path in self.templates:
133+
128134
try:
129135
self.loader.load_template(path)
130136
except Exception as e:

0 commit comments

Comments
 (0)