mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 10:41:08 +00:00
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:
parent
6581ac5d9f
commit
fb43b2f8cc
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user