]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
enable H237 check
authorMark McClain <mmcclain@yahoo-inc.com>
Thu, 12 Jun 2014 06:10:48 +0000 (02:10 -0400)
committerMark McClain <mmcclain@yahoo-inc.com>
Thu, 20 Nov 2014 15:13:17 +0000 (10:13 -0500)
Remove the remove use of 'new' module by properly patching the instance
object.  Additionally, enable the H237 (module is removed in Python 3) check

Change-Id: I7407600478de218a4294c4bfd774cd4cf7e1741e
Partial-Bug: 1329017

neutron/tests/unit/vmware/apiclient/test_api_eventlet_request.py
tox.ini

index a689ad45649524991413f371be52b0413a9a1c4d..06a84de1a020c7e57671133d9040e5c7f89143dd 100644 (file)
@@ -13,7 +13,6 @@
 #    under the License.
 
 import httplib
-import new
 import random
 
 import eventlet
@@ -106,16 +105,19 @@ class ApiRequestEventletTest(base.BaseTestCase):
         self.assertTrue(self.req._handle_request.called)
 
     def test_run_and_timeout(self):
-        def my_handle_request(self):
-            LOG.info('my_handle_request() self: %s' % self)
-            LOG.info('my_handle_request() dir(self): %s' % dir(self))
+        def my_handle_request():
+            LOG.info('my_handle_request() self: %s' % self.req)
+            LOG.info('my_handle_request() dir(self): %s' % dir(self.req))
             eventlet.greenthread.sleep(REQUEST_TIMEOUT * 2)
 
-        self.req._request_timeout = REQUEST_TIMEOUT
-        self.req._handle_request = new.instancemethod(
-            my_handle_request, self.req, request.EventletApiRequest)
-        self.req.start()
-        self.assertIsNone(self.req.join())
+        with mock.patch.object(
+            self.req,
+            '_handle_request',
+            new=my_handle_request
+        ):
+            self.req._request_timeout = REQUEST_TIMEOUT
+            self.req.start()
+            self.assertIsNone(self.req.join())
 
     def prep_issue_request(self):
         mysock = mock.Mock()
diff --git a/tox.ini b/tox.ini
index 442a6348b32275d83c829a83f49ee4c645b14f6e..d38ef0cdf526fb33bdf97940bf39136589072452 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -65,8 +65,6 @@ commands = python setup.py build_sphinx
 # E128 continuation line under-indented for visual indent
 # E129 visually indented line with same indent as next logical line
 # E265 block comment should start with ‘# ‘
-# H104 file contains nothing but comments
-# H237 module is removed in Python 3
 # H305 imports not grouped correctly
 # H307 like imports should be grouped together
 # H401 docstring should not start with a space
@@ -74,7 +72,7 @@ commands = python setup.py build_sphinx
 # H405 multi line docstring summary not separated with an empty line
 # H904 Wrap long lines in parentheses instead of a backslash
 # TODO(marun) H404 multi line docstring should start with a summary
-ignore = E125,E126,E128,E129,E265,H237,H305,H307,H401,H402,H404,H405,H904
+ignore = E125,E126,E128,E129,E265,H305,H307,H401,H402,H404,H405,H904
 show-source = true
 builtins = _
 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios