summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2016-02-10 13:47:04 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-02-10 13:46:35 +0900
commit2ae4f884ab310457701967e55813d2780a9e14ff (patch)
tree24566b58706d6acd13ffb6180852d8252923ad05
parent4dc709d90d031e303862a5ff97fdfe69643d7272 (diff)
tox: Adapt to PyPy interpreter
Note: Though tests may not be enough, as far as running unit test, this patch makes compatible with PyPy interpreter. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--.travis.yml1
-rw-r--r--ryu/lib/ofctl_v1_3.py4
-rw-r--r--ryu/lib/packet/ospf.py2
-rw-r--r--ryu/tests/unit/lib/ofctl_json/of13/4-48-ofp_meter_config_reply.packet.json4
-rw-r--r--ryu/tests/unit/lib/ofctl_json/of13/4-52-ofp_meter_features_reply.packet.json4
-rw-r--r--ryu/tests/unit/lib/test_ofctl.py9
-rw-r--r--ryu/tests/unit/lib/test_rpc.py13
-rw-r--r--tools/test-requires3
-rw-r--r--tox.ini2
9 files changed, 29 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml
index 263224d9..f55c0ed2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,7 @@ env:
- TOX_ENV=py26
- TOX_ENV=py27
- TOX_ENV=py34
+ - TOX_ENV=pypy
- TOX_ENV=pep8
install:
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 2de9e37f..3f8ee8f5 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -787,7 +787,7 @@ def get_meter_features(dp, waiters):
if (1 << k) & feature.band_types:
band_types.append(v)
capabilities = []
- for k, v in capa_convert.items():
+ for k, v in sorted(capa_convert.items()):
if k & feature.capabilities:
capabilities.append(v)
f = {'max_meter': feature.max_meter,
@@ -829,7 +829,7 @@ def get_meter_config(dp, waiters):
b['experimenter'] = band.experimenter
bands.append(b)
c_flags = []
- for k, v in flags.items():
+ for k, v in sorted(flags.items()):
if k & config.flags:
c_flags.append(v)
c = {'flags': c_flags,
diff --git a/ryu/lib/packet/ospf.py b/ryu/lib/packet/ospf.py
index 98c5d71c..464f089b 100644
--- a/ryu/lib/packet/ospf.py
+++ b/ryu/lib/packet/ospf.py
@@ -682,7 +682,7 @@ class OSPFMessage(packet_base.PacketBase, _TypeDisp):
rest = buf[length:]
subcls = cls._lookup_type(type_)
kwargs = subcls.parser(binmsg)
- return subcls(length, router_id, area_id, au_type, authentication,
+ return subcls(length, router_id, area_id, au_type, int(authentication),
checksum, version, **kwargs), None, rest
@classmethod
diff --git a/ryu/tests/unit/lib/ofctl_json/of13/4-48-ofp_meter_config_reply.packet.json b/ryu/tests/unit/lib/ofctl_json/of13/4-48-ofp_meter_config_reply.packet.json
index 799bde48..d5efcd97 100644
--- a/ryu/tests/unit/lib/ofctl_json/of13/4-48-ofp_meter_config_reply.packet.json
+++ b/ryu/tests/unit/lib/ofctl_json/of13/4-48-ofp_meter_config_reply.packet.json
@@ -9,9 +9,9 @@
}
],
"flags": [
- "STATS",
"PKTPS",
- "BURST"
+ "BURST",
+ "STATS"
],
"meter_id": 100
}
diff --git a/ryu/tests/unit/lib/ofctl_json/of13/4-52-ofp_meter_features_reply.packet.json b/ryu/tests/unit/lib/ofctl_json/of13/4-52-ofp_meter_features_reply.packet.json
index 025e6ccf..24dac7d4 100644
--- a/ryu/tests/unit/lib/ofctl_json/of13/4-52-ofp_meter_features_reply.packet.json
+++ b/ryu/tests/unit/lib/ofctl_json/of13/4-52-ofp_meter_features_reply.packet.json
@@ -6,10 +6,10 @@
"DSCP_REMARK"
],
"capabilities": [
- "STATS",
"KBPS",
"PKTPS",
- "BURST"
+ "BURST",
+ "STATS"
],
"max_bands": 255,
"max_color": 0,
diff --git a/ryu/tests/unit/lib/test_ofctl.py b/ryu/tests/unit/lib/test_ofctl.py
index a8ca01f2..8030dc68 100644
--- a/ryu/tests/unit/lib/test_ofctl.py
+++ b/ryu/tests/unit/lib/test_ofctl.py
@@ -73,7 +73,8 @@ class Test_ofctl(unittest.TestCase):
# expected message <--> sent message
request.serialize()
try:
- eq_(request.to_jsondict(), dp.request_msg.to_jsondict())
+ eq_(json.dumps(request.to_jsondict(), sort_keys=True),
+ json.dumps(dp.request_msg.to_jsondict(), sort_keys=True))
except AssertionError as e:
# For debugging
json.dump(dp.request_msg.to_jsondict(),
@@ -95,9 +96,11 @@ class Test_ofctl(unittest.TestCase):
return d2
return d
+ expected = _remove(expected, ['len', 'length'])
+ output = _remove(output, ['len', 'length'])
try:
- eq_(_remove(expected, ['len', 'length']),
- _remove(output, ['len', 'length']))
+ eq_(json.dumps(expected, sort_keys=True),
+ json.dumps(output, sort_keys=True))
except AssertionError as e:
# For debugging
json.dump(output, open('/tmp/' + name + '_reply.json', 'w'),
diff --git a/ryu/tests/unit/lib/test_rpc.py b/ryu/tests/unit/lib/test_rpc.py
index 149912ac..cedab558 100644
--- a/ryu/tests/unit/lib/test_rpc.py
+++ b/ryu/tests/unit/lib/test_rpc.py
@@ -119,7 +119,13 @@ class Test_rpc(unittest.TestCase):
assert isinstance(obj, int)
result = c.call(b'resp', [obj])
assert result == obj
- assert isinstance(result, type(obj))
+ import sys
+ # 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):
c = rpc.Client(self._client_sock)
@@ -237,6 +243,11 @@ class Test_rpc(unittest.TestCase):
@unittest.skip("doesn't work with eventlet 0.18 and later")
def test_4_call_large_binary(self):
import struct
+ import sys
+ # note: on PyPy, this test case may hang up.
+ sv = getattr(sys, 'subversion', None)
+ if sv is not None and sv[0] == 'PyPy':
+ return
c = rpc.Client(self._client_sock)
obj = struct.pack("10000000x")
diff --git a/tools/test-requires b/tools/test-requires
index 04ed5a23..3150b928 100644
--- a/tools/test-requires
+++ b/tools/test-requires
@@ -4,5 +4,6 @@ nose
pep8
pylint==0.25.0
formencode
-lxml # OF-Config
+lxml; platform_python_implementation != 'PyPy' # OF-Config
+lxml==3.4.0; platform_python_implementation == 'PyPy'
paramiko # NETCONF, BGP speaker
diff --git a/tox.ini b/tox.ini
index 60e5d70b..d13f4445 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py26,py27,py34,pep8
+envlist = py26,py27,py34,pypy,pep8
[testenv]
deps = -U