Commit a61da413 authored by Nicolas Wavrant's avatar Nicolas Wavrant

test_equeue: do not read arbitrary length from socket

but read only as much as we expect to receive. It should make tests more
stable
parent 61f7e71c
...@@ -79,7 +79,7 @@ class TestEqueue(unittest.TestCase): ...@@ -79,7 +79,7 @@ class TestEqueue(unittest.TestCase):
equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
equeue_socket.connect(self.socket) equeue_socket.connect(self.socket)
equeue_socket.send(json.dumps(request).encode()) equeue_socket.send(json.dumps(request).encode())
result = equeue_socket.recv(1024) result = equeue_socket.recv(len(request['command']))
self.assertEqual(result.decode(), request['command']) self.assertEqual(result.decode(), request['command'])
equeue_socket.close() equeue_socket.close()
...@@ -114,7 +114,7 @@ class TestEqueue(unittest.TestCase): ...@@ -114,7 +114,7 @@ class TestEqueue(unittest.TestCase):
equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
equeue_socket.connect(self.socket) equeue_socket.connect(self.socket)
equeue_socket.send(json.dumps(request).encode()) equeue_socket.send(json.dumps(request).encode())
result = equeue_socket.recv(1024) result = equeue_socket.recv(len(request['command']))
self.assertEqual(result.decode(), request['command']) self.assertEqual(result.decode(), request['command'])
equeue_socket.close() equeue_socket.close()
...@@ -145,7 +145,7 @@ class TestEqueue(unittest.TestCase): ...@@ -145,7 +145,7 @@ class TestEqueue(unittest.TestCase):
equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
equeue_socket.connect(self.socket) equeue_socket.connect(self.socket)
equeue_socket.send(json.dumps(request).encode()) equeue_socket.send(json.dumps(request).encode())
result = equeue_socket.recv(1024) result = equeue_socket.recv(len(request['command']))
self.assertEqual(result.decode(), request['command']) self.assertEqual(result.decode(), request['command'])
equeue_socket.close() equeue_socket.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment