summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-01-11 16:02:40 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-01-17 08:46:14 +0900
commit81cdd4f0d76952c16d6e65e6af8da82702175220 (patch)
treebe58f212e603324225ce61ccd780c8de90ca3d8d
parentc3b484c787f98e6cc7a53a011fd7cacc5607de6d (diff)
test_rpc: Adopt to msgpack-python>=0.50
msgpack-python version 0.50 or later supports bytearray objects, this patch fixes to adopt to this change. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/tests/unit/lib/test_rpc.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/ryu/tests/unit/lib/test_rpc.py b/ryu/tests/unit/lib/test_rpc.py
index 2df123ee..4fba5068 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