mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-05 04:16:11 +02:00
test_parser: ensure that "len" "length" fields can be omitted
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
6a099204c3
commit
baddcecedc
@ -159,6 +159,26 @@ class Test_Parser(unittest.TestCase):
|
||||
eq_(self._msg_to_jsondict(msg2), json_dict)
|
||||
eq_(wire_msg, msg2.buf)
|
||||
|
||||
# check if "len" "length" fields can be omitted
|
||||
|
||||
def _remove(d, names):
|
||||
f = lambda x: _remove(x, names)
|
||||
if isinstance(d, list):
|
||||
return map(f, d)
|
||||
if isinstance(d, dict):
|
||||
d2 = {}
|
||||
for k, v in d.iteritems():
|
||||
if k in names:
|
||||
continue
|
||||
d2[k] = f(v)
|
||||
return d2
|
||||
return d
|
||||
|
||||
json_dict3 = _remove(json_dict, ['len', 'length'])
|
||||
msg3 = self._jsondict_to_msg(dp, json_dict3)
|
||||
msg3.serialize()
|
||||
eq_(wire_msg, msg3.buf)
|
||||
|
||||
|
||||
def _add_tests():
|
||||
import os
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user