[tests] skip rpc_zmq functional test when python3 zmq lib is not present

Also refactors zmq-related test skipping logic into distinct functions.
This commit is contained in:
James O'Beirne 2018-07-12 11:52:02 -04:00
parent dcb154e5aa
commit a0b604c166
3 changed files with 26 additions and 15 deletions
test/functional/test_framework

View file

@ -475,3 +475,20 @@ 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.")
def skip_if_no_bitcoind_zmq(test_instance):
"""Skip the running test if bitcoind has not been compiled with zmq support."""
config = configparser.ConfigParser()
config.read_file(open(test_instance.options.configfile))
if not config["components"].getboolean("ENABLE_ZMQ"):
raise SkipTest("bitcoind has not been built with zmq enabled.")