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