Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/template_tests/filter_tests/test_last.py
blob: 29c558fa26c0791e37277929228f3ed13c607e75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe

from ..utils import setup


class LastTests(SimpleTestCase):

    @setup({'last01': '{{ a|last }} {{ b|last }}'})
    def test_last01(self):
        output = self.engine.render_to_string('last01', {"a": ["x", "a&b"], "b": ["x", mark_safe("a&b")]})
        self.assertEqual(output, "a&b a&b")

    @setup({'last02': '{% autoescape off %}{{ a|last }} {{ b|last }}{% endautoescape %}'})
    def test_last02(self):
        output = self.engine.render_to_string('last02', {"a": ["x", "a&b"], "b": ["x", mark_safe("a&b")]})
        self.assertEqual(output, "a&b a&b")