Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/template_tests/filter_tests/test_capfirst.py
blob: bcdf1e0203b8f62d0dc673d6955325a1e8d93762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from django.template.defaultfilters import capfirst
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe

from ..utils import setup


class CapfirstTests(SimpleTestCase):

    @setup({'capfirst01': '{% autoescape off %}{{ a|capfirst }} {{ b|capfirst }}{% endautoescape %}'})
    def test_capfirst01(self):
        output = self.engine.render_to_string('capfirst01', {'a': 'fred>', 'b': mark_safe('fred>')})
        self.assertEqual(output, 'Fred> Fred>')

    @setup({'capfirst02': '{{ a|capfirst }} {{ b|capfirst }}'})
    def test_capfirst02(self):
        output = self.engine.render_to_string('capfirst02', {'a': 'fred>', 'b': mark_safe('fred>')})
        self.assertEqual(output, 'Fred> Fred>')


class FunctionTests(SimpleTestCase):

    def test_capfirst(self):
        self.assertEqual(capfirst('hello world'), 'Hello world')