Skip to content
Snippets Groups Projects
Commit 914b2de6 authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Bump coverage

parent 06283b00
Branches
Tags
No related merge requests found
......@@ -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')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment