mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-23 07:15:29 +01:00
test: Print both messages on failure in assert_raises_message
This commit is contained in:
parent
faa13539d5
commit
fab3c34412
1 changed files with 6 additions and 2 deletions
|
@ -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__)
|
||||||
|
|
Loading…
Add table
Reference in a new issue