mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
gh-95813: Improve HTMLParser from the view of inheritance (#95874)
* gh-95813: Improve HTMLParser from the view of inheritance * gh-95813: Add unittest * Address code review
This commit is contained in:
parent
c5bc67b2a1
commit
157aef79b0
2 changed files with 16 additions and 1 deletions
|
@ -4,6 +4,8 @@ import html.parser
|
|||
import pprint
|
||||
import unittest
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class EventCollector(html.parser.HTMLParser):
|
||||
|
||||
|
@ -787,5 +789,17 @@ class AttributesTestCase(TestCaseBase):
|
|||
('starttag', 'form',
|
||||
[('action', 'bogus|&#()value')])])
|
||||
|
||||
|
||||
class TestInheritance(unittest.TestCase):
|
||||
|
||||
@patch("_markupbase.ParserBase.__init__")
|
||||
@patch("_markupbase.ParserBase.reset")
|
||||
def test_base_class_methods_called(self, super_reset_method, super_init_method):
|
||||
with patch('_markupbase.ParserBase') as parser_base:
|
||||
EventCollector()
|
||||
super_init_method.assert_called_once()
|
||||
super_reset_method.assert_called_once()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue