summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2016-01-18 10:53:08 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-01-19 10:51:47 +0900
commita40efc3a45991ff48961b44973bfd45a5ea22b79 (patch)
tree0534f90efa9b5ad66b1651fdfa514dc3256ab28d
parentbeb3353e3977504017011f0d6f561765a95bb187 (diff)
test_ofctl: Compare sent messages in json representation
Currently, test_ofctl compares the sent messages in binary, so it is difficult to figure out the differences of the sent messages and the expected messages. This patch fixes to compare the sent messages in json representation in order to make easy to debug. 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_ofctl.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/ryu/tests/unit/lib/test_ofctl.py b/ryu/tests/unit/lib/test_ofctl.py
index adb2719f..a8ca01f2 100644
--- a/ryu/tests/unit/lib/test_ofctl.py
+++ b/ryu/tests/unit/lib/test_ofctl.py
@@ -73,11 +73,12 @@ class Test_ofctl(unittest.TestCase):
# expected message <--> sent message
request.serialize()
try:
- eq_(request.buf, dp.request_msg.buf)
+ eq_(request.to_jsondict(), dp.request_msg.to_jsondict())
except AssertionError as e:
# For debugging
json.dump(dp.request_msg.to_jsondict(),
- open('/tmp/' + name, 'w'), indent=3, sort_keys=True)
+ open('/tmp/' + name + '_request.json', 'w'),
+ indent=3, sort_keys=True)
raise e
# expected output <--> return of ofctl
@@ -99,7 +100,8 @@ class Test_ofctl(unittest.TestCase):
_remove(output, ['len', 'length']))
except AssertionError as e:
# For debugging
- json.dump(output, open('/tmp/' + name, 'w'), indent=4)
+ json.dump(output, open('/tmp/' + name + '_reply.json', 'w'),
+ indent=4)
raise e
@@ -314,7 +316,7 @@ def _add_tests():
parser_json_dir = os.path.join(parser_json_root, ofp_ver)
ofctl_json_dir = os.path.join(ofctl_json_root, ofp_ver)
for test in tests:
- name = 'test_ofctl_' + test['request']
+ name = 'test_ofctl_' + ofp_ver + '_' + test['method'].__name__
print('adding %s ...' % name)
args = {}
args_json_path = os.path.join(ofctl_json_dir, test['request'])