You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
30 lines
1.0 KiB
import pytest
|
|
|
|
from markupsafe import Markup
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("value", "expect"),
|
|
(
|
|
# empty
|
|
("", ""),
|
|
# ascii
|
|
("abcd&><'\"efgh", "abcd&><'"efgh"),
|
|
("&><'\"efgh", "&><'"efgh"),
|
|
("abcd&><'\"", "abcd&><'""),
|
|
# 2 byte
|
|
("こんにちは&><'\"こんばんは", "こんにちは&><'"こんばんは"),
|
|
("&><'\"こんばんは", "&><'"こんばんは"),
|
|
("こんにちは&><'\"", "こんにちは&><'""),
|
|
# 4 byte
|
|
(
|
|
"\U0001F363\U0001F362&><'\"\U0001F37A xyz",
|
|
"\U0001F363\U0001F362&><'"\U0001F37A xyz",
|
|
),
|
|
("&><'\"\U0001F37A xyz", "&><'"\U0001F37A xyz"),
|
|
("\U0001F363\U0001F362&><'\"", "\U0001F363\U0001F362&><'""),
|
|
),
|
|
)
|
|
def test_escape(escape, value, expect):
|
|
assert escape(value) == Markup(expect)
|