changeset 36975:452696bf3e60

test-template-engine: deduplicate methods of custom template engine
author Yuya Nishihara <yuya@tcha.org>
date Thu, 15 Mar 2018 20:10:54 +0900
parents 2090044a288d
children e55d80804ace
files tests/test-template-engine.t
diffstat 1 files changed, 4 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-template-engine.t	Thu Jan 18 15:10:22 2018 +0100
+++ b/tests/test-template-engine.t	Thu Mar 15 20:10:54 2018 +0900
@@ -6,23 +6,12 @@
   >     templateutil,
   > )
   > 
-  > class mytemplater(object):
-  >     def __init__(self, loader, filters, defaults, resources, aliases):
-  >         self.loader = loader
-  >         self._defaults = defaults
-  >         self._resources = resources
-  > 
-  >     def symbol(self, mapping, key):
-  >         return mapping[key]
-  > 
-  >     def resource(self, mapping, key):
-  >         v = self._resources[key]
-  >         if v is None:
-  >             v = mapping[key]
-  >         return v
+  > class mytemplater(templater.engine):
+  >     def _load(self, t):
+  >         return self._loader(t)
   > 
   >     def process(self, t, map):
-  >         tmpl = self.loader(t)
+  >         tmpl = self._load(t)
   >         props = self._defaults.copy()
   >         props.update(map)
   >         for k, v in props.items():