Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_remove_head_tag(self):
html_string = (
'<title>Title</title>'
'<h1>Header</h1>'
'<p><span>text</span></p>'
'<p>footer <em>like</em> a boss</p>'
''
)
dom = html.fromstring(html_string)
returned = html.tostring(dom).decode("utf8")
assert html_string == returned
dom = preprocessor(dom)
returned = html.tostring(dom).decode("utf8")
expected = (
''
'<h1>Header</h1>'
'<p><span>text</span></p>'
'<p>footer <em>like</em> a boss</p>'
''
)
assert expected == returned
def test_remove_comments(self):
dom = html.fromstring(
''
'<h1>Header</h1>'
' text'
'<p>footer'
''
)
expected = '</p><h1>Header</h1> text<p>footer</p>'
returned = html.tostring(dom).decode("utf8")
assert expected == returned
dom = preprocessor(dom)
expected = '<h1>Header</h1> text<p>footer</p>'
returned = html.tostring(dom).decode("utf8")
assert expected == returned