From 26e4a58cba1a16aff0fc07cee0928005393d6a0c Mon Sep 17 00:00:00 2001 From: Constantin Hong Date: Fri, 10 May 2024 01:44:06 +0900 Subject: [PATCH] tests/test_xpath_selector_unit/test: Add context node related tests --- .../tests/test_xpath_selector_unit.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/changedetectionio/tests/test_xpath_selector_unit.py b/changedetectionio/tests/test_xpath_selector_unit.py index 0d839d5a..db3d7f03 100644 --- a/changedetectionio/tests/test_xpath_selector_unit.py +++ b/changedetectionio/tests/test_xpath_selector_unit.py @@ -205,22 +205,39 @@ def test_trips(html_content, xpath, answer): DOM_violation_two_html_root_element = """ -

Hello world

+

Hello world1

First paragraph.

-

Hello world

+

Hello world2

Browsers parse this part by fixing it but lxml doesn't and returns two root element node

Therefore, if the path is /html/body/p[1], lxml(libxml2) returns two element nodes not one.

""" @pytest.mark.parametrize("html_content", [DOM_violation_two_html_root_element]) @pytest.mark.parametrize("xpath, answer", [ + (".", "Hello world1"), (".", "First paragraph."), + (".", "Hello world2"), + (".", "Browsers parse this part by fixing it but lxml doesn't and returns two root element node"), + (".", "Therefore, if the path is /html/body/p[1], lxml(libxml2) returns two element nodes not one."), + ("/*", "Hello world1"), ("/*", "First paragraph."), + ("/*", "Hello world2"), + ("/*", "Browsers parse this part by fixing it but lxml doesn't and returns two root element node"), + ("/*", "Therefore, if the path is /html/body/p[1], lxml(libxml2) returns two element nodes not one."), + ("html", "Hello world1"), + ("html", "First paragraph."), + ("html", "Hello world2"), + ("html", "Browsers parse this part by fixing it but lxml doesn't and returns two root element node"), + ("html", "Therefore, if the path is /html/body/p[1], lxml(libxml2) returns two element nodes not one."), + ("/html", "Hello world1"), ("/html", "First paragraph."), + ("/html", "Hello world2"), + ("/html", "Browsers parse this part by fixing it but lxml doesn't and returns two root element node"), + ("/html", "Therefore, if the path is /html/body/p[1], lxml(libxml2) returns two element nodes not one."), ("/html/body/p[1]", "First paragraph."), ("/html/body/p[1]", "Browsers parse this part by fixing it but lxml doesn't and returns two root element node"), ("count(/html/body/p[1])", "2"),