Improving functionalities and adding unit tests
This commit is contained in:
@@ -43,6 +43,12 @@ class Contains:
|
||||
"""
|
||||
s: str
|
||||
|
||||
@dataclasses.dataclass
|
||||
class DoesNotContain:
|
||||
"""
|
||||
To check if the attribute does not contain a specific value
|
||||
"""
|
||||
s: str
|
||||
|
||||
@dataclasses.dataclass
|
||||
class JsonViewerNode:
|
||||
@@ -449,6 +455,11 @@ def matches(actual, expected, path=""):
|
||||
elif isinstance(expected.attrs[expected_attr], Contains):
|
||||
assert expected.attrs[expected_attr].s in actual.attrs[expected_attr], \
|
||||
f"{print_path(path)}Attribute '{expected_attr}' does not contain '{expected.attrs[expected_attr].s}': actual='{actual.attrs[expected_attr]}', expected ='{expected.attrs[expected_attr].s}'."
|
||||
|
||||
elif isinstance(expected.attrs[expected_attr], DoesNotContain):
|
||||
assert expected.attrs[expected_attr].s not in actual.attrs[expected_attr], \
|
||||
f"{print_path(path)}Attribute '{expected_attr}' does contain '{expected.attrs[expected_attr].s}' while it must not: actual='{actual.attrs[expected_attr]}'."
|
||||
|
||||
|
||||
else:
|
||||
assert actual.attrs[expected_attr] == expected.attrs[expected_attr], \
|
||||
@@ -750,13 +761,14 @@ def icon(name: str):
|
||||
return NotStr(f'<svg name="{name}"')
|
||||
|
||||
|
||||
def div_icon(name: str):
|
||||
def div_icon(name: str, cls=None):
|
||||
"""
|
||||
Test if an element is an icon wrapped in a div
|
||||
:param name:
|
||||
:param cls:
|
||||
:return:
|
||||
"""
|
||||
return Div(NotStr(f'<svg name="{name}"'))
|
||||
return Div(NotStr(f'<svg name="{name}"'), cls=cls)
|
||||
|
||||
|
||||
def span_icon(name: str):
|
||||
|
||||
Reference in New Issue
Block a user