示例#1
0
 def test_escapejs(self):
     self.assertEqual(escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027')
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'),
         '\\u005C : backslashes, too')
     self.assertEqual(escapejs_filter('and lots of whitespace: \r\n\t\v\f\b'),
         'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008')
     self.assertEqual(escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E')
     self.assertEqual(
         escapejs_filter('paragraph separator:\u2029and line separator:\u2028'),
         'paragraph separator:\\u2029and line separator:\\u2028')
示例#2
0
 def test_escapejs(self):
     self.assertEqual(escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027')
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'),
         '\\u005C : backslashes, too')
     self.assertEqual(escapejs_filter('and lots of whitespace: \r\n\t\v\f\b'),
         'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008')
     self.assertEqual(escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E')
     self.assertEqual(
         escapejs_filter('paragraph separator:\u2029and line separator:\u2028'),
         'paragraph separator:\\u2029and line separator:\\u2028')
示例#3
0
 def test_lazy_string(self):
     append_script = lazy(lambda string: r'<script>this</script>' + string,
                          str)
     self.assertEqual(
         escapejs_filter(append_script('whitespace: \r\n\t\v\f\b')),
         '\\u003Cscript\\u003Ethis\\u003C/script\\u003E'
         'whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008')
示例#4
0
 def test_lazy_string(self):
     append_script = lazy(lambda string: r"<script>this</script>" + string, str)
     self.assertEqual(
         escapejs_filter(append_script("whitespace: \r\n\t\v\f\b")),
         "\\u003Cscript\\u003Ethis\\u003C/script\\u003E"
         "whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008",
     )
示例#5
0
 def test_lazy_string(self):
     append_script = lazy(lambda string: r'<script>this</script>' + string, six.text_type)
     self.assertEqual(
         escapejs_filter(append_script('whitespace: \r\n\t\v\f\b')),
         '\\u003Cscript\\u003Ethis\\u003C/script\\u003E'
         'whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008'
     )
示例#6
0
 def test_quotes(self):
     self.assertEqual(
         escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027',
     )
示例#7
0
 def test_whitespace(self):
     self.assertEqual(
         escapejs_filter('and lots of whitespace: \r\n\t\v\f\b'),
         'and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008',
     )
示例#8
0
 def test_paragraph_separator(self):
     self.assertEqual(
         escapejs_filter("paragraph separator:\u2029and line separator:\u2028"),
         "paragraph separator:\\u2029and line separator:\\u2028",
     )
示例#9
0
 def test_script(self):
     self.assertEqual(
         escapejs_filter(r"<script>and this</script>"),
         "\\u003Cscript\\u003Eand this\\u003C/script\\u003E",
     )
示例#10
0
 def test_whitespace(self):
     self.assertEqual(
         escapejs_filter("and lots of whitespace: \r\n\t\v\f\b"),
         "and lots of whitespace: \\u000D\\u000A\\u0009\\u000B\\u000C\\u0008",
     )
示例#11
0
 def test_backslashes(self):
     self.assertEqual(
         escapejs_filter(r"\ : backslashes, too"), "\\u005C : backslashes, too"
     )
示例#12
0
 def test_quotes(self):
     self.assertEqual(
         escapejs_filter("\"double quotes\" and 'single quotes'"),
         "\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027",
     )
示例#13
0
def escapejs(data):
    return escapejs_filter(data)
示例#14
0
 def test_backslashes(self):
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'), '\\u005C : backslashes, too')
示例#15
0
 def test_script(self):
     self.assertEqual(
         escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E',
     )
示例#16
0
 def test_backslashes(self):
     self.assertEqual(escapejs_filter(r'\ : backslashes, too'),
                      '\\u005C : backslashes, too')
示例#17
0
 def test_quotes(self):
     self.assertEqual(
         escapejs_filter('"double quotes" and \'single quotes\''),
         '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027',
     )
示例#18
0
 def test_paragraph_separator(self):
     self.assertEqual(
         escapejs_filter('paragraph separator:\u2029and line separator:\u2028'),
         'paragraph separator:\\u2029and line separator:\\u2028',
     )
示例#19
0
 def test_script(self):
     self.assertEqual(
         escapejs_filter(r'<script>and this</script>'),
         '\\u003Cscript\\u003Eand this\\u003C/script\\u003E',
     )