pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/157aef79b07e07bf115e49cdf5ff25e74c66354e

9241e157469407.css" /> gh-95813: Improve HTMLParser from the view of inheritance (#95874) · python/cpython@157aef7 · GitHub
Skip to content

Commit 157aef7

Browse files
authored
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
1 parent c5bc67b commit 157aef7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Lib/html/parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def __init__(self, *, convert_charrefs=True):
8989
If convert_charrefs is True (the default), all character references
9090
are automatically converted to the corresponding Unicode characters.
9191
"""
92+
super().__init__()
9293
self.convert_charrefs = convert_charrefs
9394
self.reset()
9495

@@ -98,7 +99,7 @@ def reset(self):
9899
self.lasttag = '???'
99100
self.interesting = interesting_normal
100101
self.cdata_elem = None
101-
_markupbase.ParserBase.reset(self)
102+
super().reset()
102103

103104
def feed(self, data):
104105
r"""Feed data to the parser.

Lib/test/test_htmlparser.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pprint
55
import unittest
66

7+
from unittest.mock import patch
8+
79

810
class EventCollector(html.parser.HTMLParser):
911

@@ -787,5 +789,17 @@ def test_weird_chars_in_unquoted_attribute_values(self):
787789
('starttag', 'form',
788790
[('action', 'bogus|&#()value')])])
789791

792+
793+
class TestInheritance(unittest.TestCase):
794+
795+
@patch("_markupbase.ParserBase.__init__")
796+
@patch("_markupbase.ParserBase.reset")
797+
def test_base_class_methods_called(self, super_reset_method, super_init_method):
798+
with patch('_markupbase.ParserBase') as parser_base:
799+
EventCollector()
800+
super_init_method.assert_called_once()
801+
super_reset_method.assert_called_once()
802+
803+
790804
if __name__ == "__main__":
791805
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy