diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2014-02-21 14:46:23 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2014-02-22 13:50:12 +0100 |
| commit | 926e18d7d126fcf7f4b2d25ce4155423ac6e2f90 (patch) | |
| tree | 269e957ca3faa124206e0c724557d8144fbca4a1 /tests/utils_tests/test_text.py | |
| parent | 847171b0d09c7da95cd404bab80f84c890fc5cfd (diff) | |
Deprecated django.utils.text.javascript_quote.
Refs #21725.
Diffstat (limited to 'tests/utils_tests/test_text.py')
| -rw-r--r-- | tests/utils_tests/test_text.py | 23 |
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), - '"Text"') + with warnings.catch_warnings(): + self.assertEqual(text.javascript_quote(input), '"Text"') + self.assertEqual(text.javascript_quote(input, quote_double_quotes=True), + '"Text"') - @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)) |
