Skip to content

Commit fab3c34

Browse files
author
MarcoFalke
committed
test: Print both messages on failure in assert_raises_message
1 parent faa1353 commit fab3c34

File tree

1 file changed

+6
-2
lines changed
  • test/functional/test_framework

1 file changed

+6
-2
lines changed

test/functional/test_framework/util.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
5656
raise AssertionError("Use assert_raises_rpc_error() to test RPC failures")
5757
except exc as e:
5858
if message is not None and message not in e.error['message']:
59-
raise AssertionError("Expected substring not found:" + e.error['message'])
59+
raise AssertionError(
60+
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
61+
message, e.error['message']))
6062
except Exception as e:
6163
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
6264
else:
@@ -116,7 +118,9 @@ def try_rpc(code, message, fun, *args, **kwds):
116118
if (code is not None) and (code != e.error["code"]):
117119
raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"])
118120
if (message is not None) and (message not in e.error['message']):
119-
raise AssertionError("Expected substring not found:" + e.error['message'])
121+
raise AssertionError(
122+
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
123+
message, e.error['message']))
120124
return True
121125
except Exception as e:
122126
raise AssertionError("Unexpected exception raised: " + type(e).__name__)

0 commit comments

Comments
 (0)