Skip to content
Myr

Merge branch '3.1.x'

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 · parents e542e10, 7f66a58 · Browse files · 3 files+28 added−7 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+28 added−7 removed

  • tests:+12 added−4 removed
  • other:+16 added−3 removed

3 files+28 added−7 removed

modified:src/jinja2/loaders.py+7 added-3 removed
211 unmodified lines
212 return os.path.getmtime(filename) == mtime213 except OSError:214 return False215216 return contents, filename, uptodate216 # Use normpath to convert Windows altsep to sep.217 return contents, os.path.normpath(filename), uptodate218 raise TemplateNotFound(template)219220 def list_templates(self) -> t.List[str]:221 found = set()
108 unmodified lines
330 def get_source(331 self, environment: "Environment", template: str332 ) -> t.Tuple[str, str, t.Optional[t.Callable[[], bool]]]:333 # Use posixpath even on Windows to avoid "drive:" or UNC333 # segments breaking out of the search directory.334 p = posixpath.join(self._template_root, *split_template_path(template))334 # segments breaking out of the search directory. Use normpath to335 # convert Windows altsep to sep.336 p = os.path.normpath(337 posixpath.join(self._template_root, *split_template_path(template))338 )339 up_to_date: t.Optional[t.Callable[[], bool]]340341 if self._archive is None:342 # Package is a directory.
319 unmodified lines
modified:tests/test_loader.py+12 added-4 removed
1 unmodified line
2import importlib.machinery3import importlib.util4import os5import platform6import posixpath6import shutil7import sys8import tempfile9import time
160 unmodified lines
170 e = Environment(loader=loader)171 t = e.get_template("mojibake.txt")172 assert t.render() == expect173174 def test_filename_normpath(self):175 """Nested template names should only contain ``os.sep`` in the176 loaded filename.177 """178 loader = loaders.FileSystemLoader(self.searchpath)179 e = Environment(loader=loader)180 t = e.get_template("foo/test.html")181 assert t.filename == str(self.searchpath / "foo" / "test.html")182183184class TestModuleLoader:185 archive = None186187 def compile_down(self, prefix_loader, zip="deflated"):
123 unmodified lines
311)312def test_package_dir_source(package_dir_loader, template, expect):313 source, name, up_to_date = package_dir_loader.get_source(None, template)314 assert source.rstrip() == expect307 assert name.endswith(posixpath.join(*split_template_path(template)))315 assert name.endswith(os.path.join(*split_template_path(template)))316 assert up_to_date()317318319def test_package_dir_list(package_dir_loader):
13 unmodified lines
333)334def test_package_file_source(package_file_loader, template, expect):335 source, name, up_to_date = package_file_loader.get_source(None, template)336 assert source.rstrip() == expect329 assert name.endswith(posixpath.join(*split_template_path(template)))337 assert name.endswith(os.path.join(*split_template_path(template)))338 assert up_to_date()339340341def test_package_file_list(package_file_loader):
14 unmodified lines
356)357def test_package_zip_source(package_zip_loader, template, expect):358 source, name, up_to_date = package_zip_loader.get_source(None, template)359 assert source.rstrip() == expect352 assert name.endswith(posixpath.join(*split_template_path(template)))360 assert name.endswith(os.path.join(*split_template_path(template)))361 assert up_to_date is None362363364@pytest.mark.xfail(
48 unmodified lines
modified:CHANGES.rst+9 added
4 unmodified lines
56Unreleased789Version 3.1.110-------------1112Released 2022-03-251314- The template filename on Windows uses the primary path separator.15 :issue:`1637`161718Version 3.1.019-------------2021Released 2022-03-24
950 unmodified lines