c0327c1b2e523d901895b9263f912853ca38e66a
[jinja2.git] / jinja2 / testsuite / __init__.py
1 # -*- coding: utf-8 -*-
2 """
3     jinja2.testsuite
4     ~~~~~~~~~~~~~~~~
5
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.
9
10     :copyright: (c) 2010 by the Jinja Team.
11     :license: BSD, see LICENSE for more details.
12 """
13 import os
14 import sys
15 import unittest
16 from jinja2 import loaders
17
18
19 here = os.path.dirname(os.path.abspath(__file__))
20
21 dict_loader = loaders.DictLoader({
22     'justdict.html':        'FOO'
23 })
24 package_loader = loaders.PackageLoader('jinja2.testsuite.res', 'templates')
25 filesystem_loader = loaders.FileSystemLoader(here + 'res/templates')
26 function_loader = loaders.FunctionLoader({'justfunction.html': 'FOO'}.get)
27 choice_loader = loaders.ChoiceLoader([dict_loader, package_loader])
28 prefix_loader = loaders.PrefixLoader({
29     'a':        filesystem_loader,
30     'b':        dict_loader
31 })
32
33
34 class JinjaTestCase(unittest.TestCase):
35
36     ### use only these methods for testing.  If you need standard
37     ### unittest method, wrap them!
38
39     def assert_equal(self, a, b):
40         return self.assertEqual(a, b)
41
42     def assert_raises(self, *args, **kwargs):
43         return self.assertRaises(*args, **kwargs)
44
45
46 def suite():
47     from jinja2.testsuite import ext, filters
48     suite = unittest.TestSuite()
49     suite.addTest(ext.suite())
50     suite.addTest(filters.suite())
51     return suite