mirror of
https://github.com/django/django.git
synced 2024-11-30 15:10:46 +01:00
26 lines
989 B
Python
26 lines
989 B
Python
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)
|