]> kaliko git repositories - python-musicpd.git/commitdiff
Fixed 7cb6ba6, s/recv/read/
authorKaliko Jack <kaliko@azylum.org>
Sat, 5 Dec 2020 09:30:56 +0000 (10:30 +0100)
committerKaliko Jack <kaliko@azylum.org>
Sat, 5 Dec 2020 09:30:56 +0000 (10:30 +0100)
No recv method in _rbfile/_rfile, makefile returns a io.BufferedIOBase

musicpd.py
test.py

index f63857c4e8c931097f2a1d6e457ced94f96dd988..3425a6f7f84fd9d37f3ffdd1a749d24b19dacbc0 100644 (file)
@@ -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 ba3132b14689efa63c8164331bf702c74716253a..37b47bbaa62b6b6b6bd661aff7682c7af3be0ea9 100755 (executable)
--- 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)