diff --git a/manila/tests/api/v1/test_limits.py b/manila/tests/api/v1/test_limits.py index f1cd13b2a7..8d76e2f67b 100644 --- a/manila/tests/api/v1/test_limits.py +++ b/manila/tests/api/v1/test_limits.py @@ -67,9 +67,7 @@ class BaseLimitTestSuite(test.TestCase): class LimitsControllerTest(BaseLimitTestSuite): - """ - Tests for `limits.LimitsController` class. - """ + """Tests for `limits.LimitsController` class.""" def setUp(self): """Run before each test.""" @@ -236,9 +234,7 @@ class TestLimiter(limits.Limiter): class LimitMiddlewareTest(BaseLimitTestSuite): - """ - Tests for the `limits.RateLimitingMiddleware` class. - """ + """Tests for the `limits.RateLimitingMiddleware` class.""" @webob.dec.wsgify def _empty_app(self, request): @@ -304,9 +300,7 @@ class LimitMiddlewareTest(BaseLimitTestSuite): class LimitTest(BaseLimitTestSuite): - """ - Tests for the `limits.Limit` class. - """ + """Tests for the `limits.Limit` class.""" def test_GET_no_delay(self): """Test a limit handles 1 GET per second.""" @@ -402,9 +396,7 @@ class ParseLimitsTest(BaseLimitTestSuite): class LimiterTest(BaseLimitTestSuite): - """ - Tests for the in-memory `limits.Limiter` class. - """ + """Tests for the in-memory `limits.Limiter` class.""" def setUp(self): """Run before each test.""" @@ -461,9 +453,7 @@ class LimiterTest(BaseLimitTestSuite): self.failUnlessAlmostEqual(expected, results, 8) def test_delay_GET(self): - """ - Ensure the 11th GET will result in NO delay. - """ + """Ensure the 11th GET will result in NO delay.""" expected = [None] * 11 results = list(self._check(11, "GET", "/anything")) @@ -502,9 +492,7 @@ class LimiterTest(BaseLimitTestSuite): self.assertEqual(expected, results) def test_multiple_delays(self): - """ - Ensure multiple requests still get a delay. - """ + """Ensure multiple requests still get a delay.""" expected = [None] * 10 + [6.0] * 10 results = list(self._check(20, "PUT", "/anything")) self.assertEqual(expected, results) @@ -516,15 +504,11 @@ class LimiterTest(BaseLimitTestSuite): self.assertEqual(expected, results) def test_user_limit(self): - """ - Test user-specific limits. - """ + """Test user-specific limits.""" self.assertEqual(self.limiter.levels['user3'], []) def test_multiple_users(self): - """ - Tests involving multiple users. - """ + """Tests involving multiple users.""" # User1 expected = [None] * 10 + [6.0] * 10 results = list(self._check(20, "PUT", "/anything", "user1")) @@ -556,9 +540,7 @@ class LimiterTest(BaseLimitTestSuite): class WsgiLimiterTest(BaseLimitTestSuite): - """ - Tests for `limits.WsgiLimiter` class. - """ + """Tests for `limits.WsgiLimiter` class.""" def setUp(self): """Run before each test.""" @@ -591,7 +573,6 @@ class WsgiLimiterTest(BaseLimitTestSuite): def test_invalid_methods(self): """Only POSTs should work.""" - requests = [] for method in ["GET", "PUT", "DELETE", "HEAD", "OPTIONS"]: request = webob.Request.blank("/", method=method) response = request.get_response(self.app) @@ -627,9 +608,7 @@ class WsgiLimiterTest(BaseLimitTestSuite): class FakeHttplibSocket(object): - """ - Fake `httplib.HTTPResponse` replacement. - """ + """Fake `httplib.HTTPResponse` replacement.""" def __init__(self, response_string): """Initialize new `FakeHttplibSocket`.""" @@ -641,14 +620,10 @@ class FakeHttplibSocket(object): class FakeHttplibConnection(object): - """ - Fake `httplib.HTTPConnection`. - """ + """Fake `httplib.HTTPConnection`.""" def __init__(self, app, host): - """ - Initialize `FakeHttplibConnection`. - """ + """Initialize `FakeHttplibConnection`.""" self.app = app self.host = host @@ -698,8 +673,11 @@ def wire_HTTPConnection_to_WSGI(host, app): can restore the default HTTPConnection interface (for all hosts). """ class HTTPConnectionDecorator(object): - """Wraps the real HTTPConnection class so that when you instantiate - the class you might instead get a fake instance. + """Wrapper for HTTPConnection class + + Wraps the real HTTPConnection class so that when you + instantiate the class you might instead get a fake instance. + """ def __init__(self, wrapped): @@ -717,12 +695,11 @@ def wire_HTTPConnection_to_WSGI(host, app): class WsgiLimiterProxyTest(BaseLimitTestSuite): - """ - Tests for the `limits.WsgiLimiterProxy` class. - """ + """Tests for the `limits.WsgiLimiterProxy` class.""" def setUp(self): - """ + """Set up HTTP/WSGI magic. + Do some nifty HTTP/WSGI magic which allows for WSGI to be called directly by something like the `httplib` library. """ diff --git a/manila/tests/network/linux/test_interface.py b/manila/tests/network/linux/test_interface.py index 1483c58af3..c1b6573819 100644 --- a/manila/tests/network/linux/test_interface.py +++ b/manila/tests/network/linux/test_interface.py @@ -74,7 +74,7 @@ class TestABCDriver(TestBase): pass try: - fake = ICanNotBeInstancetiated() + ICanNotBeInstancetiated() except TypeError: pass except Exception as e: diff --git a/manila/tests/network/neutron/test_neutron_api.py b/manila/tests/network/neutron/test_neutron_api.py index 81915761ec..4003fd2110 100644 --- a/manila/tests/network/neutron/test_neutron_api.py +++ b/manila/tests/network/neutron/test_neutron_api.py @@ -101,7 +101,7 @@ class NeutronApiTest(test.TestCase): @mock.patch.object(neutron, 'get_client', mock.Mock()) def test_create_api_object(self): with mock.patch.object(base.Base, '__init__', mock.Mock()): - neutron_api_obj = neutron_api.API() + neutron_api.API() base.Base.__init__.assert_called_once() neutron.get_client.assert_called_once_with('context') diff --git a/manila/tests/scheduler/test_scheduler.py b/manila/tests/scheduler/test_scheduler.py index 78293d1496..82dc24e099 100644 --- a/manila/tests/scheduler/test_scheduler.py +++ b/manila/tests/scheduler/test_scheduler.py @@ -60,14 +60,14 @@ class SchedulerManagerTestCase(test.TestCase): host = 'fake_host' with mock.patch.object(self.manager.driver, 'update_service_capabilities', mock.Mock()): - result = self.manager.update_service_capabilities( + self.manager.update_service_capabilities( self.context, service_name=service_name, host=host) self.manager.driver.update_service_capabilities.\ assert_called_once_with(service_name, host, {}) with mock.patch.object(self.manager.driver, 'update_service_capabilities', mock.Mock()): capabilities = {'fake_capability': 'fake_value'} - result = self.manager.update_service_capabilities( + self.manager.update_service_capabilities( self.context, service_name=service_name, host=host, capabilities=capabilities) self.manager.driver.update_service_capabilities.\ @@ -116,7 +116,7 @@ class SchedulerTestCase(test.TestCase): capabilities = {'fake_capability': 'fake_value'} with mock.patch.object(self.driver.host_manager, 'update_service_capabilities', mock.Mock()): - result = self.driver.update_service_capabilities( + self.driver.update_service_capabilities( service_name, host, capabilities) self.driver.host_manager.update_service_capabilities.\ assert_called_once_with(service_name, host, capabilities) @@ -142,8 +142,9 @@ class SchedulerTestCase(test.TestCase): class SchedulerDriverBaseTestCase(SchedulerTestCase): - """Test cases for base scheduler driver class methods - that can't will fail if the driver is changed + """Test cases for base scheduler driver class methods. + + These can't fail if the driver is changed. """ def test_unimplemented_schedule(self): @@ -167,7 +168,8 @@ class SchedulerDriverModuleTestCase(test.TestCase): with mock.patch.object(timeutils, 'utcnow', mock.Mock(return_value='fake-now')): driver.share_update_db(self.context, 31337, 'fake_host') - db.share_update.assert_called_once_with(self.context, 31337, + db.share_update.assert_called_once_with( + self.context, 31337, {'host': 'fake_host', 'scheduled_at': 'fake-now'}) @@ -200,7 +202,7 @@ class SimpleSchedulerSharesTestCase(test.TestCase): with mock.patch.object(driver, 'share_update_db', mock.Mock(return_value=fake_share)): self.driver.schedule_create_share(self.context, - fake_request_spec, {}) + fake_request_spec, {}) utils.service_is_up.assert_called_once_with( utils.IsAMatcher(dict)) db.service_get_all_share_sorted.assert_called_once_with( diff --git a/manila/tests/scheduler/test_scheduler_options.py b/manila/tests/scheduler/test_scheduler_options.py index a6ce2811fe..95b8df9b66 100644 --- a/manila/tests/scheduler/test_scheduler_options.py +++ b/manila/tests/scheduler/test_scheduler_options.py @@ -71,7 +71,6 @@ class SchedulerOptionsTestCase(test.TestCase): file_old = None file_now = datetime.datetime(2012, 1, 1, 1, 1, 1) - data = dict(a=1, b=2, c=3) jdata = "" fake = FakeSchedulerOptions(last_checked, now, file_old, file_now, diff --git a/manila/tests/test_share.py b/manila/tests/test_share.py index f956529d76..0df8e219d6 100644 --- a/manila/tests/test_share.py +++ b/manila/tests/test_share.py @@ -276,7 +276,7 @@ class ShareTestCase(test.TestCase): self.share_manager.create_snapshot(self.context, share_id, snapshot_id) self.assertEqual(share_id, db.share_snapshot_get(context.get_admin_context(), - snapshot_id).share_id) + snapshot_id).share_id) snap = db.share_snapshot_get(self.context, snapshot_id) self.assertEqual(snap['status'], 'available') @@ -581,8 +581,8 @@ class ShareTestCase(test.TestCase): ) share = self._create_share(share_network_id=share_net['id'], share_server_id=share_srv['id']) - share2 = self._create_share(share_network_id=share_net['id'], - share_server_id=share_srv['id']) + self._create_share(share_network_id=share_net['id'], + share_server_id=share_srv['id']) share_id = share['id'] manager.CONF.delete_share_server_with_last_share = True diff --git a/manila/tests/test_share_api.py b/manila/tests/test_share_api.py index 6b12a01ffe..9ab9ef9e82 100644 --- a/manila/tests/test_share_api.py +++ b/manila/tests/test_share_api.py @@ -303,13 +303,6 @@ class ShareAPITestCase(test.TestCase): for name in ('id', 'export_location', 'host', 'launched_at', 'terminated_at'): options.pop(name, None) - request_spec = { - 'share_properties': options, - 'share_proto': share['share_proto'], - 'share_id': share['id'], - 'snapshot_id': share['snapshot_id'], - 'volume_type': None, - } with mock.patch.object(db_driver, 'share_create', mock.Mock(return_value=share)): self.api.create(self.context, 'nfs', '1', 'fakename', 'fakedesc', diff --git a/manila/tests/test_share_generic.py b/manila/tests/test_share_generic.py index 27cc6da26d..d1f693ad60 100644 --- a/manila/tests/test_share_generic.py +++ b/manila/tests/test_share_generic.py @@ -245,7 +245,6 @@ class GenericShareDriverTestCase(test.TestCase): self.share['name'])) def test_attach_volume_not_attached(self): - fake_server = fake_compute.FakeServer() availiable_volume = fake_volume.FakeVolume() attached_volume = fake_volume.FakeVolume(status='in-use') self.stubs.Set(self._driver.compute_api, 'instance_volume_attach', @@ -359,7 +358,6 @@ class GenericShareDriverTestCase(test.TestCase): self.share['id']) def test_detach_volume(self): - fake_server = fake_compute.FakeServer() availiable_volume = fake_volume.FakeVolume() attached_volume = fake_volume.FakeVolume(status='in-use') self.stubs.Set(self._driver, '_get_volume', @@ -383,7 +381,6 @@ class GenericShareDriverTestCase(test.TestCase): self._context, availiable_volume['id']) def test_detach_volume_detached(self): - fake_server = fake_compute.FakeServer() availiable_volume = fake_volume.FakeVolume() attached_volume = fake_volume.FakeVolume(status='in-use') self.stubs.Set(self._driver, '_get_volume', diff --git a/manila/tests/test_share_rpcapi.py b/manila/tests/test_share_rpcapi.py index 7dd3fe0ce2..107a69512f 100644 --- a/manila/tests/test_share_rpcapi.py +++ b/manila/tests/test_share_rpcapi.py @@ -95,8 +95,6 @@ class ShareRpcAPITestCase(test.TestCase): self.fake_args = None self.fake_kwargs = None - real_prepare = self.rpcapi.client.prepare - def _fake_prepare_method(*args, **kwds): for kwd in kwds: self.assertEqual(kwds[kwd], target[kwd]) diff --git a/tox.ini b/tox.ini index 66d36e6e34..2393d8c646 100644 --- a/tox.ini +++ b/tox.ini @@ -49,6 +49,6 @@ commands = bash tools/lintstack.sh # # H904 wrap long lines in parentheses instead of a backslash # reason: removed in hacking (https://review.openstack.org/#/c/101701/) -ignore = E128,H302,H404,H405,H501,H904,F841 +ignore = E128,H302,H404,H405,H501,H904 builtins = _ exclude = .venv,.tox,dist,doc,openstack,*egg