We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 75cf697 commit 57dfcaeCopy full SHA for 57dfcae
html5lib/serializer/htmlserializer.py
@@ -155,6 +155,9 @@ def __init__(self, **kwargs):
155
156
.. _html5lib user documentation: http://code.google.com/p/html5lib/wiki/UserDocumentation
157
"""
158
+ unexpected_args = frozenset(kwargs) - frozenset(self.options)
159
+ if len(unexpected_args) > 0:
160
+ raise TypeError("__init__() got an unexpected keyword argument '%s'" % next(iter(unexpected_args)))
161
if 'quote_char' in kwargs:
162
self.use_best_quote_char = False
163
for attr in self.options:
html5lib/tests/test_serializer.py
@@ -79,9 +79,12 @@ def _convertAttrib(self, attribs):
79
80
def serialize_html(input, options):
81
options = dict([(str(k), v) for k, v in options.items()])
82
+ encoding = options.get("encoding", None)
83
+ if "encoding" in options:
84
+ del options["encoding"]
85
stream = Lint(JsonWalker(input), False)
86
serializer = HTMLSerializer(alphabetical_attributes=True, **options)
- return serializer.render(stream, options.get("encoding", None))
87
+ return serializer.render(stream, encoding)
88
89
90
def runSerializerTest(input, expected, options):
@@ -146,6 +149,11 @@ def testComment():
146
149
throwsWithLatin1([["Comment", "\u0101"]])
147
150
148
151
152
+def testThrowsUnknownOption():
153
+ with pytest.raises(TypeError):
154
+ HTMLSerializer(foobar=None)
+
@pytest.mark.parametrize("c", list("\t\n\u000C\x20\r\"'=<>`"))
def testSpecQuoteAttribute(c):
input_ = [["StartTag", "http://www.w3.org/1999/xhtml", "span",
0 commit comments