20
20
from . import coverage
21
21
from .authproxy import AuthServiceProxy , JSONRPCException
22
22
from io import BytesIO
23
+ from typing import Callable , Optional
23
24
24
25
logger = logging .getLogger ("TestFramework.utils" )
25
26
@@ -80,17 +81,17 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
80
81
raise AssertionError ("No exception raised" )
81
82
82
83
83
- def assert_raises_process_error (returncode , output , fun , * args , ** kwds ):
84
+ def assert_raises_process_error (returncode : int , output : str , fun : Callable , * args , ** kwds ):
84
85
"""Execute a process and asserts the process return code and output.
85
86
86
87
Calls function `fun` with arguments `args` and `kwds`. Catches a CalledProcessError
87
88
and verifies that the return code and output are as expected. Throws AssertionError if
88
89
no CalledProcessError was raised or if the return code and output are not as expected.
89
90
90
91
Args:
91
- returncode (int) : the process return code.
92
- output (string) : [a substring of] the process output.
93
- fun (function) : the function to call. This should execute a process.
92
+ returncode: the process return code.
93
+ output: [a substring of] the process output.
94
+ fun: the function to call. This should execute a process.
94
95
args*: positional arguments for the function.
95
96
kwds**: named arguments for the function.
96
97
"""
@@ -105,19 +106,19 @@ def assert_raises_process_error(returncode, output, fun, *args, **kwds):
105
106
raise AssertionError ("No exception raised" )
106
107
107
108
108
- def assert_raises_rpc_error (code , message , fun , * args , ** kwds ):
109
+ def assert_raises_rpc_error (code : Optional [ int ] , message : Optional [ str ] , fun : Callable , * args , ** kwds ):
109
110
"""Run an RPC and verify that a specific JSONRPC exception code and message is raised.
110
111
111
112
Calls function `fun` with arguments `args` and `kwds`. Catches a JSONRPCException
112
113
and verifies that the error code and message are as expected. Throws AssertionError if
113
114
no JSONRPCException was raised or if the error code/message are not as expected.
114
115
115
116
Args:
116
- code (int), optional : the error code returned by the RPC call (defined
117
- in src/rpc/protocol.h). Set to None if checking the error code is not required.
118
- message (string), optional : [a substring of] the error string returned by the
119
- RPC call. Set to None if checking the error string is not required.
120
- fun (function) : the function to call. This should be the name of an RPC.
117
+ code: the error code returned by the RPC call (defined in src/rpc/protocol.h).
118
+ Set to None if checking the error code is not required.
119
+ message: [a substring of] the error string returned by the RPC call.
120
+ Set to None if checking the error string is not required.
121
+ fun: the function to call. This should be the name of an RPC.
121
122
args*: positional arguments for the function.
122
123
kwds**: named arguments for the function.
123
124
"""
0 commit comments