Although I'm not sure how much make sense to keep the test,
it will make test pass to make string parser a bit smarter.
From
str_ = str_.rsplit()
to something like
[re.sub('\).*', '', r) for r in re.split('[(,= ]', str(res))]
thanks
On Tue, May 21, 2013 at 01:13:58PM +0900, YAMADA Hideki wrote:
> Following errors occur at current master
> (commit 21692141dc7e8be2d44338ce4eff5af584e4ff8f)
>
> ======================================================================
> ERROR: test_parser (ryu.tests.unit.ofproto.test_parser_v10.TestOFPFlowRemoved)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 4080, in test_parser
> eq_(str(cookie['val']), check['cookie'])
> KeyError: 'cookie'
>
> ======================================================================
> ERROR: test_parser (ryu.tests.unit.ofproto.test_parser_v10.TestOFPPacketIn)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 3782, in test_parser
> ok_(self._test_parser())
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 3774, in _test_parser
> eq_(str(buffer_id['val']), check['buffer_id'])
> KeyError: 'buffer_id'
>
> ======================================================================
> ERROR: test_parser_padding
> (ryu.tests.unit.ofproto.test_parser_v10.TestOFPPacketIn)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 3785, in test_parser_padding
> ok_(self._test_parser(True))
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 3774, in _test_parser
> eq_(str(buffer_id['val']), check['buffer_id'])
> KeyError: 'buffer_id'
>
> ======================================================================
> ERROR: test_str
> (ryu.tests.unit.ofproto.test_parser_v10.TestOFPQueuePropMinRate)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 2615, in test_str
> eq_(check['rate'], str(self.rate['val']))
> KeyError: 'rate'
>
> ======================================================================
> ERROR: test_str (ryu.tests.unit.ofproto.test_parser_v10.TestOFPQueuePropNone)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 2564, in test_str
> eq_(check['property'], str(self.property['val']))
> KeyError: 'property'
>
> ======================================================================
> ERROR: test_parser
> (ryu.tests.unit.ofproto.test_parser_v10.TestOFPSwitchFeatures)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/hideki/ryu/ryu/tests/unit/ofproto/test_parser_v10.py", line
> 3580, in test_parser
> eq_(check['ports'].find('OFPPhyPort'), 0)
> KeyError: 'ports'
>
> Signed-off-by: YAMADA Hideki <[email protected]>
> ---
> ryu/tests/unit/ofproto/test_parser_v10.py | 370
> -----------------------------
> 1 files changed, 0 insertions(+), 370 deletions(-)
>
> diff --git a/ryu/tests/unit/ofproto/test_parser_v10.py
> b/ryu/tests/unit/ofproto/test_parser_v10.py
> index e135a62..4b1e20c 100644
> --- a/ryu/tests/unit/ofproto/test_parser_v10.py
> +++ b/ryu/tests/unit/ofproto/test_parser_v10.py
> @@ -2549,21 +2549,6 @@ class TestOFPQueuePropNone(unittest.TestCase):
>
> ok_(self.c.parser(buf, 0))
>
> - def test_str(self):
> - list_ = ('property', 'len')
> - check = {}
> - str_ = str(self.c)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(check['property'], str(self.property['val']))
> - eq_(check['len'], str(self.len['val']))
> -
>
> class TestOFPQueuePropMinRate(unittest.TestCase):
> """ Test case for ofprotp_v1_0_parser.OFPQueuePropMinRate
> @@ -2600,20 +2585,6 @@ class TestOFPQueuePropMinRate(unittest.TestCase):
> res = self.c.parser(self.buf, 0)
> eq_(self.rate['val'], res.rate)
>
> - def test_str(self):
> - list_ = ('rate',)
> - check = {}
> - str_ = str(self.c)
> - str_ = str_.rsplit()
> - i = 0
> -
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(check['rate'], str(self.rate['val']))
> -
>
> class TestOFPPacketQueue(unittest.TestCase):
> """ Test case for ofprotp_v1_0_parser.OFPPacketQueue
> @@ -2714,24 +2685,6 @@ class TestOFPHello(unittest.TestCase):
> eq_(xid, res.xid)
> eq_(buffer(buf), res.buf)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid')
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - # comparison fails in some environment
> - # such as hex() returns string with suffix 'L'
> - eq_(hex(ofproto_v1_0.OFP_VERSION).find(check['version:']), 0)
> - eq_(hex(ofproto_v1_0.OFPT_HELLO).find(check['msg_type']), 0)
> - eq_(hex(xid).find(check['xid']), 0)
> -
> def test_serialize(self):
>
> class Datapath(object):
> @@ -2791,22 +2744,6 @@ class TestOFPErrorMsg(unittest.TestCase):
> eq_(code['val'], res.code)
> eq_(data, res.data)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid')
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> class Datapath(object):
> ofproto = ofproto_v1_0
> @@ -2882,24 +2819,6 @@ class TestOFPEchoRequest(unittest.TestCase):
> eq_(xid['val'], res.xid)
> eq_(data, res.data)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid')
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - # comparison fails in some environment
> - # such as hex() returns string with suffix 'L'
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> class Datapath(object):
> ofproto = ofproto_v1_0
> @@ -2968,24 +2887,6 @@ class TestOFPEchoReply(unittest.TestCase):
> eq_(xid['val'], res.xid)
> eq_(data, res.data)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid')
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - # comparison fails in some environment
> - # such as hex() returns string with suffix 'L'
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> class Datapath(object):
> ofproto = ofproto_v1_0
> @@ -3057,24 +2958,6 @@ class TestOFPVendor(unittest.TestCase):
> eq_(vendor['val'], res.vendor)
> eq_(data, res.data)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid')
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - # comparison fails in some environment
> - # such as hex() returns string with suffix 'L'
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> class Datapath(object):
> ofproto = ofproto_v1_0
> @@ -3559,26 +3442,6 @@ class TestOFPSwitchFeatures(unittest.TestCase):
> eq_(supported['val'], port.supported)
> eq_(peer['val'], port.peer)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid', 'ports')
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - if str_[i + 1].startswith('{'): # "{1: OFPPhyPort..."
> - check[str_[i]] = str_[i + 2]
> - else:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> - eq_(check['ports'].find('OFPPhyPort'), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -3667,22 +3530,6 @@ class TestOFPPortStatus(unittest.TestCase):
> eq_(supported['val'], desc.supported)
> eq_(peer['val'], desc.peer)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -3755,27 +3602,6 @@ class TestOFPPacketIn(unittest.TestCase):
> eq_(reason['val'], res.reason)
> eq_(data[0:16], res.data)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',
> - 'buffer_id', 'total_len', 'in_port', 'reason',)
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> - eq_(str(buffer_id['val']), check['buffer_id'])
> - eq_(str(total_len['val']), check['total_len'])
> - eq_(str(in_port['val']), check['in_port'])
> - eq_(str(reason['val']), check['reason'])
> -
> return True
>
> def test_parser(self):
> @@ -3841,22 +3667,6 @@ class TestOFPGetConfigReply(unittest.TestCase):
> eq_(flags['val'], res.flags)
> eq_(miss_send_len['val'], res.miss_send_len)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -3905,22 +3715,6 @@ class TestOFPBarrierReply(unittest.TestCase):
> eq_(msg_len['val'], res.msg_len)
> eq_(xid['val'], res.xid)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4058,34 +3852,6 @@ class TestOFPFlowRemoved(unittest.TestCase):
> eq_(tp_src['val'], match.tp_src)
> eq_(tp_dst['val'], match.tp_dst)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',
> - 'match', 'cookie', 'priority', 'reason',
> - 'duration_sec', 'duration_nsec',
> - 'idle_timeout', 'packet_count', 'byte_count')
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> - eq_(str(cookie['val']), check['cookie'])
> - eq_(str(priority['val']), check['priority'])
> - eq_(str(reason['val']), check['reason'])
> - eq_(str(duration_sec['val']), check['duration_sec'])
> - eq_(str(duration_nsec['val']), check['duration_nsec'])
> - eq_(str(idle_timeout['val']), check['idle_timeout'])
> - eq_(str(packet_count['val']), check['packet_count'])
> - eq_(str(byte_count['val']), check['byte_count'])
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4161,23 +3927,6 @@ class TestOFPQueueGetConfigReply(unittest.TestCase):
> eq_(queue_id['val'], queue.queue_id)
> eq_(len_['val'], queue.len)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4261,23 +4010,6 @@ class TestOFPDescStatsReply(unittest.TestCase):
> eq_(serial_num, body.serial_num)
> eq_(dp_desc, body.dp_desc)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4428,23 +4160,6 @@ class TestOFPFlowStatsReply(unittest.TestCase):
> eq_(port['val'], action.port)
> eq_(max_len['val'], action.max_len)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4525,23 +4240,6 @@ class TestOFPAggregateStatsReply(unittest.TestCase):
> eq_(byte_count['val'], body.byte_count)
> eq_(flow_count['val'], body.flow_count)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4635,23 +4333,6 @@ class TestOFPTableStatsReply(unittest.TestCase):
> eq_(lookup_count['val'], body.lookup_count)
> eq_(matched_count['val'], body.matched_count)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4775,23 +4456,6 @@ class TestOFPPortStatsReply(unittest.TestCase):
> eq_(rx_crc_err['val'], body.rx_crc_err)
> eq_(collisions['val'], body.collisions)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4879,23 +4543,6 @@ class TestOFPQueueStatsReply(unittest.TestCase):
> eq_(tx_packets['val'], body.tx_packets)
> eq_(tx_errors['val'], body.tx_errors)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> @@ -4964,23 +4611,6 @@ class TestOFPVendorStatsReply(unittest.TestCase):
> body = res.body[0]
> eq_(specific_data, body)
>
> - # test __str__()
> - list_ = ('version:', 'msg_type', 'xid',)
> -
> - check = {}
> - str_ = str(res)
> - str_ = str_.rsplit()
> -
> - i = 0
> - for s in str_:
> - if s in list_:
> - check[str_[i]] = str_[i + 1]
> - i += 1
> -
> - eq_(hex(version['val']).find(check['version:']), 0)
> - eq_(hex(msg_type['val']).find(check['msg_type']), 0)
> - eq_(hex(xid['val']).find(check['xid']), 0)
> -
> def test_serialize(self):
> # Not used.
> pass
> --
> 1.7.1
>
>
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>
--
yamahata
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel