mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Change test_htmlparser to reflect the HTMLParser -> html.parser
rename in r63439. Also fix one occurrence of unichr() in html.parser.
This commit is contained in:
parent
96ad65da2f
commit
f64dcf3ce0
2 changed files with 6 additions and 6 deletions
|
@ -378,7 +378,7 @@ class HTMLParser(_markupbase.ParserBase):
|
||||||
if HTMLParser.entitydefs is None:
|
if HTMLParser.entitydefs is None:
|
||||||
entitydefs = HTMLParser.entitydefs = {'apos':"'"}
|
entitydefs = HTMLParser.entitydefs = {'apos':"'"}
|
||||||
for k, v in html.entities.name2codepoint.items():
|
for k, v in html.entities.name2codepoint.items():
|
||||||
entitydefs[k] = unichr(v)
|
entitydefs[k] = chr(v)
|
||||||
try:
|
try:
|
||||||
return self.entitydefs[s]
|
return self.entitydefs[s]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
"""Tests for HTMLParser.py."""
|
"""Tests for HTMLParser.py."""
|
||||||
|
|
||||||
import HTMLParser
|
import html.parser
|
||||||
import pprint
|
import pprint
|
||||||
import unittest
|
import unittest
|
||||||
from test import support
|
from test import support
|
||||||
|
|
||||||
|
|
||||||
class EventCollector(HTMLParser.HTMLParser):
|
class EventCollector(html.parser.HTMLParser):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.events = []
|
self.events = []
|
||||||
self.append = self.events.append
|
self.append = self.events.append
|
||||||
HTMLParser.HTMLParser.__init__(self)
|
html.parser.HTMLParser.__init__(self)
|
||||||
|
|
||||||
def get_events(self):
|
def get_events(self):
|
||||||
# Normalize the list of events so that buffer artefacts don't
|
# Normalize the list of events so that buffer artefacts don't
|
||||||
|
@ -88,10 +88,10 @@ class TestCaseBase(unittest.TestCase):
|
||||||
|
|
||||||
def _parse_error(self, source):
|
def _parse_error(self, source):
|
||||||
def parse(source=source):
|
def parse(source=source):
|
||||||
parser = HTMLParser.HTMLParser()
|
parser = html.parser.HTMLParser()
|
||||||
parser.feed(source)
|
parser.feed(source)
|
||||||
parser.close()
|
parser.close()
|
||||||
self.assertRaises(HTMLParser.HTMLParseError, parse)
|
self.assertRaises(html.parser.HTMLParseError, parse)
|
||||||
|
|
||||||
|
|
||||||
class HTMLParserTestCase(TestCaseBase):
|
class HTMLParserTestCase(TestCaseBase):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue