3
3
import importlib .util
4
4
import os
5
5
import platform
6
- import posixpath
7
6
import shutil
8
7
import sys
9
8
import tempfile
@@ -172,6 +171,15 @@ def test_uses_specified_encoding(self, encoding, expect):
172
171
t = e .get_template ("mojibake.txt" )
173
172
assert t .render () == expect
174
173
174
+ def test_filename_normpath (self ):
175
+ """Nested template names should only contain ``os.sep`` in the
176
+ 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" )
182
+
175
183
176
184
class TestModuleLoader :
177
185
archive = None
@@ -304,7 +312,7 @@ def package_dir_loader(monkeypatch):
304
312
def test_package_dir_source (package_dir_loader , template , expect ):
305
313
source , name , up_to_date = package_dir_loader .get_source (None , template )
306
314
assert source .rstrip () == expect
307
- assert name .endswith (posixpath .join (* split_template_path (template )))
315
+ assert name .endswith (os . path .join (* split_template_path (template )))
308
316
assert up_to_date ()
309
317
310
318
@@ -326,7 +334,7 @@ def package_file_loader(monkeypatch):
326
334
def test_package_file_source (package_file_loader , template , expect ):
327
335
source , name , up_to_date = package_file_loader .get_source (None , template )
328
336
assert source .rstrip () == expect
329
- assert name .endswith (posixpath .join (* split_template_path (template )))
337
+ assert name .endswith (os . path .join (* split_template_path (template )))
330
338
assert up_to_date ()
331
339
332
340
@@ -349,7 +357,7 @@ def package_zip_loader(monkeypatch):
349
357
def test_package_zip_source (package_zip_loader , template , expect ):
350
358
source , name , up_to_date = package_zip_loader .get_source (None , template )
351
359
assert source .rstrip () == expect
352
- assert name .endswith (posixpath .join (* split_template_path (template )))
360
+ assert name .endswith (os . path .join (* split_template_path (template )))
353
361
assert up_to_date is None
354
362
355
363
0 commit comments