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_html_to_nodes_not_allowed_tag(self):
with self.assertRaises(NotAllowedTag):
html_to_nodes('')
def handle_starttag(self, tag, attrs_list):
if tag not in ALLOWED_TAGS:
raise NotAllowedTag('%s tag is not allowed' % tag)
node = {'tag': tag}
if attrs_list:
attrs = {}
for attr, value in attrs_list:
attrs[attr] = value
node['attrs'] = attrs
self.current_nodes.append(node)
if tag not in VOID_ELEMENTS:
self.parent_nodes.append(self.current_nodes)
self.current_nodes = node['children'] = []