/usr/lib/python3/dist-packages/pytils/test/templatetags/helpers.py is in python3-pytils 0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # -*- coding: utf-8 -*-
"""
Helpers for templatetags' unit tests in Django webframework
"""
from django.conf import settings
from django.utils.encoding import smart_str
encoding = 'utf-8'
settings.configure(
TEMPLATE_DIRS=(),
TEMPLATE_CONTEXT_PROCESSORS=(),
TEMPLATE_LOADERS=(),
INSTALLED_APPS=('pytils',),
DEFAULT_CHARSET=encoding,
)
from django import template
from django.template import loader
import unittest
class TemplateTagTestCase(unittest.TestCase):
"""
TestCase for testing template tags and filters
"""
def check_template_tag(self, template_name, template_string, context, result_string):
"""
Method validates output of template tag or filter
@param template_name: name of template
@type template_name: C{str}
@param template_string: contents of template
@type template_string: C{str} or C{unicode}
@param context: rendering context
@type context: C{dict}
@param result_string: reference output
@type result_string: C{str} or C{unicode}
"""
def test_template_loader(template_name, template_dirs=None):
return smart_str(template_string), template_name
loader.template_source_loaders = [test_template_loader,]
output = loader.get_template(template_name).render(template.Context(context))
self.assertEquals(output, result_string)
|