Fix some pep8 errors, update tox.ini

Fixed E731, W503 and I201 pep8 errors.

Added flake8-import-order to test-requirements.txt to avoid
an "unknown option 'import-order-style' ignored" warning.

Removed {posargs} from flake8 invocation so it can be called
such as 'tox -e pep8 HEAD~1' in order to only run on files
changed in the top commit.

Removed py34, py27 and pypy from the tox.ini envlist since
there are no unit tests, and tox reports it skipped all tests.

Change-Id: I574cafe074befa59aaee44b092b011e27f5f4211
This commit is contained in:
Brian Haley 2018-04-26 14:37:49 -04:00
parent 02a5e2b076
commit 33ef4607ff
9 changed files with 23 additions and 18 deletions

View File

@ -58,8 +58,8 @@ class NetworksTestDHCPv6(base.BaseNetworkTest):
ports = body['ports'] ports = body['ports']
for port in ports: for port in ports:
if (port['device_owner'].startswith( if (port['device_owner'].startswith(
constants.DEVICE_OWNER_ROUTER_INTF) constants.DEVICE_OWNER_ROUTER_INTF) and
and port['device_id'] in [r['id'] for r in self.routers]): port['device_id'] in [r['id'] for r in self.routers]):
self.client.remove_router_interface_with_port_id( self.client.remove_router_interface_with_port_id(
port['device_id'], port['id'] port['device_id'], port['id']
) )

View File

@ -79,11 +79,11 @@ class NetworksIpAvailabilityTest(base.BaseAdminNetworkTest):
def calc_total_ips(prefix, ip_version): def calc_total_ips(prefix, ip_version):
# will calculate total ips after removing reserved. # will calculate total ips after removing reserved.
if ip_version == lib_constants.IP_VERSION_4: if ip_version == lib_constants.IP_VERSION_4:
total_ips = 2 ** (lib_constants.IPv4_BITS total_ips = 2 ** (lib_constants.IPv4_BITS -
- prefix) - DEFAULT_IP4_RESERVED prefix) - DEFAULT_IP4_RESERVED
elif ip_version == lib_constants.IP_VERSION_6: elif ip_version == lib_constants.IP_VERSION_6:
total_ips = 2 ** (lib_constants.IPv6_BITS total_ips = 2 ** (lib_constants.IPv6_BITS -
- prefix) - DEFAULT_IP6_RESERVED prefix) - DEFAULT_IP6_RESERVED
return total_ips return total_ips

View File

@ -159,9 +159,12 @@ class RoutersTest(base_routers.BaseRouterTest):
# Add router interface with subnet id # Add router interface with subnet id
router = self._create_router(data_utils.rand_name('router'), True) router = self._create_router(data_utils.rand_name('router'), True)
intf = self.create_router_interface(router['id'], subnet['id']) intf = self.create_router_interface(router['id'], subnet['id'])
status_active = lambda: self.client.show_port(
intf['port_id'])['port']['status'] == 'ACTIVE' def _status_active():
utils.wait_until_true(status_active, exception=AssertionError) return self.client.show_port(
intf['port_id'])['port']['status'] == 'ACTIVE'
utils.wait_until_true(_status_active, exception=AssertionError)
@decorators.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c') @decorators.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c')
@tutils.requires_ext(extension='extraroute', service='network') @tutils.requires_ext(extension='extraroute', service='network')

View File

@ -18,11 +18,12 @@
"""Utilities and helper functions.""" """Utilities and helper functions."""
import eventlet
import functools import functools
import threading import threading
import time import time
import eventlet
class classproperty(object): class classproperty(object):
def __init__(self, f): def __init__(self, f):

View File

@ -68,8 +68,8 @@ class FloatingIpTestCasesMixin(object):
network_id=CONF.network.public_network_id) network_id=CONF.network.public_network_id)
for subnet in subnets['subnets']: for subnet in subnets['subnets']:
if (subnet['gateway_ip'] if (subnet['gateway_ip'] and
and subnet['ip_version'] == lib_constants.IP_VERSION_4): subnet['ip_version'] == lib_constants.IP_VERSION_4):
return subnet['gateway_ip'] return subnet['gateway_ip']
@classmethod @classmethod

View File

@ -69,8 +69,8 @@ class NetworkMtuTest(NetworkMtuBaseTest):
def skip_checks(cls): def skip_checks(cls):
super(NetworkMtuTest, cls).skip_checks() super(NetworkMtuTest, cls).skip_checks()
if ("vxlan" not in if ("vxlan" not in
config.CONF.neutron_plugin_options.available_type_drivers config.CONF.neutron_plugin_options.available_type_drivers or
or "gre" not in "gre" not in
config.CONF.neutron_plugin_options.available_type_drivers): config.CONF.neutron_plugin_options.available_type_drivers):
raise cls.skipException("GRE or VXLAN type_driver is not enabled") raise cls.skipException("GRE or VXLAN type_driver is not enabled")

View File

@ -75,8 +75,8 @@ class QoSTest(base.BaseTempestTestCase):
BS = 512 BS = 512
COUNT = BUFFER_SIZE / BS COUNT = BUFFER_SIZE / BS
FILE_SIZE = BS * COUNT FILE_SIZE = BS * COUNT
LIMIT_BYTES_SEC = (constants.LIMIT_KILO_BITS_PER_SECOND * 1024 LIMIT_BYTES_SEC = (constants.LIMIT_KILO_BITS_PER_SECOND * 1024 *
* TOLERANCE_FACTOR / 8.0) TOLERANCE_FACTOR / 8.0)
FILE_PATH = "/tmp/img" FILE_PATH = "/tmp/img"
NC_PORT = 1234 NC_PORT = 1234

View File

@ -5,6 +5,7 @@
hacking<0.13,>=0.12.0 # Apache-2.0 hacking<0.13,>=0.12.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
flake8-import-order==0.12 # LGPLv3
python-subunit>=1.0.0 # Apache-2.0/BSD python-subunit>=1.0.0 # Apache-2.0/BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0

View File

@ -1,6 +1,6 @@
[tox] [tox]
minversion = 2.0 minversion = 2.0
envlist = py34,py27,pypy,pep8 envlist = pep8
skipsdist = True skipsdist = True
[testenv] [testenv]
@ -15,7 +15,7 @@ commands = python setup.py test --slowest --testr-args='{posargs}'
[testenv:pep8] [testenv:pep8]
commands = commands =
sh ./tools/misc-sanity-checks.sh sh ./tools/misc-sanity-checks.sh
flake8 {posargs} flake8
whitelist_externals = whitelist_externals =
sh sh