diff --git a/test/functional/test_framework/chronik/client.py b/test/functional/test_framework/chronik/client.py --- a/test/functional/test_framework/chronik/client.py +++ b/test/functional/test_framework/chronik/client.py @@ -6,7 +6,13 @@ import http.client from typing import Union -import websocket +# websocket-client is needed in this module but may not be installed on +# all systems. Since this module is imported in multiple tests, we attempt +# to import websocket-client here and check it before use. +try: + import websocket +except ImportError: + websocket = None # Timespan when HTTP requests to Chronik time out DEFAULT_TIMEOUT = 30 @@ -134,6 +140,9 @@ return ChronikScriptClient(self, script_type, script_payload) def ws(self, *, timeout=None) -> ChronikWs: + if websocket is None: + raise ImportError( + "websocket-client is not installed, but is needed for chronik tests") ws = websocket.WebSocket() ws.connect(f'ws://{self.host}:{self.port}/ws', timeout=timeout) return ChronikWs(ws)