forked from django/django
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_templates.py
More file actions
25 lines (21 loc) · 989 Bytes
/
test_templates.py
File metadata and controls
25 lines (21 loc) · 989 Bytes
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
import json
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": {
"inline_formset_data": json.dumps(
{
"formset": {"prefix": "my-prefix"},
"opts": {"verbose_name": "verbose name\\"},
}
),
},
}
output = render_to_string("admin/edit_inline/stacked.html", context)
self.assertIn(""prefix": "my-prefix"", output)
self.assertIn(""verbose_name": "verbose name\\\\"", output)
output = render_to_string("admin/edit_inline/tabular.html", context)
self.assertIn(""prefix": "my-prefix"", output)
self.assertIn(""verbose_name": "verbose name\\\\"", output)