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&><'"efgh"), 13 ("&><'\"efgh", "&><'"efgh"), 14 ("abcd&><'\"", "abcd&><'""), 15 # 2 byte 16 ("こんにちは&><'\"こんばんは", "こんにちは&><'"こんばんは"), 17 ("&><'\"こんばんは", "&><'"こんばんは"), 18 ("こんにちは&><'\"", "こんにちは&><'""), 19 # 4 byte 20 ( 21 "\U0001F363\U0001F362&><'\"\U0001F37A xyz", 22 "\U0001F363\U0001F362&><'"\U0001F37A xyz", 23 ), 24 ("&><'\"\U0001F37A xyz", "&><'"\U0001F37A xyz"), 25 ("\U0001F363\U0001F362&><'\"", "\U0001F363\U0001F362&><'""), 26 ), 27) 28def test_escape(escape, value, expect): 29 assert escape(value) == Markup(expect) 30