Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/admin_inlines/test_templates.py
blob: 1ed52c91157efc086eaf3b41f37bfdd10ba6c805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from __future__ import unicode_literals

from django.template.loader import render_to_string
from django.test import SimpleTestCase


class TestTemplates(SimpleTestCase):
    def test_javascript_escaping(self):
        context = {
            'inline_admin_formset': {
                'formset': {'prefix': 'my-prefix'},
                'opts': {'verbose_name': 'verbose name\\'},
            },
        }
        output = render_to_string('admin/edit_inline/stacked.html', context)
        self.assertIn('prefix: "my\\u002Dprefix",', output)
        self.assertIn('addText: "Add another Verbose name\\u005C"', output)

        output = render_to_string('admin/edit_inline/tabular.html', context)
        self.assertIn('prefix: "my\\u002Dprefix",', output)
        self.assertIn('addText: "Add another Verbose name\\u005C"', output)