From 6014d6e1b5a0dda6e20c2721f0bdb7e6a63ece81 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sat, 23 Jan 2021 22:19:15 +0100 Subject: [PATCH] zmq test: dedup message reception handling in ZMQSubscriber --- test/functional/interface_zmq.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py index e9f61be4d42..4c23c4d30c1 100755 --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -33,7 +33,8 @@ class ZMQSubscriber: self.socket.setsockopt(zmq.SUBSCRIBE, self.topic) - def receive(self): + # Receive message from publisher and verify that topic and sequence match + def _receive_from_publisher_and_check(self): topic, body, seq = self.socket.recv_multipart() # Topic should match the subscriber topic. assert_equal(topic, self.topic) @@ -42,13 +43,11 @@ class ZMQSubscriber: self.sequence += 1 return body + def receive(self): + return self._receive_from_publisher_and_check() + def receive_sequence(self): - topic, body, seq = self.socket.recv_multipart() - # Topic should match the subscriber topic. - assert_equal(topic, self.topic) - # Sequence should be incremental. - assert_equal(struct.unpack('