mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
#15114: The html.parser module now raises a DeprecationWarning when the strict argument of HTMLParser or the HTMLParser.error method are used.
This commit is contained in:
parent
28f0beaff6
commit
88ebfb129b
4 changed files with 29 additions and 9 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue