aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_framework.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/test_framework/test_framework.py')
-rwxr-xr-xtest/functional/test_framework/test_framework.py71
1 files changed, 49 insertions, 22 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index afb0983953..57c985b2a2 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -44,6 +44,13 @@ TEST_EXIT_FAILED = 1
TEST_EXIT_SKIPPED = 77
+class SkipTest(Exception):
+ """This exception is raised to skip a test"""
+
+ def __init__(self, message):
+ self.message = message
+
+
class BitcoinTestMetaClass(type):
"""Metaclass for BitcoinTestFramework.
@@ -156,6 +163,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
try:
if self.options.usecli and not self.supports_cli:
raise SkipTest("--usecli specified but test does not support using CLI")
+ self.skip_test_if_missing_module()
self.setup_chain()
self.setup_network()
self.import_deterministic_coinbase_privkeys()
@@ -221,6 +229,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
"""Override this method to add command-line options to the test"""
pass
+ def skip_test_if_missing_module(self):
+ """Override this method to skip a test if a module is not compiled"""
+ pass
+
def setup_chain(self):
"""Override this method to customize blockchain setup"""
self.log.info("Initializing test directory " + self.options.tmpdir)
@@ -486,30 +498,45 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
for i in range(self.num_nodes):
initialize_datadir(self.options.tmpdir, i)
+ def skip_if_no_py3_zmq(self):
+ """Attempt to import the zmq package and skip the test if the import fails."""
+ try:
+ import zmq # noqa
+ except ImportError:
+ raise SkipTest("python3-zmq module not available.")
+
+ def skip_if_no_bitcoind_zmq(self):
+ """Skip the running test if bitcoind has not been compiled with zmq support."""
+ if not self.is_zmq_compiled():
+ raise SkipTest("bitcoind has not been built with zmq enabled.")
+
+ def skip_if_no_wallet(self):
+ """Skip the running test if wallet has not been compiled."""
+ if not self.is_wallet_compiled():
+ raise SkipTest("wallet has not been compiled.")
+
+ def skip_if_no_cli(self):
+ """Skip the running test if bitcoin-cli has not been compiled."""
+ if not self.is_cli_compiled():
+ raise SkipTest("bitcoin-cli has not been compiled.")
+
+ def is_cli_compiled(self):
+ """Checks whether bitcoin-cli was compiled."""
+ config = configparser.ConfigParser()
+ config.read_file(open(self.options.configfile))
-class SkipTest(Exception):
- """This exception is raised to skip a test"""
- def __init__(self, message):
- self.message = message
-
-
-def skip_if_no_py3_zmq():
- """Attempt to import the zmq package and skip the test if the import fails."""
- try:
- import zmq # noqa
- except ImportError:
- raise SkipTest("python3-zmq module not available.")
-
+ return config["components"].getboolean("ENABLE_UTILS")
-def skip_if_no_bitcoind_zmq(test_instance):
- """Skip the running test if bitcoind has not been compiled with zmq support."""
- if not is_zmq_enabled(test_instance):
- raise SkipTest("bitcoind has not been built with zmq enabled.")
+ def is_wallet_compiled(self):
+ """Checks whether the wallet module was compiled."""
+ config = configparser.ConfigParser()
+ config.read_file(open(self.options.configfile))
+ return config["components"].getboolean("ENABLE_WALLET")
-def is_zmq_enabled(test_instance):
- """Checks whether zmq is enabled or not."""
- config = configparser.ConfigParser()
- config.read_file(open(test_instance.options.configfile))
+ def is_zmq_compiled(self):
+ """Checks whether the zmq module was compiled."""
+ config = configparser.ConfigParser()
+ config.read_file(open(self.options.configfile))
- return config["components"].getboolean("ENABLE_ZMQ")
+ return config["components"].getboolean("ENABLE_ZMQ")