MCPcopy
hub / github.com/igrek51/wat / assert_multiline_match

Function assert_multiline_match

tests/asserts.py:63–75  ·  view source on GitHub ↗
(text: str, regex_pattern: str)

Source from the content-addressed store, hash-verified

61
62
63def assert_multiline_match(text: str, regex_pattern: str):
64 regex_lines = regex_pattern.strip().splitlines()
65 text_lines = strip_ansi_colors(text).strip().splitlines()
66
67 if len(text_lines) < len(regex_lines):
68 assert False, f'Actual text has {len(regex_lines) - len(text_lines)} less lines than a pattern.\nActual text:\n{text}'
69
70 if len(text_lines) > len(regex_lines):
71 assert False, f'Actual text has {len(text_lines) - len(regex_lines)} more lines than a pattern.\nActual text:\n{text}'
72
73 for index, (regex_line, text_line) in enumerate(zip(regex_lines, text_lines)):
74 match = re.fullmatch(regex_line, text_line)
75 assert match, f'Actual Line #{index+1}:\n{text_line}\n does not match the Regex pattern:\n{regex_line}'
76
77
78def get_logger_handler(logger: logging.Logger) -> Optional[logging.Handler]:

Calls

no outgoing calls

Tested by 15

test_inspect_instanceFunction · 0.72
test_inspect_functionFunction · 0.72
test_inspect_nested_dictFunction · 0.72
test_inspect_async_defFunction · 0.72
test_wat_with_objectFunction · 0.72
test_list_parent_classesFunction · 0.72