- TemplateLookup raises TopLevelLookupException for a given path that is a directory, not a filename, instead of passing through to the template to generate IOError. [ticket:73]
diff --git a/CHANGES b/CHANGES index eb38534..7f7d0a9 100644 --- a/CHANGES +++ b/CHANGES
@@ -50,6 +50,11 @@ drive etc.) and no URI - the URI is converted to a forward-slash path and module_directory is treated as a windows path. [ticket:128] + +- TemplateLookup raises TopLevelLookupException for + a given path that is a directory, not a filename, + instead of passing through to the template to + generate IOError. [ticket:73] 0.2.6
diff --git a/mako/lookup.py b/mako/lookup.py index 0398c5e..8514a8a 100644 --- a/mako/lookup.py +++ b/mako/lookup.py
@@ -107,7 +107,7 @@ u = re.sub(r'^\/+', '', uri) for dir in self.directories: srcfile = posixpath.normpath(posixpath.join(dir, u)) - if os.path.exists(srcfile): + if os.path.isfile(srcfile): return self._load(srcfile, uri) else: raise exceptions.TopLevelLookupException(
diff --git a/test/test_lookup.py b/test/test_lookup.py index 4d6644d..5e6cb24 100644 --- a/test/test_lookup.py +++ b/test/test_lookup.py
@@ -29,6 +29,13 @@ "this is include 2" ] + + def test_directory_lookup(self): + """test that hitting an existent directory still raises LookupError.""" + + self.assertRaises(exceptions.TopLevelLookupException, + tl.get_template, "/subdir" + ) def test_no_lookup(self): t = Template("hi <%include file='foo.html'/>")