diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-03-28 09:37:09 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-04-01 17:36:14 -0400 |
commit | faace13868571cc482c7e4ebcbbed83aa349d2d6 (patch) | |
tree | 6ac344c48f12fe86e752e697d8d0cbff47fe3eb5 /test/functional/test_framework | |
parent | 8394300859e69141fc62a5c120448f3311e5cc6a (diff) |
qa: Match full plain text by default
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/test_node.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 291ac3ee46..4a4ab046c5 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -6,6 +6,7 @@ import decimal import errno +from enum import Enum import http.client import json import logging @@ -35,6 +36,12 @@ class FailedToStartError(Exception): """Raised when a node fails to start correctly.""" +class ErrorMatch(Enum): + FULL_TEXT = 1 + FULL_REGEX = 2 + PARTIAL_REGEX = 3 + + class TestNode(): """A class for representing a bitcoind node under test. @@ -172,7 +179,7 @@ class TestNode(): def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT): wait_until(self.is_node_stopped, timeout=timeout) - def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, partial_match=False, *args, **kwargs): + def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, match=ErrorMatch.FULL_TEXT, *args, **kwargs): """Attempt to start the node and expect it to raise an error. extra_args: extra arguments to pass through to bitcoind @@ -194,12 +201,15 @@ class TestNode(): if expected_msg is not None: log_stderr.seek(0) stderr = log_stderr.read().decode('utf-8').strip() - if partial_match: + if match == ErrorMatch.PARTIAL_REGEX: if re.search(expected_msg, stderr, flags=re.MULTILINE) is None: raise AssertionError('Expected message "{}" does not partially match stderr:\n"{}"'.format(expected_msg, stderr)) - else: + elif match == ErrorMatch.FULL_REGEX: if re.fullmatch(expected_msg, stderr) is None: raise AssertionError('Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr)) + elif match == ErrorMatch.FULL_TEXT: + if expected_msg != stderr: + raise AssertionError('Expected message "{}" does not fully match stderr:\n"{}"'.format(expected_msg, stderr)) else: if expected_msg is None: assert_msg = "bitcoind should have exited with an error" |