Skip to content

Commit a03a586

Browse files
Add regex parsing for test logs
1 parent 5b9f4ad commit a03a586

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/functional/test_framework/test_node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def debug_log_size(self, **kwargs) -> int:
488488
return dl.tell()
489489

490490
@contextlib.contextmanager
491-
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
491+
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2, with_regex=False):
492492
if unexpected_msgs is None:
493493
unexpected_msgs = []
494494
assert_equal(type(expected_msgs), list)
@@ -506,10 +506,10 @@ def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
506506
log = dl.read()
507507
print_log = " - " + "\n - ".join(log.splitlines())
508508
for unexpected_msg in unexpected_msgs:
509-
if re.search(re.escape(unexpected_msg), log, flags=re.MULTILINE):
509+
if re.search(unexpected_msg if with_regex else re.escape(unexpected_msg), log, flags=re.MULTILINE):
510510
self._raise_assertion_error('Unexpected message "{}" partially matches log:\n\n{}\n\n'.format(unexpected_msg, print_log))
511511
for expected_msg in expected_msgs:
512-
if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
512+
if re.search(expected_msg if with_regex else re.escape(expected_msg), log, flags=re.MULTILINE) is None:
513513
found = False
514514
if found:
515515
return

0 commit comments

Comments
 (0)