示例#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
示例#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
示例#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
示例#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
示例#5
0
文件: test_xml.py 项目: gdrius/kajiki
 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'
示例#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'
示例#7
0
文件: test_text.py 项目: ollyc/kajiki
 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"
示例#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