Browse Source

Adopt hacking 1.1.0

This incorporates flake8 2.6.x and pycodestyle will be used
instead of older pep8.  This ensures future python3 compatibility
and a bit better code styling.

Change-Id: Ia7c7c5a44727f615a151e1e68dd94c7ed42f974f
changes/61/576761/2
IWAMOTO Toshihiro 3 years ago
parent
commit
0f180d8e2e
26 changed files with 39 additions and 21 deletions
  1. +3
    -3
      lower-constraints.txt
  2. +1
    -0
      neutron/agent/linux/iptables_manager.py
  3. +1
    -0
      neutron/api/rpc/callbacks/version_manager.py
  4. +1
    -0
      neutron/conf/agent/common.py
  5. +1
    -0
      neutron/db/api.py
  6. +1
    -0
      neutron/extensions/securitygroup.py
  7. +1
    -0
      neutron/plugins/ml2/db.py
  8. +1
    -0
      neutron/plugins/ml2/extensions/dns_integration.py
  9. +1
    -0
      neutron/services/l3_router/service_providers/base.py
  10. +1
    -0
      neutron/services/segments/db.py
  11. +2
    -0
      neutron/tests/common/agents/ovs_agent.py
  12. +1
    -0
      neutron/tests/functional/agent/linux/bin/ipt_binname.py
  13. +1
    -1
      neutron/tests/unit/agent/l3/test_router_info.py
  14. +1
    -0
      neutron/tests/unit/agent/linux/test_iptables_manager.py
  15. +1
    -1
      neutron/tests/unit/agent/test_securitygroups_rpc.py
  16. +2
    -2
      neutron/tests/unit/common/test_utils.py
  17. +1
    -0
      neutron/tests/unit/db/quota/test_driver.py
  18. +5
    -5
      neutron/tests/unit/hacking/test_checks.py
  19. +1
    -0
      neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py
  20. +2
    -2
      neutron/tests/unit/plugins/ml2/test_plugin.py
  21. +2
    -2
      neutron/tests/unit/services/metering/test_metering_plugin.py
  22. +2
    -2
      neutron/tests/unit/services/qos/test_qos_plugin.py
  23. +1
    -0
      neutron/tests/unit/services/trunk/drivers/linuxbridge/agent/test_trunk_plumber.py
  24. +2
    -1
      neutron/tests/unit/testlib_api.py
  25. +1
    -1
      test-requirements.txt
  26. +2
    -1
      tox.ini

+ 3
- 3
lower-constraints.txt View File

@ -25,13 +25,13 @@ extras==1.0.0
fasteners==0.7.0
fixtures==3.0.0
flake8-import-order==0.12
flake8==2.5.5
flake8==2.6.2
future==0.16.0
futurist==1.2.0
gitdb==0.6.4
GitPython==1.0.1
greenlet==0.4.10
hacking==0.12.0
hacking==1.1.0
httplib2==0.9.1
imagesize==0.7.1
iso8601==0.1.11
@ -96,7 +96,7 @@ positional==1.2.1
prettytable==0.7.2
psutil==3.2.2
pycadf==1.1.0
pycodestyle==2.3.1
pycodestyle==2.4.0
pycparser==2.18
pyflakes==0.8.1
Pygments==2.2.0


+ 1
- 0
neutron/agent/linux/iptables_manager.py View File

@ -51,6 +51,7 @@ def get_binary_name():
"""Grab the name of the binary we're running in."""
return os.path.basename(sys.argv[0])[:16].replace(' ', '_')
binary_name = get_binary_name()
# A length of a chain name must be less than or equal to 11 characters.


+ 1
- 0
neutron/api/rpc/callbacks/version_manager.py View File

@ -233,6 +233,7 @@ class CachedResourceConsumerTracker(object):
self._check_expiration()
self._versions.report()
_cached_version_tracker = None


+ 1
- 0
neutron/conf/agent/common.py View File

@ -251,6 +251,7 @@ def setup_conf():
conf.register_opts(bind_opts)
return conf
# add a logging setup method here for convenience
setup_logging = config.setup_logging


+ 1
- 0
neutron/db/api.py View File

@ -68,6 +68,7 @@ def is_retriable(e):
# looking savepoints mangled by deadlocks. see bug/1590298 for details.
return _is_nested_instance(e, db_exc.DBError) and '1305' in str(e)
_retry_db_errors = oslo_db_api.wrap_db_retry(
max_retries=MAX_RETRIES,
retry_interval=0.1,


+ 1
- 0
neutron/extensions/securitygroup.py View File

@ -207,6 +207,7 @@ def _validate_name_not_default(data, max_len=db_const.NAME_FIELD_SIZE):
if data.lower() == "default":
raise SecurityGroupDefaultAlreadyExists()
validators.add_validator('name_not_default', _validate_name_not_default)
sg_supported_protocols = ([None] + list(const.IP_PROTOCOL_MAP.keys()))


+ 1
- 0
neutron/plugins/ml2/db.py View File

@ -342,4 +342,5 @@ def subscribe():
resources.SEGMENT,
events.BEFORE_DELETE)
subscribe()

+ 1
- 0
neutron/plugins/ml2/extensions/dns_integration.py View File

@ -531,4 +531,5 @@ def subscribe():
_delete_port_in_external_dns_service, resources.PORT,
events.BEFORE_DELETE)
subscribe()

+ 1
- 0
neutron/services/l3_router/service_providers/base.py View File

@ -31,6 +31,7 @@ class _FeatureFlag(object):
raise RuntimeError(_("A driver can't require a feature and not "
"support it."))
UNSUPPORTED = _FeatureFlag(supports=False, requires=False)
OPTIONAL = _FeatureFlag(supports=True, requires=False)
MANDATORY = _FeatureFlag(supports=True, requires=True)


+ 1
- 0
neutron/services/segments/db.py View File

@ -321,4 +321,5 @@ def subscribe():
resources.NETWORK,
events.PRECOMMIT_DELETE)
subscribe()

+ 2
- 0
neutron/tests/common/agents/ovs_agent.py View File

@ -40,11 +40,13 @@ def get_tunnel_name_full(cls, network_type, local_ip, remote_ip):
return '%s-%s-%s' % (network_type, source_ip_hash, remote_ip_hash)
ovs_neutron_agent.OVSNeutronAgent.get_tunnel_name = get_tunnel_name_full
def main():
_main()
if __name__ == "__main__":
sys.exit(main())

+ 1
- 0
neutron/tests/functional/agent/linux/bin/ipt_binname.py View File

@ -31,6 +31,7 @@ def print_binary_name():
print(iptables_manager.binary_name)
if __name__ == "__main__":
if 'spawn' in sys.argv:
eventlet.spawn(print_binary_name).wait()


+ 1
- 1
neutron/tests/unit/agent/l3/test_router_info.py View File

@ -190,7 +190,7 @@ class TestRouterInfo(base.BaseTestCase):
{}, **self.ri_kwargs)
new_mark_ids.pop()
self.assertEqual(new_mark_ids, new_ri.available_mark_ids)
self.assertTrue(ri.available_mark_ids != new_ri.available_mark_ids)
self.assertNotEqual(ri.available_mark_ids, new_ri.available_mark_ids)
def test_process_delete(self):
ri = router_info.RouterInfo(mock.Mock(), _uuid(), {}, **self.ri_kwargs)


+ 1
- 0
neutron/tests/unit/agent/linux/test_iptables_manager.py View File

@ -362,6 +362,7 @@ def _generate_raw_restore_dump(iptables_args):
'COMMIT\n'
'# Completed by iptables_manager\n' % iptables_args)
MANGLE_DUMP = _generate_mangle_dump(IPTABLES_ARG)
MANGLE_DUMP_V6 = _generate_mangle_dump_v6(IPTABLES_ARG)
RAW_DUMP = _generate_raw_dump(IPTABLES_ARG)


+ 1
- 1
neutron/tests/unit/agent/test_securitygroups_rpc.py View File

@ -1363,9 +1363,9 @@ class SecurityGroupAgentRpcApiTestCase(base.BaseTestCase):
None, security_groups=[])
self.assertFalse(self.mock_cast.called)
# Note(nati) bn -> binary_name
# id -> device_id
PHYSDEV_MOD = '-m physdev'
PHYSDEV_IS_BRIDGED = '--physdev-is-bridged'


+ 2
- 2
neutron/tests/unit/common/test_utils.py View File

@ -439,7 +439,7 @@ class TestThrottler(base.BaseTestCase):
def sleep_mock(amount_to_sleep):
sleep(amount_to_sleep)
self.assertTrue(threshold > amount_to_sleep)
self.assertGreater(threshold, amount_to_sleep)
with mock.patch.object(utils.eventlet, "sleep",
side_effect=sleep_mock):
@ -455,7 +455,7 @@ class TestThrottler(base.BaseTestCase):
throttled_func()
self.assertEqual(3, orig_function.call_count)
self.assertTrue(timestamp < lock_with_timer.timestamp)
self.assertLess(timestamp, lock_with_timer.timestamp)
def test_method_docstring_is_preserved(self):
class Klass(object):


+ 1
- 0
neutron/tests/unit/db/quota/test_driver.py View File

@ -80,6 +80,7 @@ class TestCountableResource(resource.CountableResource):
def default(self):
return self.flag
PROJECT = 'prj_test'
RESOURCE = 'res_test'
ALT_RESOURCE = 'res_test_meh'


+ 5
- 5
neutron/tests/unit/hacking/test_checks.py View File

@ -14,8 +14,8 @@ import re
from flake8 import engine
from hacking.tests import test_doctest as hacking_doctest
import pep8
import pkg_resources
import pycodestyle
import testscenarios
import testtools
from testtools import content
@ -235,7 +235,7 @@ class HackingTestCase(base.BaseTestCase):
# TODO(amotoki): Migrate existing unit tests above to docstring tests.
# NOTE(amotoki): Is it better to enhance HackingDocTestCase in hacking repo to
# pass filename to pep8.Checker so that we can reuse it in this test.
# pass filename to pycodestyle.Checker so that we can reuse it in this test.
# I am not sure whether unit test class is public.
SELFTEST_REGEX = re.compile(r'\b(Okay|N\d{3})(\((\S+)\))?:\s(.*)')
@ -249,7 +249,7 @@ class HackingDocTestCase(hacking_doctest.HackingTestCase):
scenarios = file_cases
def test_pep8(self):
def test_pycodestyle(self):
# NOTE(jecarey): Add tests marked as off_by_default to enable testing
turn_on = set(['H106'])
@ -258,8 +258,8 @@ class HackingDocTestCase(hacking_doctest.HackingTestCase):
self.options.select = tuple(turn_on)
self.options.ignore = ('N530',)
report = pep8.BaseReport(self.options)
checker = pep8.Checker(filename=self.filename, lines=self.lines,
report = pycodestyle.BaseReport(self.options)
checker = pycodestyle.Checker(filename=self.filename, lines=self.lines,
options=self.options, report=report)
checker.check_all()
self.addDetail('doctest', content.text_content(self.raw))


+ 1
- 0
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py View File

@ -37,6 +37,7 @@ def nonzero(f):
else:
return f.__nonzero__()
# Useful global dummy variables.
NET_UUID = '3faeebfe-5d37-11e1-a64b-000c29d5f0a7'
LS_ID = 420


+ 2
- 2
neutron/tests/unit/plugins/ml2/test_plugin.py View File

@ -2036,7 +2036,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
return_value=[]):
new_context = plugin._bind_port(context)
self.assertEqual(mock_port, new_context.original)
self.assertFalse(new_context == context)
self.assertNotEqual(new_context, context)
class TestMl2PortBindingNoSG(TestMl2PortBinding):
@ -2830,7 +2830,7 @@ class TestML2Segments(Ml2PluginV2TestCase):
# Assert it is not changed
self.assertEqual(seg_id, segment[driver_api.SEGMENTATION_ID])
else:
self.assertTrue(segment[driver_api.SEGMENTATION_ID] > 0)
self.assertGreater(segment[driver_api.SEGMENTATION_ID], 0)
return segment


+ 2
- 2
neutron/tests/unit/services/metering/test_metering_plugin.py View File

@ -292,9 +292,9 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
with self.router(tenant_id=self.tenant_id, set_context=True):
with self.metering_label(tenant_id=self.tenant_id,
set_context=True) as label:
l = label['metering_label']
la = label['metering_label']
self.mock_uuid.return_value = second_uuid
with self.metering_label_rule(l['id']):
with self.metering_label_rule(la['id']):
self.mock_add_rule.assert_called_with(self.ctx,
expected_add)
self._delete('metering-label-rules', second_uuid)


+ 2
- 2
neutron/tests/unit/services/qos/test_qos_plugin.py View File

@ -943,5 +943,5 @@ class TestQosPlugin(base.BaseQosTestCase):
action_index = mock_manager.mock_calls.index(
get_rule_mock_call)
self.assertTrue(
action_index < mock_manager.mock_calls.index(driver_mock_call))
self.assertLess(
action_index, mock_manager.mock_calls.index(driver_mock_call))

+ 1
- 0
neutron/tests/unit/services/trunk/drivers/linuxbridge/agent/test_trunk_plumber.py View File

@ -95,6 +95,7 @@ class PlumberTestCase(base.BaseTestCase):
'tap47198374-5c']
self.assertEqual(expected, names)
IP_LINK_OUTPUT = """
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0


+ 2
- 1
neutron/tests/unit/testlib_api.py View File

@ -308,7 +308,8 @@ class SqlTestCase(BaseSqlTestCase, base.BaseTestCase):
class OpportunisticDBTestMixin(object):
"""Mixin that converts a BaseSqlTestCase to use the OpportunisticSqlFixture.
"""Mixin that converts a BaseSqlTestCase to use the
OpportunisticSqlFixture.
"""
SKIP_ON_UNAVAILABLE_DB = not base.bool_from_env('OS_FAIL_ON_MISSING_DEPS')


+ 1
- 1
test-requirements.txt View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=1.1.0 # Apache-2.0
bandit>=1.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0


+ 2
- 1
tox.ini View File

@ -162,7 +162,8 @@ commands = sphinx-build -W -b linkcheck doc/source doc/build/linkcheck
# N534 Untranslated exception message
# TODO(amotoki) check the following new rules should be fixed or ignored
# E731 do not assign a lambda expression, use a def
ignore = E125,E126,E128,E731,H404,H405,N530,N534
# W504 line break after binary operator
ignore = E125,E126,E128,E731,H404,H405,N530,N534,W504
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H204: Use assert(Not)Equal to check for equality


Loading…
Cancel
Save