diff options
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/test_node.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index dbdaf67201..8d88069108 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -169,8 +169,11 @@ class TestNode(): def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, *args, **kwargs): """Attempt to start the node and expect it to raise an error. + 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 appear in bitcoind's stdout.""" + Will throw if an expected_msg is provided and it does not match bitcoind's stdout.""" with tempfile.SpooledTemporaryFile(max_size=2**16) as log_stderr: try: self.start(extra_args, stderr=log_stderr, *args, **kwargs) @@ -181,11 +184,12 @@ class TestNode(): assert 'bitcoind exited' in str(e) # node must have shutdown self.running = False self.process = None + # Check stderr for expected message if expected_msg is not None: log_stderr.seek(0) stderr = log_stderr.read().decode('utf-8') - if expected_msg not in stderr: - raise AssertionError("Expected error \"" + expected_msg + "\" not found in:\n" + stderr) + if re.fullmatch(expected_msg + '\n', stderr) is None: + raise AssertionError('Expected message "{}" does not match stderr:\n"{}"'.format(expected_msg, stderr)) else: if expected_msg is None: assert_msg = "bitcoind should have exited with an error" |