From: Mark McClain Date: Thu, 12 Jun 2014 06:10:48 +0000 (-0400) Subject: enable H237 check X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d884f30e57dca3942eff8922e895c6f2ef6e31ef;p=openstack-build%2Fneutron-build.git enable H237 check 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 --- diff --git a/neutron/tests/unit/vmware/apiclient/test_api_eventlet_request.py b/neutron/tests/unit/vmware/apiclient/test_api_eventlet_request.py index a689ad456..06a84de1a 100644 --- a/neutron/tests/unit/vmware/apiclient/test_api_eventlet_request.py +++ b/neutron/tests/unit/vmware/apiclient/test_api_eventlet_request.py @@ -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 442a6348b..d38ef0cdf 100644 --- 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