From cb5b3bfadd486f64be6f807546f4022204099a41 Mon Sep 17 00:00:00 2001 From: Jerry Boonstra Date: Mon, 27 Dec 2021 16:24:37 -0800 Subject: [PATCH 1/2] This is a failure situation that should yield an error. Currently this situation is only logged to error with no return value. This clearly should instead throw an exception like elsewhere in the code. --- pybit/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pybit/__init__.py b/pybit/__init__.py index 03557ad..dc5e88f 100644 --- a/pybit/__init__.py +++ b/pybit/__init__.py @@ -2045,8 +2045,7 @@ def fetch(self, topic): topic = self.conform_topic(topic) # If the topic given isn't in the initial subscribed list. if topic not in self.subscriptions: - self.logger.error(f'You aren\'t subscribed to the {topic} topic.') - return + raise Exception(f"You aren\'t subscribed to the {topic} topic.") # Pop all trade or execution data on each poll. # don't pop order or stop_order data as we will lose valuable state From 8a755c8e4c938ead09f67859dbf3fc31b92e3014 Mon Sep 17 00:00:00 2001 From: Jerry Boonstra Date: Mon, 27 Dec 2021 18:39:54 -0800 Subject: [PATCH 2/2] fix test to pass correct argument --- tests/test_pybit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_pybit.py b/tests/test_pybit.py index 368264b..86dc492 100644 --- a/tests/test_pybit.py +++ b/tests/test_pybit.py @@ -62,6 +62,6 @@ class WebSocketTest(unittest.TestCase): # A very simple test to ensure we're getting something from WS. def test_websocket(self): self.assertNotEqual( - ws.fetch(['instrument_info.100ms.BTCUSD']), + ws.fetch('instrument_info.100ms.BTCUSD'), [] - ) \ No newline at end of file + )