| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,6 +155,9 @@ def __init__(self, **kwargs): | |||
| 155 | 155 | ||
| 156 | 156 | .. _html5lib user documentation: http://code.google.com/p/html5lib/wiki/UserDocumentation | |
| 157 | 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))) | ||
| 158 | 161 | if 'quote_char' in kwargs: | |
| 159 | 162 | self.use_best_quote_char = False | |
| 160 | 163 | for attr in self.options: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,9 +79,12 @@ def _convertAttrib(self, attribs): | |||
| 79 | 79 | ||
| 80 | 80 | def serialize_html(input, options): | |
| 81 | 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"] | ||
| 82 | 85 | stream = Lint(JsonWalker(input), False) | |
| 83 | 86 | serializer = HTMLSerializer(alphabetical_attributes=True, **options) | |
| 84 | - return serializer.render(stream, options.get("encoding", None)) | ||
| 87 | + return serializer.render(stream, encoding) | ||
| 85 | 88 | ||
| 86 | 89 | ||
| 87 | 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) | ||
| 155 | + | ||
| 156 | + | ||
| 149 | 157 | @pytest.mark.parametrize("c", list("\t\n\u000C\x20\r\"'=<>`")) | |
| 150 | 158 | def testSpecQuoteAttribute(c): | |
| 151 | 159 | input_ = [["StartTag", "http://www.w3.org/1999/xhtml", "span", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments