MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / assert_raises_process_error

Function assert_raises_process_error

test/functional/test_framework/util.py:65–87  ·  view source on GitHub ↗

Execute a process and asserts the process return code and output. Calls function `fun` with arguments `args` and `kwds`. Catches a CalledProcessError and verifies that the return code and output are as expected. Throws AssertionError if no CalledProcessError was raised or if the return

(returncode, output, fun, *args, **kwds)

Source from the content-addressed store, hash-verified

63 raise AssertionError("No exception raised")
64
65def assert_raises_process_error(returncode, output, fun, *args, **kwds):
66 """Execute a process and asserts the process return code and output.
67
68 Calls function `fun` with arguments `args` and `kwds`. Catches a CalledProcessError
69 and verifies that the return code and output are as expected. Throws AssertionError if
70 no CalledProcessError was raised or if the return code and output are not as expected.
71
72 Args:
73 returncode (int): the process return code.
74 output (string): [a substring of] the process output.
75 fun (function): the function to call. This should execute a process.
76 args*: positional arguments for the function.
77 kwds**: named arguments for the function.
78 """
79 try:
80 fun(*args, **kwds)
81 except CalledProcessError as e:
82 if returncode != e.returncode:
83 raise AssertionError("Unexpected returncode %i" % e.returncode)
84 if output not in e.output:
85 raise AssertionError("Expected substring not found:" + e.output)
86 else:
87 raise AssertionError("No exception raised")
88
89def assert_raises_rpc_error(code, message, fun, *args, **kwds):
90 """Run an RPC and verify that a specific JSONRPC exception code and message is raised.

Callers 1

run_testMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected