@@ -146,6 +146,37 @@ def testComment():
146146 throwsWithLatin1 ([["Comment" , "\u0101 " ]])
147147
148148
149+ @pytest .mark .parametrize ("c" , list ("\t \n \u000C \x20 \r \" '=<>`" ))
150+ def testSpecQuoteAttribute (c ):
151+ input_ = [["StartTag" , "http://www.w3.org/1999/xhtml" , "span" ,
152+ [{"namespace" : None , "name" : "foo" , "value" : c }]]]
153+ if c == '"' :
154+ output_ = ["<span foo='%s'>" % c ]
155+ else :
156+ output_ = ['<span foo="%s">' % c ]
157+ options_ = {"quote_attr_values" : "spec" }
158+ runSerializerTest (input_ , output_ , options_ )
159+
160+
161+ @pytest .mark .parametrize ("c" , list ("\t \n \u000C \x20 \r \" '=<>`"
162+ "\x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \t \n "
163+ "\x0b \x0c \r \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 "
164+ "\x16 \x17 \x18 \x19 \x1a \x1b \x1c \x1d \x1e \x1f "
165+ "\x20 \x2f \x60 \xa0 \u1680 \u180e \u180f \u2000 "
166+ "\u2001 \u2002 \u2003 \u2004 \u2005 \u2006 \u2007 "
167+ "\u2008 \u2009 \u200a \u2028 \u2029 \u202f \u205f "
168+ "\u3000 " ))
169+ def testLegacyQuoteAttribute (c ):
170+ input_ = [["StartTag" , "http://www.w3.org/1999/xhtml" , "span" ,
171+ [{"namespace" : None , "name" : "foo" , "value" : c }]]]
172+ if c == '"' :
173+ output_ = ["<span foo='%s'>" % c ]
174+ else :
175+ output_ = ['<span foo="%s">' % c ]
176+ options_ = {"quote_attr_values" : "legacy" }
177+ runSerializerTest (input_ , output_ , options_ )
178+
179+
149180@pytest .fixture
150181def lxml_parser ():
151182 return etree .XMLParser (resolve_entities = False )
0 commit comments