Skip to content

Commit 28e282e

Browse files
committed
qa: assert_raises_message() - Stop assuming certain structure for exceptions
1 parent 1f639ef commit 28e282e

File tree

1 file changed

+3
-4
lines changed
  • test/functional/test_framework

1 file changed

+3
-4
lines changed

test/functional/test_framework/util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,9 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
101101
except JSONRPCException:
102102
raise AssertionError("Use assert_raises_rpc_error() to test RPC failures")
103103
except exc as e:
104-
if message is not None and message not in e.error['message']:
105-
raise AssertionError(
106-
"Expected substring not found in error message:\nsubstring: '{}'\nerror message: '{}'.".format(
107-
message, e.error['message']))
104+
if message is not None and message not in repr(e):
105+
raise AssertionError("Expected substring not found in exception:\n"
106+
f"substring: '{message}'\nexception: {repr(e)}.")
108107
except Exception as e:
109108
raise AssertionError("Unexpected exception raised: " + type(e).__name__)
110109
else:

0 commit comments

Comments
 (0)