msgpack-python version 0.50 or later supports bytearray objects, this
patch fixes to adopt to this change.

Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com>
---
 ryu/tests/unit/lib/test_rpc.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/ryu/tests/unit/lib/test_rpc.py b/ryu/tests/unit/lib/test_rpc.py
index 2df123e..4fba506 100644
--- a/ryu/tests/unit/lib/test_rpc.py
+++ b/ryu/tests/unit/lib/test_rpc.py
@@ -138,13 +138,18 @@ class Test_rpc(unittest.TestCase):
         assert result == obj
         assert isinstance(result, numbers.Integral)
 
-    @raises(TypeError)
     def test_0_call_bytearray(self):
         c = rpc.Client(self._client_sock)
         obj = bytearray(b'foo')
-        result = c.call('resp', [obj])
-        assert result == obj
-        assert isinstance(result, str)
+        # Note: msgpack-python version 0.50 or later supports bytearray
+        # objects, here ignores TypeError for the backward compatibility.
+        try:
+            result = c.call('resp', [obj])
+        except TypeError:
+            # Case with msgpack-python version 0.4.x or earlier.
+            return
+        self.assertEqual(obj, result)
+        self.assertIsInstance(result, six.binary_type)
 
     def test_1_shutdown_wr(self):
         # test if the server shutdown on disconnect
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to