def main(verbose): basenames = [ "test_template", "test_engine", "test_preprocessor", "test_safe", "test_htmlhelper", "test_main", "test_encoding", "test_loader", "test_store", "test_gae", "test_tenjin", "test_users_guide", "test_examples", ] #filenames = glob.glob(os.path.dirname(__file__) + '/test_*.py') #assert len(filenames) - 1 == len(basenames) if python3: basenames.remove("test_encoding") basenames.remove("test_gae") if python2 and sys.version_info[1] <= 4: basenames.remove("test_gae") if verbose: for basename in basenames: print('') print("************************************************* " + basename) os.system("%s %s.py" % (sys.executable, basename)) else: #import unittest #from oktest import ok, not_ok #suite = unittest.TestSuite() #for basename in basenames: # test_module = __import__(basename) # suite.addTest(unittest.findTestCases(test_module)) # #unittest.TextTestRunner(verbosity=1).run(suite) ##unittest.TextTestRunner(verbosity=2).run(test_template.TemplateTest) test_classes = [] for basename in basenames: test_module = __import__(basename) for x in dir(test_module): if x.endswith('Test'): klass = getattr(test_module, x) if type(klass) == type: test_classes.append(klass) import oktest kwd = {'style': 'simple'} oktest.run(*test_classes, **kwd)
### ### $Release: 1.1.1 $ ### $Copyright: copyright(c) 2007-2012 kuwata-lab.com all rights reserved. $ ### from oktest import ok, not_ok, run, spec from oktest.helper import dummy_file import sys, os, re import tenjin from tenjin.helpers import * class TenjinTest(object): pass if __name__ == '__main__': run()
#!/usr/bin/env python # -*- coding: utf-8 -*- import logging from test_popit import * from test_mapit import * __author__ = 'guglielmo' # log format (if used in tests) FORMAT = "[PCI | %(levelname)s] %(message)s" logging.basicConfig(level = logging.WARN, format=FORMAT) ## invoke tests if __name__ == '__main__': import oktest oktest.run(r'.*Test$')
if spec("kwargs are removed from context data."): pass def test_hook_context(self): e = tenjin.Engine() ctx = {} e.hook_context(ctx) if spec("add engine itself into context data."): ok (ctx.get('_engine')).is_(e) if spec("add include() method into context data."): ok (ctx.get('include')) == (e.include) @test("get_template(): ignores syntax error when compiling.") def _(self): input = """<p>${{foo}</p>""" fname = "tmp_999.pyhtml" f = open(fname, 'w'); f.write(input); f.close() try: e = tenjin.Engine() def fn(): e.get_template(fname) ok (fn).not_raise(SyntaxError) finally: for x in glob(fname + '*'): os.unlink(x) _DUMMY_VALUE = 'SOS' if __name__ == '__main__': run(EngineTest)