2015-11-23 10:46:19 +00:00
|
|
|
import json
|
|
|
|
|
2015-03-06 17:45:53 +00:00
|
|
|
from django.template.loader import render_to_string
|
|
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class TestTemplates(SimpleTestCase):
|
|
|
|
def test_javascript_escaping(self):
|
|
|
|
context = {
|
2022-02-03 19:24:19 +00:00
|
|
|
"inline_admin_formset": {
|
|
|
|
"inline_formset_data": json.dumps(
|
|
|
|
{
|
|
|
|
"formset": {"prefix": "my-prefix"},
|
|
|
|
"opts": {"verbose_name": "verbose name\\"},
|
|
|
|
}
|
|
|
|
),
|
2015-03-06 17:45:53 +00:00
|
|
|
},
|
|
|
|
}
|
2022-02-03 19:24:19 +00:00
|
|
|
output = render_to_string("admin/edit_inline/stacked.html", context)
|
|
|
|
self.assertIn(""prefix": "my-prefix"", output)
|
|
|
|
self.assertIn(""verbose_name": "verbose name\\\\"", output)
|
2015-03-06 17:45:53 +00:00
|
|
|
|
2022-02-03 19:24:19 +00:00
|
|
|
output = render_to_string("admin/edit_inline/tabular.html", context)
|
|
|
|
self.assertIn(""prefix": "my-prefix"", output)
|
|
|
|
self.assertIn(""verbose_name": "verbose name\\\\"", output)
|