qa: Improve assert_start_raises_init_error output

Re-raising within the except-block would trigger excessive "During handling of the above exception, another exception occurred"-output.

Also changed comment - exceptions are raised in Python, not thrown.
This commit is contained in:
Hodlinator 2025-12-03 21:23:51 +01:00
parent 6581ac5d9f
commit fb43b2f8cc
No known key found for this signature in database

View File

@ -712,11 +712,12 @@ class TestNode():
extra_args: extra arguments to pass through to bitcoind
expected_msg: regex that stderr should match when bitcoind fails
Will throw if bitcoind starts without an error.
Will throw if an expected_msg is provided and it does not match bitcoind's stdout."""
Will raise if bitcoind starts without an error.
Will raise if an expected_msg is provided and it does not match bitcoind's stdout."""
assert not self.running
with tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False) as log_stderr, \
tempfile.NamedTemporaryFile(dir=self.stdout_dir, delete=False) as log_stdout:
assert_msg = None
try:
self.start(extra_args, stdout=log_stdout, stderr=log_stderr, *args, **kwargs)
ret = self.process.wait(timeout=self.rpc_timeout)
@ -740,7 +741,7 @@ class TestNode():
if expected_msg != stderr:
self._raise_assertion_error(
'Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr))
except subprocess.TimeoutExpired:
except subprocess.TimeoutExpired as e:
self.process.kill()
self.running = False
self.process = None
@ -749,6 +750,10 @@ class TestNode():
assert_msg += "with an error"
else:
assert_msg += "with expected error " + expected_msg
assert_msg += f" (cmd: {e.cmd})"
# Raise assertion outside of except-block above in order for it not to be treated as a knock-on exception.
if assert_msg:
self._raise_assertion_error(assert_msg)
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, send_version=True, supports_v2_p2p=None, wait_for_v2_handshake=True, expect_success=True, **kwargs):