diff options
author | John Newbery <john@johnnewbery.com> | 2018-02-07 10:38:25 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-03-18 13:32:50 -0400 |
commit | 58122736b53390a2013630e95ff760800af160e7 (patch) | |
tree | 386b714cff790ba9fae18135bb91c13455802e09 /test/functional/test_framework/test_node.py | |
parent | 0ec08a672dce3f619e46d0c7455e95a13dc5c4e2 (diff) |
[Tests] Require exact match in assert_start_raises_init_eror()
Diffstat (limited to 'test/functional/test_framework/test_node.py')
-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" |