aboutsummaryrefslogtreecommitdiff
path: root/test/functional/zmq_test.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-03-24 18:36:55 -0400
committerJohn Newbery <john@johnnewbery.com>2017-04-20 11:25:33 -0400
commit6803e09e6eeb2dbc820bb1025475a50a4352e30d (patch)
treefd0c65c5f69e4d85ec4a247abefa07aef3b91294 /test/functional/zmq_test.py
parent987a6c09562e1e1e9d6623b999ae9de268490e4b (diff)
downloadbitcoin-6803e09e6eeb2dbc820bb1025475a50a4352e30d.tar.xz
Move zmq test skipping logic into individual test case.
This commit uses the new skip test funcationality added in 232b6665bc3e5b134821dc7584968fb439fd5f44 to skip the zmq tests if the python zmq module is not available or if bitcoind has been built without zmq support. This removes the zmq-specific logic from test_runner.py. In general it's better if test_runner.py has no knowledge of special cases for individual tests and is a general purpose test runner.
Diffstat (limited to 'test/functional/zmq_test.py')
-rwxr-xr-xtest/functional/zmq_test.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/functional/zmq_test.py b/test/functional/zmq_test.py
index 9e27b46381..891b609ffa 100755
--- a/test/functional/zmq_test.py
+++ b/test/functional/zmq_test.py
@@ -3,11 +3,13 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the ZMQ API."""
+import configparser
+import os
+import struct
+import sys
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import zmq
-import struct
class ZMQTest (BitcoinTestFramework):
@@ -18,6 +20,21 @@ class ZMQTest (BitcoinTestFramework):
port = 28332
def setup_nodes(self):
+ # Try to import python3-zmq. Skip this test if the import fails.
+ try:
+ import zmq
+ except ImportError:
+ self.log.warning("python3-zmq module not available. Skipping zmq tests!")
+ sys.exit(self.TEST_EXIT_SKIPPED)
+
+ # Check that bitcoin has been built with ZMQ enabled
+ config = configparser.ConfigParser()
+ config.read_file(open(os.path.dirname(__file__) + "/config.ini"))
+
+ if not config["components"].getboolean("ENABLE_ZMQ"):
+ self.log.warning("bitcoind has not been built with zmq enabled. Skipping zmq tests!")
+ sys.exit(self.TEST_EXIT_SKIPPED)
+
self.zmqContext = zmq.Context()
self.zmqSubSocket = self.zmqContext.socket(zmq.SUB)
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"hashblock")