mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
Avoid reusing the same collector in the tests.
This commit is contained in:
parent
18b0e5b79b
commit
b9a48f7144
1 changed files with 11 additions and 10 deletions
|
@ -360,8 +360,8 @@ DOCTYPE html [
|
||||||
|
|
||||||
class HTMLParserTolerantTestCase(TestCaseBase):
|
class HTMLParserTolerantTestCase(TestCaseBase):
|
||||||
|
|
||||||
def setUp(self):
|
def get_collector(self):
|
||||||
self.collector = EventCollector(strict=False)
|
return EventCollector(strict=False)
|
||||||
|
|
||||||
def test_tolerant_parsing(self):
|
def test_tolerant_parsing(self):
|
||||||
self._run_check('<html <html>te>>xt&a<<bc</a></html>\n'
|
self._run_check('<html <html>te>>xt&a<<bc</a></html>\n'
|
||||||
|
@ -375,9 +375,10 @@ class HTMLParserTolerantTestCase(TestCaseBase):
|
||||||
('endtag', 'html'),
|
('endtag', 'html'),
|
||||||
('data', '\n<img src="URL><//img></html'),
|
('data', '\n<img src="URL><//img></html'),
|
||||||
('endtag', 'html')],
|
('endtag', 'html')],
|
||||||
collector = self.collector)
|
collector=self.get_collector())
|
||||||
|
|
||||||
def test_with_unquoted_attributes(self):
|
def test_with_unquoted_attributes(self):
|
||||||
|
# see #12008
|
||||||
html = ("<html><body bgcolor=d0ca90 text='181008'>"
|
html = ("<html><body bgcolor=d0ca90 text='181008'>"
|
||||||
"<table cellspacing=0 cellpadding=1 width=100% ><tr>"
|
"<table cellspacing=0 cellpadding=1 width=100% ><tr>"
|
||||||
"<td align=left><font size=-1>"
|
"<td align=left><font size=-1>"
|
||||||
|
@ -399,7 +400,7 @@ class HTMLParserTolerantTestCase(TestCaseBase):
|
||||||
('endtag', 'span'), ('endtag', 'a'), ('endtag', 'table')
|
('endtag', 'span'), ('endtag', 'a'), ('endtag', 'table')
|
||||||
]
|
]
|
||||||
|
|
||||||
self._run_check(html, expected, collector=self.collector)
|
self._run_check(html, expected, collector=self.get_collector())
|
||||||
|
|
||||||
def test_comma_between_attributes(self):
|
def test_comma_between_attributes(self):
|
||||||
self._run_check('<form action="/xxx.php?a=1&b=2&", '
|
self._run_check('<form action="/xxx.php?a=1&b=2&", '
|
||||||
|
@ -407,15 +408,16 @@ class HTMLParserTolerantTestCase(TestCaseBase):
|
||||||
('starttag', 'form',
|
('starttag', 'form',
|
||||||
[('action', '/xxx.php?a=1&b=2&'),
|
[('action', '/xxx.php?a=1&b=2&'),
|
||||||
('method', 'post')])],
|
('method', 'post')])],
|
||||||
collector = self.collector)
|
collector=self.get_collector())
|
||||||
|
|
||||||
def test_weird_chars_in_unquoted_attribute_values(self):
|
def test_weird_chars_in_unquoted_attribute_values(self):
|
||||||
self._run_check('<form action=bogus|&#()value>', [
|
self._run_check('<form action=bogus|&#()value>', [
|
||||||
('starttag', 'form',
|
('starttag', 'form',
|
||||||
[('action', 'bogus|&#()value')])],
|
[('action', 'bogus|&#()value')])],
|
||||||
collector = self.collector)
|
collector=self.get_collector())
|
||||||
|
|
||||||
def test_issue13273(self):
|
def test_correct_detection_of_start_tags(self):
|
||||||
|
# see #13273
|
||||||
html = ('<div style="" ><b>The <a href="some_url">rain</a> '
|
html = ('<div style="" ><b>The <a href="some_url">rain</a> '
|
||||||
'<br /> in <span>Spain</span></b></div>')
|
'<br /> in <span>Spain</span></b></div>')
|
||||||
expected = [
|
expected = [
|
||||||
|
@ -434,9 +436,8 @@ class HTMLParserTolerantTestCase(TestCaseBase):
|
||||||
('endtag', 'b'),
|
('endtag', 'b'),
|
||||||
('endtag', 'div')
|
('endtag', 'div')
|
||||||
]
|
]
|
||||||
self._run_check(html, expected, collector=self.collector)
|
self._run_check(html, expected, collector=self.get_collector())
|
||||||
|
|
||||||
def test_issue13273_2(self):
|
|
||||||
html = '<div style="", foo = "bar" ><b>The <a href="some_url">rain</a>'
|
html = '<div style="", foo = "bar" ><b>The <a href="some_url">rain</a>'
|
||||||
expected = [
|
expected = [
|
||||||
('starttag', 'div', [('style', ''), ('foo', 'bar')]),
|
('starttag', 'div', [('style', ''), ('foo', 'bar')]),
|
||||||
|
@ -446,7 +447,7 @@ class HTMLParserTolerantTestCase(TestCaseBase):
|
||||||
('data', 'rain'),
|
('data', 'rain'),
|
||||||
('endtag', 'a'),
|
('endtag', 'a'),
|
||||||
]
|
]
|
||||||
self._run_check(html, expected, collector=self.collector)
|
self._run_check(html, expected, collector=self.get_collector())
|
||||||
|
|
||||||
def test_unescape_function(self):
|
def test_unescape_function(self):
|
||||||
p = html.parser.HTMLParser()
|
p = html.parser.HTMLParser()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue