selectolax icon indicating copy to clipboard operation
selectolax copied to clipboard

Error in empty string attribute

Open SkySandy opened this issue 1 year ago • 2 comments

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

SkySandy avatar Jun 09 '24 04:06 SkySandy

I think there is nothing we can do about it. That's how Modest treats them.

rushter avatar Oct 12 '24 09:10 rushter

it's a pity

SkySandy avatar Oct 12 '24 10:10 SkySandy