Skip to content

Commit 409d0d6

Browse files
committed
test: enable running individual independent functional test methods
- Some test methods in the functional test framework are independent and do not require any previous context or setup defined in `run_test`. - This commit adds a new option for running these specific methods within a test file, allowing them to be executed individually without running the entire test suite. - running test methods that require an argument or context will fail.
1 parent 0903ce8 commit 409d0d6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/functional/test_framework/test_framework.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ def main(self):
129129

130130
try:
131131
self.setup()
132-
self.run_test()
132+
if self.options.test_methods:
133+
self.run_test_methods()
134+
else:
135+
self.run_test()
136+
133137
except JSONRPCException:
134138
self.log.exception("JSONRPC error")
135139
self.success = TestStatus.FAILED
@@ -155,6 +159,13 @@ def main(self):
155159
exit_code = self.shutdown()
156160
sys.exit(exit_code)
157161

162+
def run_test_methods(self):
163+
for method_name in self.options.test_methods:
164+
self.log.info(f"Attempting to execute method: {method_name}")
165+
method = getattr(self, method_name)
166+
method()
167+
self.log.info(f"Method '{method_name}' executed successfully.")
168+
158169
def parse_args(self, test_file):
159170
previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
160171
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
@@ -194,6 +205,8 @@ def parse_args(self, test_file):
194205
help="use BIP324 v2 connections between all nodes by default")
195206
parser.add_argument("--v1transport", dest="v1transport", default=False, action="store_true",
196207
help="Explicitly use v1 transport (can be used to overwrite global --v2transport option)")
208+
parser.add_argument("--test_methods", dest="test_methods", nargs='*',
209+
help="Run specified test methods sequentially instead of the full test. Use only for methods that do not depend on any context set up in run_test or other methods.")
197210

198211
self.add_options(parser)
199212
# Running TestShell in a Jupyter notebook causes an additional -f argument

0 commit comments

Comments
 (0)