summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_text.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils_tests/test_text.py')
-rw-r--r--tests/utils_tests/test_text.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py
index 12e441b81a..8bfd4c6ca1 100644
--- a/tests/utils_tests/test_text.py
+++ b/tests/utils_tests/test_text.py
@@ -2,6 +2,7 @@
from __future__ import unicode_literals
from unittest import skipUnless
+import warnings
from django.test import SimpleTestCase
from django.utils import six, text
@@ -152,16 +153,26 @@ class TestUtilsText(SimpleTestCase):
def test_javascript_quote(self):
input = "<script>alert('Hello \\xff.\n Welcome\there\r');</script>"
output = r"<script>alert(\'Hello \\xff.\n Welcome\there\r\');<\/script>"
- self.assertEqual(text.javascript_quote(input), output)
+ with warnings.catch_warnings():
+ self.assertEqual(text.javascript_quote(input), output)
# Exercising quote_double_quotes keyword argument
input = '"Text"'
- self.assertEqual(text.javascript_quote(input), '"Text"')
- self.assertEqual(text.javascript_quote(input, quote_double_quotes=True),
- '&quot;Text&quot;')
+ with warnings.catch_warnings():
+ self.assertEqual(text.javascript_quote(input), '"Text"')
+ self.assertEqual(text.javascript_quote(input, quote_double_quotes=True),
+ '&quot;Text&quot;')
- @skipUnless(IS_WIDE_BUILD)
+ @skipUnless(IS_WIDE_BUILD, 'Not running in a wide build of Python')
def test_javascript_quote_unicode(self):
input = "<script>alert('Hello \\xff.\n Wel𝕃come\there\r');</script>"
output = r"<script>alert(\'Hello \\xff.\n Wel𝕃come\there\r\');<\/script>"
- self.assertEqual(text.javascript_quote(input), output)
+ with warnings.catch_warnings():
+ self.assertEqual(text.javascript_quote(input), output)
+
+ def test_deprecation(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ text.javascript_quote('thingy')
+ self.assertEqual(len(w), 1)
+ self.assertIn('escapejs()', repr(w[0].message))