Skip to content
Myr

clean up message, add test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent ed5f762 · Browse files · 3 files+24 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+24 added−4 removed

  • tests:+18 added−0 removed
  • other:+6 added−4 removed

3 files+24 added−4 removed

modified:src/jinja2/loaders.py+4 added-2 removed
202 unmodified lines
203204 if os.path.isfile(filename):205 break206 else:207 plural = "path" if len(self.searchpath) == 1 else "paths"208 paths_str = ", ".join(repr(p) for p in self.searchpath)209 raise TemplateNotFound(208 f"{template} not found in the following search path(s):"209 f" {self.searchpath}"210 template,211 f"{template!r} not found in search {plural}: {paths_str}",212 )213214 with open(filename, encoding=self.encoding) as f:215 contents = f.read()
474 unmodified lines
modified:tests/test_loader.py+18 added
177 unmodified lines
178 e = Environment(loader=loader)179 t = e.get_template("foo/test.html")180 assert t.filename == str(self.searchpath / "foo" / "test.html")181182 def test_error_includes_paths(self, env, filesystem_loader):183 env.loader = filesystem_loader184185 with pytest.raises(TemplateNotFound) as info:186 env.get_template("missing")187188 e_str = str(info.value)189 assert e_str.startswith("'missing' not found in search path: ")190191 filesystem_loader.searchpath.append("other")192193 with pytest.raises(TemplateNotFound) as info:194 env.get_template("missing")195196 e_str = str(info.value)197 assert e_str.startswith("'missing' not found in search paths: ")198 assert ", 'other'" in e_str199200201class TestModuleLoader:202 archive = None203 mod_env = None204
227 unmodified lines
modified:CHANGES.rst+2 added-2 removed
33 unmodified lines
34 objects. :issue:`2025`35- Fix `copy`/`pickle` support for the internal ``missing`` object.36 :issue:`2027`37- ``Environment.overlay(enable_async)`` is applied correctly. :pr:`2061`38- Paths where the loader searched for the template were added39 to the error message. :issue:`1661`38- The error message from ``FileSystemLoader`` includes the paths that were39 searched. :issue:`1661`404142Version 3.1.443-------------
994 unmodified lines