qa: assert_raises_message() - Stop assuming certain structure for exceptions
This commit is contained in:
1 file changed
+3
-4
@@ -101,10 +101,9 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
|
|||||||
except JSONRPCException:
|
except JSONRPCException:
|
||||||
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 repr(e):
|
||||||
raise AssertionError(
|
raise AssertionError("Expected substring not found in exception:\n"
|
||||||
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
|
f"substring: '{message}'\nexception: {repr(e)}.")
|
||||||
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:
|
||||||
|
|||||||
Reference in new issue
Block a user