diff options
author | John Newbery <john@johnnewbery.com> | 2017-07-12 10:29:02 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2017-10-05 09:48:46 -0400 |
commit | 5864e9c1611e6034a8d49b78231abe6bfade686d (patch) | |
tree | e8cec4a64d53873002d7ab327e2cd026802bc49e /test/functional/test_framework/util.py | |
parent | e93fff1463ae906fc986bf98c3b118c82f171546 (diff) | |
download | bitcoin-5864e9c1611e6034a8d49b78231abe6bfade686d.tar.xz |
[tests] remove direct testing on JSONRPCException from individual test cases
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 64966adb97..44d7e04a89 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -99,6 +99,13 @@ def assert_raises_jsonrpc(code, message, fun, *args, **kwds): args*: positional arguments for the function. kwds**: named arguments for the function. """ + assert try_rpc(code, message, fun, *args, **kwds), "No exception raised" + +def try_rpc(code, message, fun, *args, **kwds): + """Tries to run an rpc command. + + Test against error code and message if the rpc fails. + Returns whether a JSONRPCException was raised.""" try: fun(*args, **kwds) except JSONRPCException as e: @@ -107,10 +114,11 @@ def assert_raises_jsonrpc(code, message, fun, *args, **kwds): raise AssertionError("Unexpected JSONRPC error code %i" % e.error["code"]) if (message is not None) and (message not in e.error['message']): raise AssertionError("Expected substring not found:" + e.error['message']) + return True except Exception as e: raise AssertionError("Unexpected exception raised: " + type(e).__name__) else: - raise AssertionError("No exception raised") + return False def assert_is_hex_string(string): try: |