MCPcopy
hub / github.com/django/django / test_escapejs

Method test_escapejs

tests/utils_tests/test_html.py:242–269  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

240 self.check_output(strip_spaces_between_tags, lazystr(value), output)
241
242 def test_escapejs(self):
243 items = (
244 (
245 "\"double quotes\" and 'single quotes'",
246 "\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027",
247 ),
248 (r"\ : backslashes, too", "\\u005C : backslashes, too"),
249 (
250 "and lots of whitespace: \r\n\t\v\f\b",
251 "and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008",
252 ),
253 (
254 r"<script>and this</script>",
255 "\\u003Cscript\\u003Eand this\\u003C/script\\u003E",
256 ),
257 (
258 "paragraph separator:\u2029and line separator:\u2028",
259 "paragraph separator:\\u2029and line separator:\\u2028",
260 ),
261 ("`", "\\u0060"),
262 ("\u007f", "\\u007F"),
263 ("\u0080", "\\u0080"),
264 ("\u009f", "\\u009F"),
265 )
266 for value, output in items:
267 with self.subTest(value=value, output=output):
268 self.check_output(escapejs, value, output)
269 self.check_output(escapejs, lazystr(value), output)
270
271 def test_json_script(self):
272 tests = (

Callers

nothing calls this directly

Calls 2

check_outputMethod · 0.95
lazystrFunction · 0.90

Tested by

no test coverage detected