Commit 914b2de6 authored by jvoisin's avatar jvoisin

Bump coverage

parent 06283b00
Pipeline #22500 passed with stages
in 5 minutes and 10 seconds
......@@ -36,7 +36,9 @@ class _HTMLParser(parser.HTMLParser):
self.__validation_queue.append(tag)
def handle_endtag(self, tag: str):
if tag != self.__validation_queue.pop():
if not self.__validation_queue:
raise ValueError
elif tag != self.__validation_queue.pop():
raise ValueError
# There is no `get_endtag_text()` method :/
self.__textrepr += '</' + tag + '>\n'
......
......@@ -8,6 +8,7 @@
<h1>Hello</h1>
I am a web page.
Please <b>love</b> me.
Here, have a pretty picture: <img src='dirty.jpg' alt='a pretty picture'/>
</p>
</body>
</html>
......@@ -252,3 +252,20 @@ class TestCorruptedFiles(unittest.TestCase):
os.remove('./tests/data/clean.html')
os.remove('./tests/data/clean.cleaned.html')
with open('./tests/data/clean.html', 'w') as f:
f.write('</close>')
with self.assertRaises(ValueError):
html.HTMLParser('./tests/data/clean.html')
os.remove('./tests/data/clean.html')
with open('./tests/data/clean.html', 'w') as f:
f.write('<notclosed>')
p = html.HTMLParser('./tests/data/clean.html')
with self.assertRaises(ValueError):
p.get_meta()
p = html.HTMLParser('./tests/data/clean.html')
with self.assertRaises(ValueError):
p.remove_all()
os.remove('./tests/data/clean.html')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment