Start running pylint on the test tree
Remove ignore directive that was skipping the test tree. Fixed code as required. Trivialfix Change-Id: I7d5bb8de1273b235730303f640d6830d89a9568c Signed-off-by: Brian Haley <haleyb.dev@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
[MASTER]
|
||||
# Add <file or directory> to the black list. It should be a base name, not a
|
||||
# path. You may set this option multiple times.
|
||||
ignore=.git,tests
|
||||
ignore=.git
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
# NOTE(gus): This is a long list. A number of these are important and
|
||||
|
||||
@@ -198,7 +198,7 @@ class BaseTestCase(testtools.TestCase):
|
||||
if isinstance(exc_info[1], SystemExit):
|
||||
if os.getpid() != self.orig_pid:
|
||||
# Subprocess - let it just exit
|
||||
raise
|
||||
raise exc_info[1]
|
||||
# This makes sys.exit(0) still a failure
|
||||
self.force_failure = True
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ def get_exception_handler(debugger_name):
|
||||
def _get_debugger(debugger_name):
|
||||
try:
|
||||
debugger = __import__(debugger_name)
|
||||
except ImportError:
|
||||
except ImportError as exc:
|
||||
raise ValueError("can't import %s module as a post mortem debugger" %
|
||||
debugger_name)
|
||||
debugger_name) from exc
|
||||
if 'post_mortem' in dir(debugger):
|
||||
return debugger
|
||||
else:
|
||||
@@ -88,9 +88,9 @@ def get_ignored_traceback(tb):
|
||||
|
||||
# Find all members of an ignored trailing chain
|
||||
ignored_tracebacks = []
|
||||
for tb in reversed(tb_list):
|
||||
for memb in reversed(tb_list):
|
||||
if '__unittest' in tb.tb_frame.f_globals:
|
||||
ignored_tracebacks.append(tb)
|
||||
ignored_tracebacks.append(memb)
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class DefinitionBaseTestCase(test_base.BaseTestCase):
|
||||
self._assert_subresource(subresource)
|
||||
else:
|
||||
self.assertEqual(
|
||||
['parameters'], [p for p in sub_attrmap.keys()],
|
||||
['parameters'], list(sub_attrmap.keys()),
|
||||
'When extending sub-resources only use the parameters '
|
||||
'keyword')
|
||||
self.assertParams(sub_attrmap['parameters'])
|
||||
|
||||
@@ -398,11 +398,11 @@ class TestConvertToSanitizedMacAddress(base.BaseTestCase):
|
||||
('12345678901', '01:23:45:67:89:01'),
|
||||
('012345678901', '01:23:45:67:89:01'),
|
||||
)
|
||||
for input, expected in input_exp:
|
||||
for eui, expected in input_exp:
|
||||
self.assertEqual(
|
||||
expected,
|
||||
converters.convert_to_sanitized_mac_address(input))
|
||||
eui_address = netaddr.EUI(input)
|
||||
converters.convert_to_sanitized_mac_address(eui))
|
||||
eui_address = netaddr.EUI(eui)
|
||||
self.assertEqual(
|
||||
expected,
|
||||
converters.convert_to_sanitized_mac_address(eui_address))
|
||||
|
||||
@@ -1349,7 +1349,7 @@ class TestAnyKeySpecs(base.BaseTestCase):
|
||||
validators.validate_any_key_specs_or_none(None, key_specs={}))
|
||||
|
||||
def test_data_is_not_list(self):
|
||||
for t in [dict(), set(), 'abc', 1, True]:
|
||||
for t in [{}, set(), 'abc', 1, True]:
|
||||
self.assertRaises(
|
||||
n_exc.InvalidInput,
|
||||
validators.validate_any_key_specs_or_none, t, key_specs={})
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from neutron_lib.callbacks import events
|
||||
from oslotest import base
|
||||
|
||||
from neutron_lib.callbacks import events
|
||||
|
||||
|
||||
class EventPayloadTestCase(base.BaseTestCase):
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ callback_id_2 = manager._get_id(callback_2)
|
||||
|
||||
|
||||
def callback_raise(*args, **kwargs):
|
||||
raise Exception()
|
||||
raise exceptions.BadRequest()
|
||||
|
||||
|
||||
def callback_raise_retriable(*args, **kwargs):
|
||||
@@ -65,7 +65,7 @@ def callback_raise_retriable(*args, **kwargs):
|
||||
|
||||
|
||||
def callback_raise_not_retriable(*args, **kwargs):
|
||||
raise Exception()
|
||||
raise exceptions.BadRequest()
|
||||
|
||||
|
||||
def callback_3(resource, event, trigger, payload):
|
||||
|
||||
@@ -49,11 +49,11 @@ class TestExceptionToRetryContextManager(_base.BaseTestCase):
|
||||
|
||||
def test_inner_exception_preserved_in_retryrequest(self):
|
||||
try:
|
||||
exc = ValueError('test')
|
||||
vexc = ValueError('test')
|
||||
with db_api.exc_to_retry(ValueError):
|
||||
raise exc
|
||||
raise vexc
|
||||
except db_exc.RetryRequest as e:
|
||||
self.assertEqual(exc, e.inner_exc)
|
||||
self.assertEqual(vexc, e.inner_exc)
|
||||
|
||||
def test_retries_on_multi_exception_containing_target(self):
|
||||
with testtools.ExpectedException(db_exc.RetryRequest):
|
||||
|
||||
@@ -32,30 +32,30 @@ class TestModelBase(db_base.SqlTestCase):
|
||||
self.session = self.ctx.session
|
||||
|
||||
def test_model_base(self):
|
||||
foo = TestTable(name='meh')
|
||||
self.assertEqual('meh', foo.name)
|
||||
self.assertIn('meh', str(foo)) # test foo.__repr__
|
||||
cols = [k for k, _v in foo] # test foo.__iter__ and foo.next
|
||||
table = TestTable(name='meh')
|
||||
self.assertEqual('meh', table.name)
|
||||
self.assertIn('meh', str(table)) # test table.__repr__
|
||||
cols = [k for k, _v in table] # test table.__iter__ and table.next
|
||||
self.assertIn('name', cols)
|
||||
|
||||
def test_get_set_tenant_id_tenant(self):
|
||||
foo = TestTable(tenant_id='tenant')
|
||||
self.assertEqual('tenant', foo.get_tenant_id())
|
||||
foo.set_tenant_id('project')
|
||||
self.assertEqual('project', foo.get_tenant_id())
|
||||
table = TestTable(tenant_id='tenant')
|
||||
self.assertEqual('tenant', table.get_tenant_id())
|
||||
table.set_tenant_id('project')
|
||||
self.assertEqual('project', table.get_tenant_id())
|
||||
|
||||
def test_get_set_tenant_id_project(self):
|
||||
foo = TestTable(project_id='project')
|
||||
self.assertEqual('project', foo.get_tenant_id())
|
||||
foo.set_tenant_id('tenant')
|
||||
self.assertEqual('tenant', foo.get_tenant_id())
|
||||
table = TestTable(project_id='project')
|
||||
self.assertEqual('project', table.get_tenant_id())
|
||||
table.set_tenant_id('tenant')
|
||||
self.assertEqual('tenant', table.get_tenant_id())
|
||||
|
||||
def test_project_id_attribute(self):
|
||||
foo = TestTable(project_id='project')
|
||||
self.assertEqual('project', foo.project_id)
|
||||
self.assertEqual('project', foo.tenant_id)
|
||||
table = TestTable(project_id='project')
|
||||
self.assertEqual('project', table.project_id)
|
||||
self.assertEqual('project', table.tenant_id)
|
||||
|
||||
def test_tenant_id_attribute(self):
|
||||
foo = TestTable(tenant_id='tenant')
|
||||
self.assertEqual('tenant', foo.project_id)
|
||||
self.assertEqual('tenant', foo.tenant_id)
|
||||
table = TestTable(tenant_id='tenant')
|
||||
self.assertEqual('tenant', table.project_id)
|
||||
self.assertEqual('tenant', table.tenant_id)
|
||||
|
||||
@@ -37,11 +37,11 @@ class StandardAttrTestCase(base.BaseTestCase):
|
||||
|
||||
def test_standard_attr_resource_model_map(self):
|
||||
rs_map = standard_attr.get_standard_attr_resource_model_map()
|
||||
base = self._make_decl_base()
|
||||
decl_base = self._make_decl_base()
|
||||
|
||||
class MyModel(standard_attr.HasStandardAttributes,
|
||||
standard_attr.model_base.HasId,
|
||||
base):
|
||||
decl_base):
|
||||
api_collections = ['my_resource', 'my_resource2']
|
||||
api_sub_resources = ['my_subresource']
|
||||
|
||||
@@ -66,30 +66,30 @@ class StandardAttrTestCase(base.BaseTestCase):
|
||||
|
||||
class Dup(standard_attr.HasStandardAttributes,
|
||||
standard_attr.model_base.HasId,
|
||||
base):
|
||||
decl_base):
|
||||
api_collections = ['my_resource']
|
||||
|
||||
with testtools.ExpectedException(RuntimeError):
|
||||
standard_attr.get_standard_attr_resource_model_map()
|
||||
|
||||
def test_standard_attr_resource_parent_map(self):
|
||||
base = self._make_decl_base()
|
||||
decl_base = self._make_decl_base()
|
||||
|
||||
class TagSupportModel(standard_attr.HasStandardAttributes,
|
||||
standard_attr.model_base.HasId,
|
||||
base):
|
||||
decl_base):
|
||||
collection_resource_map = {'collection_name': 'member_name'}
|
||||
tag_support = True
|
||||
|
||||
class TagUnsupportModel(standard_attr.HasStandardAttributes,
|
||||
standard_attr.model_base.HasId,
|
||||
base):
|
||||
decl_base):
|
||||
collection_resource_map = {'collection_name2': 'member_name2'}
|
||||
tag_support = False
|
||||
|
||||
class TagUnsupportModel2(standard_attr.HasStandardAttributes,
|
||||
standard_attr.model_base.HasId,
|
||||
base):
|
||||
decl_base):
|
||||
collection_resource_map = {'collection_name3': 'member_name3'}
|
||||
|
||||
parent_map = standard_attr.get_tag_resource_parent_map()
|
||||
@@ -99,7 +99,7 @@ class StandardAttrTestCase(base.BaseTestCase):
|
||||
|
||||
class DupTagSupportModel(standard_attr.HasStandardAttributes,
|
||||
standard_attr.model_base.HasId,
|
||||
base):
|
||||
decl_base):
|
||||
collection_resource_map = {'collection_name': 'member_name'}
|
||||
tag_support = True
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ class FakeNotifier:
|
||||
return self.__class__(self.transport, publisher_id)
|
||||
|
||||
def _notify(self, ctxt, event_type, payload, priority):
|
||||
msg = dict(publisher_id=self.publisher_id,
|
||||
priority=priority,
|
||||
event_type=event_type,
|
||||
payload=payload)
|
||||
msg = {'publisher_id': self.publisher_id,
|
||||
'priority': priority,
|
||||
'event_type': event_type,
|
||||
'payload': payload}
|
||||
NOTIFICATIONS.append(msg)
|
||||
|
||||
@@ -17,8 +17,8 @@ from neutron_lib.tests import _base as base
|
||||
|
||||
|
||||
class _MechanismDriver(api.MechanismDriver):
|
||||
def bind_port(s, c):
|
||||
return c
|
||||
def bind_port(self, context):
|
||||
return context
|
||||
|
||||
def initialize(self):
|
||||
pass
|
||||
|
||||
@@ -155,7 +155,7 @@ class TestUtils(base.BaseTestCase):
|
||||
with mock.patch.object(excutils, 'save_and_reraise_exception'):
|
||||
with mock.patch.object(utils, 'LOG'):
|
||||
with utils.delete_port_on_error(core_plugin, 'ctx', '1'):
|
||||
raise Exception()
|
||||
raise exceptions.BadRequest()
|
||||
|
||||
core_plugin.delete_port.assert_called_once_with(
|
||||
'ctx', '1', l3_port_check=False)
|
||||
@@ -165,7 +165,7 @@ class TestUtils(base.BaseTestCase):
|
||||
with mock.patch.object(excutils, 'save_and_reraise_exception'):
|
||||
with mock.patch.object(utils, 'LOG'):
|
||||
with utils.update_port_on_error(core_plugin, 'ctx', '1', '2'):
|
||||
raise Exception()
|
||||
raise exceptions.BadRequest()
|
||||
|
||||
core_plugin.update_port.assert_called_once_with(
|
||||
'ctx', '1', {'port': '2'})
|
||||
|
||||
@@ -38,10 +38,13 @@ def _make_rule(rule_type='fake-rule-type', params=None):
|
||||
|
||||
|
||||
def _make_driver(name='fake-driver',
|
||||
vif_types=[portbindings.VIF_TYPE_OVS],
|
||||
vnic_types=[portbindings.VNIC_NORMAL],
|
||||
supported_rules=SUPPORTED_RULES,
|
||||
vif_types=None,
|
||||
vnic_types=None,
|
||||
supported_rules=None,
|
||||
requires_rpc_notifications=False):
|
||||
vif_types = vif_types or [portbindings.VIF_TYPE_OVS]
|
||||
vnic_types = vnic_types or [portbindings.VNIC_NORMAL]
|
||||
supported_rules = supported_rules or SUPPORTED_RULES
|
||||
return qos_base.DriverBase(
|
||||
name, vif_types, vnic_types, supported_rules,
|
||||
requires_rpc_notifications=requires_rpc_notifications)
|
||||
|
||||
@@ -20,9 +20,9 @@ from neutron_lib.tests import _base as base
|
||||
class TestNeutronLib(base.BaseTestCase):
|
||||
|
||||
def test_sentinel_constant(self):
|
||||
foo = constants.Sentinel()
|
||||
bar = copy.deepcopy(foo)
|
||||
self.assertEqual(id(foo), id(bar))
|
||||
singleton = constants.Sentinel()
|
||||
sing_copy = copy.deepcopy(singleton)
|
||||
self.assertEqual(id(singleton), id(sing_copy))
|
||||
|
||||
def test_sentinel_copy(self):
|
||||
singleton = constants.Sentinel()
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestReplaceFile(base.BaseTestCase):
|
||||
|
||||
def _verify_result(self, file_mode):
|
||||
self.assertTrue(os.path.exists(self.file_name))
|
||||
with open(self.file_name) as f:
|
||||
with open(self.file_name, encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
self.assertEqual(self.data, content)
|
||||
mode = os.stat(self.file_name).st_mode
|
||||
|
||||
@@ -113,8 +113,8 @@ class TestDictUtils(base.BaseTestCase):
|
||||
{"key2": "value2"},
|
||||
{"key4": "value4"}]
|
||||
added, removed = helpers.diff_list_of_dict(old_list, new_list)
|
||||
self.assertEqual(added, [dict(key4="value4")])
|
||||
self.assertEqual(removed, [dict(key3="value3")])
|
||||
self.assertEqual(added, [{"key4": "value4"}])
|
||||
self.assertEqual(removed, [{"key3": "value3"}])
|
||||
|
||||
|
||||
class TestDict2Tuples(base.BaseTestCase):
|
||||
|
||||
Reference in New Issue
Block a user