Skip to content

Conversation

@thunze
Copy link

@thunze thunze commented Nov 29, 2025

lxml 6 doesn't find a <body> tag via the XPath expression //body anymore when the parsed HTML doesn't contain any tags at all. This currently causes the following tests to fail when lxml 6 is used:

Version 0.21.0:

tests/test_djangoclient.py::DjangoClientDriverTest::test_is_text_present_and_should_wait_time
tests/test_djangoclient.py::DjangoClientDriverTestWithCustomHeaders::test_create_a_phantomjs_with_custom_headers
tests/test_flaskclient.py::FlaskClientDriverTest::test_is_text_present_and_should_wait_time
tests/test_flaskclient.py::FlaskClientDriverTestWithCustomHeaders::test_create_a_flask_client_with_custom_headers
tests/test_zopetestbrowser.py::ZopeTestBrowserDriverTest::test_is_text_present_and_should_wait_time

master at the time of writing (8615391):

tests/tests_django/test_custom_headers.py::test_create_a_django_client_with_custom_headers
tests/test_all_drivers/test_is_text_present.py::test_is_text_present_and_should_wait_time

See https://hydra.nixos.org/build/314264704/nixlog/1 for logs of the test failures. Note that these logs were obtained by running the test suite of version 0.21.0 and the tests have apparently been restructured since then. I'm pretty sure the underlying test failures are the same though.

This PR fixes these test failures by wrapping fake web server responses that currently don't have a <body> tag with <html><body>...</body></html>.

lxml 6 doesn't find a `<body>` tag via the XPath expression `//body`
anymore when the parsed HTML doesn't contain any tags at all.
This caused some of splinter's tests to fail when lxml 6 is used.

See https://hydra.nixos.org/build/314264704/nixlog/1 for logs of
the test failures.
Copy link
Contributor

@fsouza fsouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this!

@thunze
Copy link
Author

thunze commented Dec 7, 2025

@fsouza Sure thing!

I don't think the CI failures are related to this change, can you confirm this?

@fsouza
Copy link
Contributor

fsouza commented Dec 7, 2025

yeah I think that's a flaky test, let me see if a retry will turn it green

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

Successfully merging this pull request may close these issues.

2 participants