2015-11-23 11:46:19 +01:00
|
|
|
import json
|
|
|
|
|
2015-03-06 18:45:53 +01:00
|
|
|
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": {
|
2015-11-23 11:46:19 +01:00
|
|
|
"inline_formset_data": json.dumps(
|
|
|
|
{
|
|
|
|
"formset": {"prefix": "my-prefix"},
|
|
|
|
"opts": {"verbose_name": "verbose name\\"},
|
|
|
|
}
|
|
|
|
),
|
2015-03-06 18:45:53 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
output = render_to_string("admin/edit_inline/stacked.html", context)
|
2015-11-23 11:46:19 +01:00
|
|
|
self.assertIn(""prefix": "my-prefix"", output)
|
|
|
|
self.assertIn(""verbose_name": "verbose name\\\\"", output)
|
2015-03-06 18:45:53 +01:00
|
|
|
|
|
|
|
output = render_to_string("admin/edit_inline/tabular.html", context)
|
2015-11-23 11:46:19 +01:00
|
|
|
self.assertIn(""prefix": "my-prefix"", output)
|
|
|
|
self.assertIn(""verbose_name": "verbose name\\\\"", output)
|