Skip to content

Commit b043ca8

Browse files
committed
test: convert docs into type annotations in test_framework/util.py
1 parent 6fe012c commit b043ca8

File tree

1 file changed

+11
-10
lines changed
  • test/functional/test_framework

1 file changed

+11
-10
lines changed

test/functional/test_framework/util.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from . import coverage
2121
from .authproxy import AuthServiceProxy, JSONRPCException
2222
from io import BytesIO
23+
from typing import Callable, Optional
2324

2425
logger = logging.getLogger("TestFramework.utils")
2526

@@ -80,17 +81,17 @@ def assert_raises_message(exc, message, fun, *args, **kwds):
8081
raise AssertionError("No exception raised")
8182

8283

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):
8485
"""Execute a process and asserts the process return code and output.
8586
8687
Calls function `fun` with arguments `args` and `kwds`. Catches a CalledProcessError
8788
and verifies that the return code and output are as expected. Throws AssertionError if
8889
no CalledProcessError was raised or if the return code and output are not as expected.
8990
9091
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.
9495
args*: positional arguments for the function.
9596
kwds**: named arguments for the function.
9697
"""
@@ -105,19 +106,19 @@ def assert_raises_process_error(returncode, output, fun, *args, **kwds):
105106
raise AssertionError("No exception raised")
106107

107108

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):
109110
"""Run an RPC and verify that a specific JSONRPC exception code and message is raised.
110111
111112
Calls function `fun` with arguments `args` and `kwds`. Catches a JSONRPCException
112113
and verifies that the error code and message are as expected. Throws AssertionError if
113114
no JSONRPCException was raised or if the error code/message are not as expected.
114115
115116
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.
121122
args*: positional arguments for the function.
122123
kwds**: named arguments for the function.
123124
"""

0 commit comments

Comments
 (0)