Skip to content

Conversation

@thibaudcolas
Copy link
Collaborator

Motivation

  • The DOM engine selection is stored on DOM.dom and HTML.__init__ calls DOM.use, causing the engine to be global across all HTML instances and leading to surprising last-wins and thread-safety issues.
  • Add unit tests that capture the current (problematic) behavior so future fixes can be validated with regressions.

Description

  • Added two unit tests to tests/test_html.py: test_engine_is_global_for_existing_instances and test_engine_switching_affects_previous_instance that exercise engine selection across multiple HTML instances.
  • The tests assert the difference in escaping behavior between DOM.STRING and DOM.STRING_COMPAT to demonstrate that switching engines affects previously created HTML instances.

Testing

  • No automated tests were executed as part of this change; the new tests were added but not run here.
  • To run the tests locally, execute make test or pytest tests/test_html.py::TestHTML::test_engine_is_global_for_existing_instances tests/test_html.py::TestHTML::test_engine_switching_affects_previous_instance.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants