test_rpc: Use numbers.Integral instead of long type
Currently, test_rpc.py uses long type for PyPy interpreter compatibility, but log type is obsoleted in Python 3. This patch fixes test_rpc.py to use numbers.Integral and makes its implemetation more clean. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
9f04612459
commit
a45c180447
@ -119,13 +119,7 @@ class Test_rpc(unittest.TestCase):
|
|||||||
assert isinstance(obj, int)
|
assert isinstance(obj, int)
|
||||||
result = c.call(b'resp', [obj])
|
result = c.call(b'resp', [obj])
|
||||||
assert result == obj
|
assert result == obj
|
||||||
import sys
|
assert isinstance(result, numbers.Integral)
|
||||||
# note: on PyPy, result will be a long type value.
|
|
||||||
sv = getattr(sys, 'subversion', None)
|
|
||||||
if sv is not None and sv[0] == 'PyPy':
|
|
||||||
assert isinstance(result, long)
|
|
||||||
else:
|
|
||||||
assert isinstance(result, type(obj))
|
|
||||||
|
|
||||||
def test_0_call_int3(self):
|
def test_0_call_int3(self):
|
||||||
c = rpc.Client(self._client_sock)
|
c = rpc.Client(self._client_sock)
|
||||||
@ -133,16 +127,15 @@ class Test_rpc(unittest.TestCase):
|
|||||||
assert isinstance(obj, int)
|
assert isinstance(obj, int)
|
||||||
result = c.call(b'resp', [obj])
|
result = c.call(b'resp', [obj])
|
||||||
assert result == obj
|
assert result == obj
|
||||||
assert isinstance(result, type(obj))
|
assert isinstance(result, numbers.Integral)
|
||||||
|
|
||||||
def test_0_call_long(self):
|
def test_0_call_long(self):
|
||||||
c = rpc.Client(self._client_sock)
|
c = rpc.Client(self._client_sock)
|
||||||
obj = 0xffffffffffffffff # max value for msgpack
|
obj = 0xffffffffffffffff # max value for msgpack
|
||||||
_long = int if six.PY3 else long
|
assert isinstance(obj, numbers.Integral)
|
||||||
assert isinstance(obj, _long)
|
|
||||||
result = c.call(b'resp', [obj])
|
result = c.call(b'resp', [obj])
|
||||||
assert result == obj
|
assert result == obj
|
||||||
assert isinstance(result, type(obj))
|
assert isinstance(result, numbers.Integral)
|
||||||
|
|
||||||
def test_0_call_long2(self):
|
def test_0_call_long2(self):
|
||||||
c = rpc.Client(self._client_sock)
|
c = rpc.Client(self._client_sock)
|
||||||
|
Loading…
Reference in New Issue
Block a user