| 1 |
import json |
| 2 |
|
| 3 |
from django.template.loader import render_to_string |
| 4 |
from django.test import SimpleTestCase |
| 5 |
|
| 6 |
|
| 7 |
class TestTemplates(SimpleTestCase): |
| 8 |
def test_javascript_escaping(self): |
| 9 |
context = { |
| 10 |
"inline_admin_formset": { |
| 11 |
"inline_formset_data": json.dumps( |
| 12 |
{ |
| 13 |
"formset": {"prefix": "my-prefix"}, |
| 14 |
"opts": {"verbose_name": "verbose name\\"}, |
| 15 |
} |
| 16 |
), |
| 17 |
}, |
| 18 |
} |
| 19 |
output = render_to_string("admin/edit_inline/stacked.html", context) |
| 20 |
self.assertIn(""prefix": "my-prefix"", output) |
| 21 |
self.assertIn(""verbose_name": "verbose name\\\\"", output) |
| 22 |
|
| 23 |
output = render_to_string("admin/edit_inline/tabular.html", context) |
| 24 |
self.assertIn(""prefix": "my-prefix"", output) |
| 25 |
self.assertIn(""verbose_name": "verbose name\\\\"", output) |