def test_path(self): template = PageTemplateFile("path.pt") class Context(object): dummy_wysiwyg_support = True context = Context() template = template.__get__(context, Context) result = template(editor="dummy") self.assertTrue("supported" in result) self.assertTrue("some path" in result)
def load_template(name, context=None, _memo={}): ''' load the main template ''' if name not in _memo: tpl = PageTemplateFile(name) if context is not None: bound = tpl.bind(context) _memo[name] = bound else: _memo[name] = tpl return _memo[name]
def test_path(self): from z3c.pt.pagetemplate import PageTemplateFile template = PageTemplateFile("path.pt") class Context(object): dummy_wysiwyg_support = True context = Context() template = template.__get__(context, Context) result = template(editor="dummy") self.failUnless("supported" in result) self.failUnless("some path" in result)
def test_exists(self): from z3c.pt.pagetemplate import PageTemplateFile template = PageTemplateFile("exists.pt") def dont_call(): raise RuntimeError() result = template(callable=dont_call) self.failUnless('ok' in result)
def test_nocall(self): from z3c.pt.pagetemplate import PageTemplateFile template = PageTemplateFile("nocall.pt") def dont_call(): raise RuntimeError() result = template(callable=dont_call) self.failUnless(repr(dont_call) in result)
def test_exists(self): template = PageTemplateFile("exists.pt") def dont_call(): raise AssertionError("Should not be called") result = template(callable=dont_call) self.assertTrue("ok" in result)
def test_nocall(self): template = PageTemplateFile("nocall.pt") def dont_call(): raise AssertionError("Should not be called") result = template(callable=dont_call) self.assertTrue(repr(dont_call) in result)
class z3cPageTemplate(grok.components.GrokTemplate): def setFromString(self, string): self._template = PageTemplate(string) def setFromFilename(self, filename, _prefix=None): filename = os.path.join(_prefix, filename) self._template = PageTemplateFile(filename) def render(self, view): return self._template.render(**self.getNamespace(view))
def test_boolean_attribute(self): from z3c.pt.pagetemplate import PageTemplateFile template = PageTemplateFile("boolean.pt") result = template() self.failIf('False' in result) self.failUnless('checked="checked"' in result)
def test_false_attribute(self): from z3c.pt.pagetemplate import PageTemplateFile template = PageTemplateFile("false.pt") result = template() self.failUnless('False' in result)
actions['callgrind'] = '' if config.profiling.memory_profile_log: actions['memory_profile_start'] = (memory(), resident()) if actions: if 'sql' in actions: condition = actions['sql'] if condition not in (True, False): condition = condition['condition'] da.start_sql_logging(condition) if 'show' in actions or available_profilers.intersection(actions): _profilers.profiler = Profiler() _profilers.profiler.start() _profilers.profiling = True _profilers.actions = actions template = PageTemplateFile( os.path.join(os.path.dirname(__file__), 'profile.pt')) available_profilers = frozenset(('pstats', 'callgrind')) def start(): """Turn on profiling from code. """ actions = _profilers.actions profiler = _profilers.profiler if actions is None: actions = _profilers.actions = {} _profilers.profiling = True elif 'inline' not in actions and ( 'show' in actions or available_profilers.intersection(actions)):
def test_boolean_attribute(self): template = PageTemplateFile("boolean.pt") result = template() self.assertFalse("False" in result) self.assertTrue('checked="checked"' in result)
def test_false_attribute(self): template = PageTemplateFile("false.pt") result = template() self.assertTrue("False" in result)
def setFromFilename(self, filename, _prefix=None): filename = os.path.join(_prefix, filename) self._template = PageTemplateFile(filename)
def setFromString(self, string): self._template = PageTemplate(string)