summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2021-11-09 12:14:48 -0800
committerDavid Lord <davidism@gmail.com>2021-11-09 12:18:53 -0800
commiteec0db8642b25691867890f14fc6c9ca04c8a8c9 (patch)
tree2e561e32b5a0e391adb141c56e676ca1223c7ee5 /tests
parent46f3a68183c2eca8865195f3988f9baf4ec551eb (diff)
downloadjinja2-eec0db8642b25691867890f14fc6c9ca04c8a8c9.tar.gz
PackageLoader works with single module file
Diffstat (limited to 'tests')
-rw-r--r--tests/test_loader.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_loader.py b/tests/test_loader.py
index 1533d02..b300c8f 100644
--- a/tests/test_loader.py
+++ b/tests/test_loader.py
@@ -314,6 +314,28 @@ def test_package_dir_list(package_dir_loader):
@pytest.fixture()
+def package_file_loader(monkeypatch):
+ monkeypatch.syspath_prepend(Path(__file__).parent / "res")
+ return PackageLoader("__init__")
+
+
+@pytest.mark.parametrize(
+ ("template", "expect"), [("foo/test.html", "FOO"), ("test.html", "BAR")]
+)
+def test_package_file_source(package_file_loader, template, expect):
+ source, name, up_to_date = package_file_loader.get_source(None, template)
+ assert source.rstrip() == expect
+ assert name.endswith(os.path.join(*split_template_path(template)))
+ assert up_to_date()
+
+
+def test_package_file_list(package_file_loader):
+ templates = package_file_loader.list_templates()
+ assert "foo/test.html" in templates
+ assert "test.html" in templates
+
+
+@pytest.fixture()
def package_zip_loader(monkeypatch):
package_zip = (Path(__file__) / ".." / "res" / "package.zip").resolve()
monkeypatch.syspath_prepend(package_zip)