selectolax
selectolax copied to clipboard
Error in empty string attribute
Let's write this test
@pytest.mark.parametrize(*_PARSERS_PARAMETRIZER)
def test_empty_attributes(self, parser):
html = "<div><p id=''>text</p></div>"
selector = "p"
for node in parser(html).css(selector):
assert 'id' in node.attributes
assert node.attributes['id'] == ''
Run it
Passed 1 of 2
Expected :'' Actual :None
> assert node.attributes['id'] == ''
E AssertionError: assert None == ''
HTMLParser return None for empty string attribute, but LexborHTMLParser return empty string
I think there is nothing we can do about it. That's how Modest treats them.
it's a pity