Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in empty string attribute #119

Open
SkySandy opened this issue Jun 9, 2024 · 2 comments
Open

Error in empty string attribute #119

SkySandy opened this issue Jun 9, 2024 · 2 comments

Comments

@SkySandy
Copy link

SkySandy commented Jun 9, 2024

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

@rushter
Copy link
Owner

rushter commented Oct 12, 2024

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

@SkySandy
Copy link
Author

it's a pity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants