summaryrefslogtreecommitdiff
path: root/tests/regressiontests/utils/html.py
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2011-01-02 17:34:52 +0000
committerRamiro Morales <cramm0@gmail.com>2011-01-02 17:34:52 +0000
commit0f783b7f4eac037e22875eeeb6dc85c26b2a65f4 (patch)
tree7600364217fb5f354bfa1283a98e9562cbfbec6a /tests/regressiontests/utils/html.py
parent544ab30ed71e0d78c4c061008758de29ff79e8f7 (diff)
Fixed #2986 -- Made the JavaScript code that drives related model instance addition in a popup window handle a model representation containing new lines. Also, moved the escapejs functionality yoo django.utils.html so it can be used from Python code. Thanks andrewwatts for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15131 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/utils/html.py')
-rw-r--r--tests/regressiontests/utils/html.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/regressiontests/utils/html.py b/tests/regressiontests/utils/html.py
index a9b0d337f2..3acb218cd1 100644
--- a/tests/regressiontests/utils/html.py
+++ b/tests/regressiontests/utils/html.py
@@ -109,3 +109,15 @@ class TestUtilsHtml(unittest.TestCase):
)
for value, output in items:
self.check_output(f, value, output)
+
+ def test_escapejs(self):
+ f = html.escapejs
+ items = (
+ (u'"double quotes" and \'single quotes\'', u'\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027'),
+ (ur'\ : backslashes, too', u'\\u005C : backslashes, too'),
+ (u'and lots of whitespace: \r\n\t\v\f\b', u'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008'),
+ (ur'<script>and this</script>', u'\\u003Cscript\\u003Eand this\\u003C/script\\u003E'),
+ (u'paragraph separator:\u2029and line separator:\u2028', u'paragraph separator:\\u2029and line separator:\\u2028'),
+ )
+ for value, output in items:
+ self.check_output(f, value, output)