mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-31 20:21:00 +02:00
test: Print both messages on failure in assert_raises_message
This commit is contained in:
@@ -56,7 +56,9 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
|
|||||||
raise AssertionError("Use assert_raises_rpc_error() to test RPC failures")
|
raise AssertionError("Use assert_raises_rpc_error() to test RPC failures")
|
||||||
except exc as e:
|
except exc as e:
|
||||||
if message is not None and message not in e.error['message']:
|
if message is not None and message not in e.error['message']:
|
||||||
raise AssertionError("Expected substring not found:" + e.error['message'])
|
raise AssertionError(
|
||||||
|
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
|
||||||
|
message, e.error['message']))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
|
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
|
||||||
else:
|
else:
|
||||||
@@ -116,7 +118,9 @@ def try_rpc(code, message, fun, *args, **kwds):
|
|||||||
if (code is not None) and (code != e.error["code"]):
|
if (code is not None) and (code != e.error["code"]):
|
||||||
raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
|
raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
|
||||||
if (message is not None) and (message not in e.error['message']):
|
if (message is not None) and (message not in e.error['message']):
|
||||||
raise AssertionError("Expected substring not found:" + e.error['message'])
|
raise AssertionError(
|
||||||
|
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
|
||||||
|
message, e.error['message']))
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
|
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
|
||||||
|
Reference in New Issue
Block a user