From 26128ac589418b30296567196ebb7cf26dfae4ae Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Thu, 26 Jan 2017 10:52:52 -0500 Subject: [PATCH] Fix some pylint errors in IPAM tests W:121,15: Using type() instead of isinstance() for a typecheck. E:123,20: Raising NoneType while only classes or instances are allowed E:137,20: Raising NoneType while only classes or instances are allowed There was also some incorrect indentation. Trivialfix Change-Id: I24aae1f41db80aa11405c024684773f73cd6dfbf --- .../unit/db/test_ipam_pluggable_backend.py | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/neutron/tests/unit/db/test_ipam_pluggable_backend.py b/neutron/tests/unit/db/test_ipam_pluggable_backend.py index 70efd58e87d..9d151548499 100644 --- a/neutron/tests/unit/db/test_ipam_pluggable_backend.py +++ b/neutron/tests/unit/db/test_ipam_pluggable_backend.py @@ -112,12 +112,10 @@ class TestDbBasePluginIpam(test_db_base.NeutronDbPluginV2TestCase): def _get_allocate_mock(self, subnet_id, auto_ip='10.0.0.2', fail_ip='127.0.0.1', - exception=None): - if exception is None: - exception = n_exc.InvalidInput(error_message='SomeError') - + exception=n_exc.InvalidInput( + error_message='SomeError')): def allocate_mock(request): - if type(request) == ipam_req.SpecificAddressRequest: + if isinstance(request, ipam_req.SpecificAddressRequest): if request.address == netaddr.IPAddress(fail_ip): raise exception else: @@ -127,15 +125,14 @@ class TestDbBasePluginIpam(test_db_base.NeutronDbPluginV2TestCase): return allocate_mock - def _get_deallocate_mock(self, fail_ip='127.0.0.1', exception=None): - if exception is None: - exception = n_exc.InvalidInput(error_message='SomeError') + def _get_deallocate_mock(self, fail_ip='127.0.0.1', + exception=n_exc.InvalidInput( + error_message='SomeError')): + def deallocate_mock(ip): + if str(ip) == fail_ip: + raise exception - def deallocate_mock(ip): - if str(ip) == fail_ip: - raise exception - - return deallocate_mock + return deallocate_mock def _validate_allocate_calls(self, expected_calls, mocks): self.assertTrue(mocks['subnets'].allocate.called)