From 28e282ef9ae94ede4aace6b97ff18c66cb72a001 Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:39:16 +0200 Subject: [PATCH] qa: assert_raises_message() - Stop assuming certain structure for exceptions --- test/functional/test_framework/util.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 903dd1b2b5b..c35d41124dd 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -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: