1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# -*- coding: utf-8 -*-
import pytest
from markupsafe import Markup
@pytest.mark.parametrize(
("value", "expect"),
(
# empty
(u"", u""),
# ascii
(u"abcd&><'\"efgh", u"abcd&><'"efgh"),
(u"&><'\"efgh", u"&><'"efgh"),
(u"abcd&><'\"", u"abcd&><'""),
# 2 byte
(u"こんにちは&><'\"こんばんは", u"こんにちは&><'"こんばんは"),
(u"&><'\"こんばんは", u"&><'"こんばんは"),
(u"こんにちは&><'\"", u"こんにちは&><'""),
# 4 byte
(
u"\U0001F363\U0001F362&><'\"\U0001F37A xyz",
u"\U0001F363\U0001F362&><'"\U0001F37A xyz",
),
(u"&><'\"\U0001F37A xyz", u"&><'"\U0001F37A xyz"),
(u"\U0001F363\U0001F362&><'\"", u"\U0001F363\U0001F362&><'""),
),
)
def test_escape(escape, value, expect):
assert escape(value) == Markup(expect)
|