class PreprocessLoaderTestCase(unittest.TestCase): """ Test the ``PreprocessLoader``. """ def setUp(self): from wheezy.template.loader import PreprocessLoader from wheezy.template.loader import DictLoader class Engine(object): def render(self, name, ctx, d1, d2): assert {'x': 1} == ctx return 'x' engine = Engine() engine.loader = DictLoader(templates={ 'tmpl1.html': 'x1', 'shared/master.html': 'x2' }) self.loader = PreprocessLoader(engine, {'x': 1}) def test_list_names(self): """ Tests list_names. """ assert ('shared/master.html', 'tmpl1.html') == self.loader.list_names() def test_load_existing(self): """ Tests load existing. """ assert 'x' == self.loader.load('tmpl1.html')
class PreprocessLoaderTestCase(unittest.TestCase): """Test the ``PreprocessLoader``.""" def setUp(self) -> None: templates = {"tmpl1.html": "x1", "shared/master.html": "x2"} engine = Engine( loader=DictLoader(templates=templates), extensions=[CoreExtension()], ) self.loader = PreprocessLoader(engine, {"x": 1}) def test_list_names(self) -> None: """Tests list_names.""" assert ("shared/master.html", "tmpl1.html") == self.loader.list_names() def test_load_existing(self) -> None: """Tests load existing.""" assert "x1" == self.loader.load("tmpl1.html")