Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_htmlparser.py @ 86842:0a56709eb798
#15114: The html.parser module now raises a DeprecationWarning when the strict argument of HTMLParser or the HTMLParser.error method are used.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Sat, 02 Nov 2013 17:08:24 +0200 |
| parents | 9cb90c1a1a46 |
| children | 0ce6c0a47676 |
line wrap: on
line diff
--- a/Lib/test/test_htmlparser.py Sat Nov 02 16:41:23 2013 +0200 +++ b/Lib/test/test_htmlparser.py Sat Nov 02 17:08:24 2013 +0200 @@ -96,7 +96,9 @@ parser = self.get_collector() parser.feed(source) parser.close() - self.assertRaises(html.parser.HTMLParseError, parse) + with self.assertRaises(html.parser.HTMLParseError): + with self.assertWarns(DeprecationWarning): + parse() class HTMLParserStrictTestCase(TestCaseBase): @@ -360,7 +362,16 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase): def get_collector(self): - return EventCollector(strict=False) + return EventCollector() + + def test_deprecation_warnings(self): + with self.assertWarns(DeprecationWarning): + EventCollector(strict=True) + with self.assertWarns(DeprecationWarning): + EventCollector(strict=False) + with self.assertRaises(html.parser.HTMLParseError): + with self.assertWarns(DeprecationWarning): + EventCollector().error('test') def test_tolerant_parsing(self): self._run_check('<html <html>te>>xt&a<<bc</a></html>\n' @@ -676,7 +687,7 @@ class AttributesTolerantTestCase(AttributesStrictTestCase): def get_collector(self): - return EventCollector(strict=False) + return EventCollector() def test_attr_funky_names2(self): self._run_check(
