diff --git a/tests/test_raw_bytes_send.py b/tests/test_raw_bytes_send.py index fc150163..ebc0b7ce 100644 --- a/tests/test_raw_bytes_send.py +++ b/tests/test_raw_bytes_send.py @@ -1,3 +1,4 @@ +import copy import random import unittest @@ -42,12 +43,12 @@ def test_send_recv_raw_bytes(self): for j in range(random.randint(10, 20)): d = msg.request.index.docs.add() d.raw_bytes = b'a' * random.randint(100, 1000) - raw_bytes = [d.raw_bytes for d in msg.request.index.docs] + raw_bytes = copy.deepcopy([d.raw_bytes for d in msg.request.index.docs]) c1.send_message(msg, squeeze_pb=True) r_msg = c2.recv_message() - for d, r_d in zip(msg.request.index.docs, r_msg.request.index.docs): + for d, o_d, r_d in zip(msg.request.index.docs, raw_bytes, r_msg.request.index.docs): self.assertEqual(d.raw_bytes, b'') - self.assertEqual(raw_bytes, r_d.raw_bytes) + self.assertEqual(o_d, r_d.raw_bytes) print('.', end='') print('checked %d docs' % len(msg.request.index.docs)) @@ -127,15 +128,15 @@ def test_benchmark2(self): def test_benchmark3(self): all_msgs = self.build_msgs() + all_msgs_bak = copy.deepcopy(all_msgs) with ZmqClient(self.c1_args) as c1, ZmqClient(self.c2_args) as c2: - for m in all_msgs: - raw_bytes = [d.raw_bytes for d in m.request.index.docs] + for m, m1 in zip(all_msgs, all_msgs_bak): c1.send_message(m, squeeze_pb=True) r_m = c2.recv_message() - for d, r_d in zip(m.request.index.docs, r_m.request.index.docs): + for d, o_d, r_d in zip(m.request.index.docs, m1.request.index.docs, r_m.request.index.docs): self.assertEqual(d.raw_bytes, b'') - self.assertEqual(raw_bytes, r_d.raw_bytes) + self.assertEqual(o_d.raw_bytes, r_d.raw_bytes) def test_benchmark4(self): all_msgs = self.build_msgs2() @@ -154,7 +155,7 @@ def test_benchmark4(self): def test_benchmark5(self): all_msgs = self.build_msgs2() - all_msgs_bak = self.build_msgs2() + all_msgs_bak = copy.deepcopy(all_msgs) with ZmqClient(self.c1_args) as c1, ZmqClient(self.c2_args) as c2: with TimeContext('send->recv, squeeze_pb=True'): @@ -165,4 +166,4 @@ def test_benchmark5(self): for d, r_d in zip(m1.request.index.docs, r_m.request.index.docs): for c, r_c in zip(d.chunks, r_d.chunks): np.allclose(blob2array(c.embedding), blob2array(r_c.embedding)) - np.allclose(blob2array(c.blob), blob2array(r_c.blob)) + np.allclose(blob2array(c.blob), blob2array(r_c.blob)) \ No newline at end of file