From fe41ddbc51b4b7c6ce7d958ea7622983d7805b7e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 17 Feb 2024 13:52:16 +0000 Subject: Support attributes in HTML paths in style mappings --- tests/styles/parser/html_path_parser_tests.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/styles/parser/html_path_parser_tests.py b/tests/styles/parser/html_path_parser_tests.py index 0c2ef3a..6dd7032 100644 --- a/tests/styles/parser/html_path_parser_tests.py +++ b/tests/styles/parser/html_path_parser_tests.py @@ -53,6 +53,20 @@ def test_can_read_multiple_classes_on_element(): ) +def test_can_read_attribute_on_element(): + assert_equal( + html_paths.path([html_paths.element(["p"], attributes={"lang": "fr"})]), + read_html_path("p[lang='fr']") + ) + + +def test_can_read_multiple_attributes_on_element(): + assert_equal( + html_paths.path([html_paths.element(["p"], attributes={"lang": "fr", "data-x": "y"})]), + read_html_path("p[lang='fr'][data-x='y']") + ) + + def test_can_read_when_element_must_be_fresh(): assert_equal( html_paths.path([html_paths.element(["p"], fresh=True)]), -- cgit v1.2.3