Improving functionalities and adding unit tests

This commit is contained in:
2025-07-25 09:50:36 +02:00
parent aa8aa8f58c
commit fb82365980
4 changed files with 151 additions and 34 deletions

View File

@@ -57,7 +57,8 @@ def sample_structure():
"Path 'div[class=a long attr]':\n\tAttribute 'class' does not start with 'different start': actual='a long attr', expected ='different start'."),
(Div(cls="a long attr"), Div(cls=Contains("not included")),
"Path 'div[class=a long attr]':\n\tAttribute 'class' does not contain 'not included': actual='a long attr', expected ='not included'."),
(Div(cls="a long attr"), Div(cls=DoesNotContain("long attr")),
"Path 'div[class=a long attr]':\n\tAttribute 'class' does contain 'long attr' while it must not: actual='a long attr'."),
])
def test_matches_error_expected(value, expected, expected_error):
with pytest.raises(AssertionError) as error:
@@ -75,6 +76,7 @@ def test_matches_error_expected(value, expected, expected_error):
(Div(), Div(Empty)),
(Div(cls="a long attr"), Div(cls=StartsWith("a long"))),
(Div(cls="a long attr"), Div(cls=Contains("long"))),
(Div(cls="a long attr"), Div(cls=DoesNotContain("xxxx"))),
])
def test_matches_success_expected(value, expected):
assert matches(value, expected)