From fe692d6437980c2a691b03fc85a23230ef128c38 Mon Sep 17 00:00:00 2001 From: Kaliko Jack Date: Sat, 5 Dec 2020 10:30:56 +0100 Subject: [PATCH] Fixed 7cb6ba6, s/recv/read/ No recv method in _rbfile/_rfile, makefile returns a io.BufferedIOBase --- musicpd.py | 2 +- test.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/musicpd.py b/musicpd.py index f63857c..3425a6f 100644 --- a/musicpd.py +++ b/musicpd.py @@ -393,7 +393,7 @@ class MPDClient: def _read_binary(self, amount): chunk = bytearray() while amount > 0: - result = self._rbfile.recv(amount) + result = self._rbfile.read(amount) if len(result) == 0: self.disconnect() raise ConnectionError("Connection lost while reading binary content") diff --git a/test.py b/test.py index ba3132b..37b47bb 100755 --- a/test.py +++ b/test.py @@ -223,15 +223,14 @@ class TestMPDClient(unittest.TestCase): def MPDWillReturnBinary(self, lines): data = bytearray(b''.join(lines)) - print(data) - def recv(amount): + def read(amount): val = bytearray() while amount > 0: amount -= 1 - _ = data.pop(0) - print(hex(_)) - val.append(_) + # _ = data.pop(0) + # print(hex(_)) + val.append(data.pop(0)) return val def readline(): @@ -240,7 +239,7 @@ class TestMPDClient(unittest.TestCase): val.append(data.pop(0)) return val self.client._rbfile.readline.side_effect = readline - self.client._rbfile.recv.side_effect = recv + self.client._rbfile.read.side_effect = read def assertMPDReceived(self, *lines): self.client._wfile.write.assert_called_with(*lines) -- 2.39.5