From a40efc3a45991ff48961b44973bfd45a5ea22b79 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Mon, 18 Jan 2016 10:53:08 +0900 Subject: [PATCH] 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 Signed-off-by: FUJITA Tomonori --- ryu/tests/unit/lib/test_ofctl.py | 10 ++++++---- 1 file 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'])