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