Removed spurious static_path.
[smonitor.git] / monitor / jinja2 / testsuite / __init__.py
blob1f10ef68141971c873c5a04a93cfc97b7a93b4ea
1 # -*- coding: utf-8 -*-
2 """
3 jinja2.testsuite
4 ~~~~~~~~~~~~~~~~
6 All the unittests of Jinja2. These tests can be executed by
7 either running run-tests.py using multiple Python versions at
8 the same time.
10 :copyright: (c) 2010 by the Jinja Team.
11 :license: BSD, see LICENSE for more details.
12 """
13 import os
14 import re
15 import sys
16 import unittest
17 from traceback import format_exception
18 from jinja2 import loaders
21 here = os.path.dirname(os.path.abspath(__file__))
23 dict_loader = loaders.DictLoader({
24 'justdict.html': 'FOO'
26 package_loader = loaders.PackageLoader('jinja2.testsuite.res', 'templates')
27 filesystem_loader = loaders.FileSystemLoader(here + '/res/templates')
28 function_loader = loaders.FunctionLoader({'justfunction.html': 'FOO'}.get)
29 choice_loader = loaders.ChoiceLoader([dict_loader, package_loader])
30 prefix_loader = loaders.PrefixLoader({
31 'a': filesystem_loader,
32 'b': dict_loader
36 class JinjaTestCase(unittest.TestCase):
38 ### use only these methods for testing. If you need standard
39 ### unittest method, wrap them!
41 def setup(self):
42 pass
44 def teardown(self):
45 pass
47 def setUp(self):
48 self.setup()
50 def tearDown(self):
51 self.teardown()
53 def assert_equal(self, a, b):
54 return self.assertEqual(a, b)
56 def assert_raises(self, *args, **kwargs):
57 return self.assertRaises(*args, **kwargs)
59 def assert_traceback_matches(self, callback, expected_tb):
60 try:
61 callback()
62 except Exception, e:
63 tb = format_exception(*sys.exc_info())
64 if re.search(expected_tb.strip(), ''.join(tb)) is None:
65 raise self.fail('Traceback did not match:\n\n%s\nexpected:\n%s'
66 % (''.join(tb), expected_tb))
67 else:
68 self.fail('Expected exception')
71 def suite():
72 from jinja2.testsuite import ext, filters, tests, core_tags, \
73 loader, inheritance, imports, lexnparse, security, api, \
74 regression, debug, utils, doctests
75 suite = unittest.TestSuite()
76 suite.addTest(ext.suite())
77 suite.addTest(filters.suite())
78 suite.addTest(tests.suite())
79 suite.addTest(core_tags.suite())
80 suite.addTest(loader.suite())
81 suite.addTest(inheritance.suite())
82 suite.addTest(imports.suite())
83 suite.addTest(lexnparse.suite())
84 suite.addTest(security.suite())
85 suite.addTest(api.suite())
86 suite.addTest(regression.suite())
87 suite.addTest(debug.suite())
88 suite.addTest(utils.suite())
90 # doctests will not run on python 3 currently. Too many issues
91 # with that, do not test that on that platform.
92 if sys.version_info < (3, 0):
93 suite.addTest(doctests.suite())
95 return suite