qa: assert_raises_message() - search in str(e)

repr() is annoying because it requires escaping special characters, use str() instead.

Original discussion: https://github.com/bitcoin/bitcoin/pull/30660#discussion_r2080292165
This commit is contained in:
Hodlinator
2025-05-14 16:19:23 +02:00
parent bd8ebbc4ab
commit 075352ec8e
2 changed files with 6 additions and 6 deletions

View File

@@ -101,9 +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 repr(e):
if message is not None and message not in str(e):
raise AssertionError("Expected substring not found in exception:\n"
f"substring: '{message}'\nexception: {repr(e)}.")
f"substring: '{message}'\nexception: {e!r}.")
except Exception as e:
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
else: