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