- Method in Python3 is obtained as a mere function from class attributes
Signed-off-by: Satoshi KOBAYASHI <[email protected]>
---
ryu/app/wsgi.py | 10 +++++++---
ryu/tests/unit/app/test_wsgi.py | 16 ++++++++++++----
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/ryu/app/wsgi.py b/ryu/app/wsgi.py
index 24baf05..6687dc2 100644
--- a/ryu/app/wsgi.py
+++ b/ryu/app/wsgi.py
@@ -263,9 +263,13 @@ class WSGIApplication(object):
return controller(req)
def register(self, controller, data=None):
- methods = inspect.getmembers(controller,
- lambda v: inspect.ismethod(v) and
- hasattr(v, 'routing_info'))
+ def _target_filter(attr):
+ if not inspect.ismethod(attr) and not inspect.isfunction(attr):
+ return False
+ if not hasattr(attr, 'routing_info'):
+ return False
+ return True
+ methods = inspect.getmembers(controller, _target_filter)
for method_name, method in methods:
routing_info = getattr(method, 'routing_info')
name = routing_info['name']
diff --git a/ryu/tests/unit/app/test_wsgi.py b/ryu/tests/unit/app/test_wsgi.py
index a1da122..9da2057 100644
--- a/ryu/tests/unit/app/test_wsgi.py
+++ b/ryu/tests/unit/app/test_wsgi.py
@@ -17,10 +17,14 @@
import unittest
import logging
-from nose.tools import *
-from ryu.app.wsgi import ControllerBase, WSGIApplication, route
+import nose
+from nose.tools import eq_
from webob.response import Response
+
+from ryu.app.wsgi import ControllerBase
+from ryu.app.wsgi import WSGIApplication
+from ryu.app.wsgi import route
from ryu.lib import dpid as dpidlib
LOG = logging.getLogger('test_wsgi')
@@ -61,7 +65,7 @@ class Test_wsgi(unittest.TestCase):
r = self.wsgi_app({'REQUEST_METHOD': 'GET',
'PATH_INFO': '/test/0123456789abcdef'},
lambda s, _: eq_(s, '200 OK'))
- eq_(r[0], ('0123456789abcdef'))
+ eq_(r[0], (b'0123456789abcdef'))
def test_wsgi_decorator_ng_path(self):
self.wsgi_app({'REQUEST_METHOD': 'GET',
@@ -93,4 +97,8 @@ class Test_wsgi(unittest.TestCase):
r = self.wsgi_app({'REQUEST_METHOD': 'DELETE',
'PATH_INFO': '/test'},
lambda s, _: eq_(s, '200 OK'))
- eq_(r[0], 'root')
+ eq_(r[0], b'root')
+
+
+if __name__ == '__main__':
+ nose.main(argv=['nosetests', '-s', '-v'], defaultTest=__file__)
--
2.3.2 (Apple Git-55)
------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors
network devices and physical & virtual servers, alerts via email & sms
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel