Package pytils :: Package test :: Package templatetags :: Module helpers
[hide private]

Source Code for Module pytils.test.templatetags.helpers

 1  # -*- coding: utf-8 -*- 
 2  # PyTils - simple processing for russian strings 
 3  # Copyright (C) 2006-2007  Yury Yurevich 
 4  # 
 5  # http://gorod-omsk.ru/blog/pythy/projects/pytils/ 
 6  # 
 7  # This program is free software; you can redistribute it and/or 
 8  # modify it under the terms of the GNU General Public License 
 9  # as published by the Free Software Foundation, version 2 
10  # of the License. 
11  # 
12  # This program is distributed in the hope that it will be useful, 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  # GNU General Public License for more details. 
16  """ 
17  Helpers for templatetags' unit tests in Django webframework 
18  """ 
19   
20  __id__ = __revision__ = "$Id: helpers.py 76 2007-02-27 15:38:53Z the.pythy $" 
21  __url__ = "$URL: https://pythy.googlecode.com/svn/trunk/pytils/pytils/test/templatetags/helpers.py $" 
22   
23  from django.conf import settings 
24   
25  settings.configure( 
26      TEMPLATE_DIRS=(), 
27      TEMPLATE_CONTEXT_PROCESSORS=(), 
28      TEMPLATE_LOADERS=(), 
29      INSTALLED_APPS=('pytils',), 
30  ) 
31   
32  from django import template 
33  from django.template import loader 
34   
35  import unittest 
36   
37   
38 -class TemplateTagTestCase(unittest.TestCase):
39 """ 40 TestCase for testing template tags and filters 41 """
42 - def check_template_tag(self, template_name, template_string, context, result_string):
43 """ 44 Method validates output of template tag or filter 45 46 @param template_name: name of template 47 @type template_name: C{str} 48 49 @param template_string: contents of template 50 @type template_string: C{str} 51 52 @param context: rendering context 53 @type context: C{dict} 54 55 @param result_string: reference output 56 @type result_string: C{str} 57 """ 58 59 def test_template_loader(template_name, template_dirs=None): 60 return template_string, template_name
61 62 loader.template_source_loaders = [test_template_loader,] 63 64 output = loader.get_template(template_name).render(template.Context(context)) 65 66 self.assertEquals(output, result_string)
67