diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index bc8cd0e82cbc0..7e8c40cf162c5 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -129,7 +129,11 @@ def main(self): try: self.setup() - self.run_test() + if self.options.test_methods: + self.run_test_methods() + else: + self.run_test() + except JSONRPCException: self.log.exception("JSONRPC error") self.success = TestStatus.FAILED @@ -155,6 +159,13 @@ def main(self): exit_code = self.shutdown() sys.exit(exit_code) + def run_test_methods(self): + for method_name in self.options.test_methods: + self.log.info(f"Attempting to execute method: {method_name}") + method = getattr(self, method_name) + method() + self.log.info(f"Method '{method_name}' executed successfully.") + def parse_args(self, test_file): previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases" parser = argparse.ArgumentParser(usage="%(prog)s [options]") @@ -194,6 +205,8 @@ def parse_args(self, test_file): help="use BIP324 v2 connections between all nodes by default") parser.add_argument("--v1transport", dest="v1transport", default=False, action="store_true", help="Explicitly use v1 transport (can be used to overwrite global --v2transport option)") + parser.add_argument("--test_methods", dest="test_methods", nargs='*', + 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.") self.add_options(parser) # Running TestShell in a Jupyter notebook causes an additional -f argument