qa: assert_raises_message() - Stop assuming certain structure for exceptions

This commit is contained in:
Hodlinator
2025-04-25 14:39:16 +02:00
parent 1f639efca5
commit 28e282ef9a

View File

@@ -101,10 +101,9 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
except JSONRPCException:
raise AssertionError("Use assert_raises_rpc_error() to test RPC failures")
except exc as e:
if message is not None and message not in e.error['message']:
raise AssertionError(
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
message, e.error['message']))
if message is not None and message not in repr(e):
raise AssertionError("Expected substring not found in exception:\n"
f"substring: '{message}'\nexception: {repr(e)}.")
except Exception as e:
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
else: