Skip to content

Commit fae91a0

Browse files
author
MarcoFalke
committed
test: Remove incorrect and unused try-block in assert_debug_log
1 parent 6e43129 commit fae91a0

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

test/functional/rpc_setban.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def run_test(self):
2626
self.nodes[1].setban("127.0.0.1", "add")
2727

2828
# Node 0 should not be able to reconnect
29-
with self.nodes[1].assert_debug_log(expected_msgs=['dropped (banned)\n'],timeout=5):
29+
with self.nodes[1].assert_debug_log(expected_msgs=['dropped (banned)\n'], timeout=5):
3030
self.restart_node(1, [])
3131
self.nodes[0].addnode("127.0.0.1:" + str(p2p_port(1)), "onetry")
3232

test/functional/test_framework/test_node.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,24 +313,24 @@ def assert_debug_log(self, expected_msgs, timeout=2):
313313
with open(debug_log, encoding='utf-8') as dl:
314314
dl.seek(0, 2)
315315
prev_size = dl.tell()
316-
try:
317-
yield
318-
finally:
319-
while True:
320-
found = True
321-
with open(debug_log, encoding='utf-8') as dl:
322-
dl.seek(prev_size)
323-
log = dl.read()
324-
print_log = " - " + "\n - ".join(log.splitlines())
325-
for expected_msg in expected_msgs:
326-
if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
327-
found = False
328-
if found:
329-
return
330-
if time.time() >= time_end:
331-
break
332-
time.sleep(0.05)
333-
self._raise_assertion_error('Expected messages "{}" does not partially match log:\n\n{}\n\n'.format(str(expected_msgs), print_log))
316+
317+
yield
318+
319+
while True:
320+
found = True
321+
with open(debug_log, encoding='utf-8') as dl:
322+
dl.seek(prev_size)
323+
log = dl.read()
324+
print_log = " - " + "\n - ".join(log.splitlines())
325+
for expected_msg in expected_msgs:
326+
if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
327+
found = False
328+
if found:
329+
return
330+
if time.time() >= time_end:
331+
break
332+
time.sleep(0.05)
333+
self._raise_assertion_error('Expected messages "{}" does not partially match log:\n\n{}\n\n'.format(str(expected_msgs), print_log))
334334

335335
@contextlib.contextmanager
336336
def assert_memory_usage_stable(self, *, increase_allowed=0.03):

0 commit comments

Comments
 (0)