diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2013-11-02 15:08:24 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2013-11-02 15:08:24 (GMT) |
commit | 88ebfb129b59dc8a2b855fc93fcf32457128d64d (patch) | |
tree | c1c3e6ab03e4c6431330402cabe40b8889353454 /Lib/test | |
parent | 28f0beaff692117a55ab919e87d336044935a0ab (diff) | |
download | cpython-88ebfb129b59dc8a2b855fc93fcf32457128d64d.zip cpython-88ebfb129b59dc8a2b855fc93fcf32457128d64d.tar.gz cpython-88ebfb129b59dc8a2b855fc93fcf32457128d64d.tar.bz2 |
#15114: The html.parser module now raises a DeprecationWarning when the strict argument of HTMLParser or the HTMLParser.error method are used.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_htmlparser.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index b15b6fd..6ebf5b8 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -96,7 +96,9 @@ class TestCaseBase(unittest.TestCase): 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 @@ text 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 AttributesStrictTestCase(TestCaseBase): class AttributesTolerantTestCase(AttributesStrictTestCase): def get_collector(self): - return EventCollector(strict=False) + return EventCollector() def test_attr_funky_names2(self): self._run_check( |