Ejemplo n.º 1
0
 def test_without_substituting_gettext_with_lambda_extending_file(self):
     # this should use i18n.gettext
     loader = FileLoader(path=os.path.join(os.path.dirname(__file__),
                         'data'))
     tpl = loader.import_('file_child.html')
     rsp = tpl(dict()).render()
     assert rsp == '''<div>parent</div><div>child</div>''', rsp
Ejemplo n.º 2
0
 def test_without_substituting_gettext_with_lambda_extending_file(self):
     # this should use i18n.gettext
     loader = FileLoader(
         path=os.path.join(os.path.dirname(__file__), "data"))
     tpl = loader.import_("file_child.html")
     rsp = tpl(dict()).render()
     assert rsp == """<div>parent</div><div>child</div>""", rsp
Ejemplo n.º 3
0
 def test_substituting_gettext_with_lambda_extending_file(self):
     loader = FileLoader(path=os.path.join(os.path.dirname(__file__),
                                           'data'),
                         base_globals=dict(gettext=lambda x: 'egg'))
     tpl = loader.import_('file_child.html')
     rsp = tpl(dict()).render()
     assert rsp == '''<div>egg</div><div>egg</div>''', rsp
Ejemplo n.º 4
0
 def test_substituting_gettext_with_lambda_extending_file(self):
     loader = FileLoader(
         path=os.path.join(os.path.dirname(__file__), "data"),
         base_globals=dict(gettext=lambda x: "egg"),
     )
     tpl = loader.import_("file_child.html")
     rsp = tpl(dict()).render()
     assert rsp == """<div>egg</div><div>egg</div>""", rsp
Ejemplo n.º 5
0
 def test_debug(self):
     loader = FileLoader(base=os.path.join(os.path.dirname(__file__), 'data'))
     tpl = loader.import_('debug.html')
     try:
         tpl().render()
         assert False, 'Should have raised ValueError'
     except ValueError:
         exc_info = sys.exc_info()
         stack = traceback.extract_tb(exc_info[2])
     # Verify we have stack trace entries in the template
     for fn, lno, func, line in stack:
         if fn.endswith('debug.html'): break
     else:
         assert False, 'Stacktrace is all python'
Ejemplo n.º 6
0
 def test_debug(self):
     loader = FileLoader(
         path=os.path.join(os.path.dirname(__file__), 'data'))
     tpl = loader.import_('debug.html')
     try:
         tpl().render()
         assert False, 'Should have raised ValueError'
     except ValueError:
         exc_info = sys.exc_info()
         stack = traceback.extract_tb(exc_info[2])
     # Verify we have stack trace entries in the template
     for fn, lno, func, line in stack:
         if fn.endswith('debug.html'):
             break
     else:
         assert False, 'Stacktrace is all python'
Ejemplo n.º 7
0
 def test_debug(self):
     loader = FileLoader(path=os.path.join(os.path.dirname(__file__), "data"))
     tpl = loader.import_("debug.txt")
     try:
         tpl().render()
     except ValueError:
         exc_info = sys.exc_info()
         stack = traceback.extract_tb(exc_info[2])
     else:
         assert False, "Should have raised ValueError"
     # Verify we have stack trace entries in the template
     for fn, lno, func, line in stack:
         if fn.endswith("debug.txt"):
             break
     else:
         assert False, "Stacktrace is all python"
Ejemplo n.º 8
0
 def test_substituting_gettext_with_lambda_extending_file(self):
     loader = FileLoader(path=os.path.join(os.path.dirname(__file__),
                         'data'), base_globals=dict(gettext=lambda x: 'egg'))
     tpl = loader.import_('file_child.html')
     rsp = tpl(dict()).render()
     assert rsp == '''<div>egg</div><div>egg</div>''', rsp