From 24b4039bae557a8f29be783c3fdd3f9f148c4b0e Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 18 May 2013 09:09:35 -0700 Subject: [PATCH] Migrate to flake8. Fixes bug 1172444. Change-Id: Ia063ec67de9e6061ce38b948c9eb60b5589c7bb4 --- run_tests.sh | 22 ++-------------------- tests/v1/fakes.py | 4 ++-- tests/v1/test_auth.py | 2 +- tests/v2/fakes.py | 4 ++-- tests/v2/test_auth.py | 2 +- tools/test-requires | 7 ++++++- tox.ini | 8 ++++++-- 7 files changed, 20 insertions(+), 29 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 9b3684f3b..ef018f365 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -117,26 +117,8 @@ function copy_subunit_log { } function run_pep8 { - echo "Running pep8 ..." - srcfiles="cinderclient tests" - # Just run PEP8 in current environment - # - # NOTE(sirp): W602 (deprecated 3-arg raise) is being ignored for the - # following reasons: - # - # 1. It's needed to preserve traceback information when re-raising - # exceptions; this is needed b/c Eventlet will clear exceptions when - # switching contexts. - # - # 2. There doesn't appear to be an alternative, "pep8-tool" compatible way of doing this - # in Python 2 (in Python 3 `with_traceback` could be used). - # - # 3. Can find no corroborating evidence that this is deprecated in Python 2 - # other than what the PEP8 tool claims. It is deprecated in Python 3, so, - # perhaps the mistake was thinking that the deprecation applied to Python 2 - # as well. - pep8_opts="--ignore=E202,W602 --repeat" - ${wrapper} pep8 ${pep8_opts} ${srcfiles} + echo "Running flake8 ..." + ${wrapper} flake8 } TESTRTESTS="testr run --parallel $testropts" diff --git a/tests/v1/fakes.py b/tests/v1/fakes.py index ee4a58dc3..b78e8ef98 100644 --- a/tests/v1/fakes.py +++ b/tests/v1/fakes.py @@ -302,10 +302,10 @@ class FakeHTTPClient(base_client.HTTPClient): return (200, {}, { 'volume_types': [{'id': 1, 'name': 'test-type-1', - 'extra_specs':{}}, + 'extra_specs': {}}, {'id': 2, 'name': 'test-type-2', - 'extra_specs':{}}]}) + 'extra_specs': {}}]}) def get_types_1(self, **kw): return (200, {}, {'volume_type': {'id': 1, diff --git a/tests/v1/test_auth.py b/tests/v1/test_auth.py index 4ad12310f..c0b59e940 100644 --- a/tests/v1/test_auth.py +++ b/tests/v1/test_auth.py @@ -192,7 +192,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): } correct_response = json.dumps(dict_correct_response) dict_responses = [ - {"headers": {'location':'http://127.0.0.1:5001'}, + {"headers": {'location': 'http://127.0.0.1:5001'}, "status_code": 305, "text": "Use proxy"}, # Configured on admin port, cinder redirects to v2.0 port. diff --git a/tests/v2/fakes.py b/tests/v2/fakes.py index 038a434e1..8567591ad 100644 --- a/tests/v2/fakes.py +++ b/tests/v2/fakes.py @@ -309,10 +309,10 @@ class FakeHTTPClient(base_client.HTTPClient): return (200, {}, { 'volume_types': [{'id': 1, 'name': 'test-type-1', - 'extra_specs':{}}, + 'extra_specs': {}}, {'id': 2, 'name': 'test-type-2', - 'extra_specs':{}}]}) + 'extra_specs': {}}]}) def get_types_1(self, **kw): return (200, {}, {'volume_type': {'id': 1, diff --git a/tests/v2/test_auth.py b/tests/v2/test_auth.py index b18a7a327..b29752a25 100644 --- a/tests/v2/test_auth.py +++ b/tests/v2/test_auth.py @@ -208,7 +208,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): } correct_response = json.dumps(dict_correct_response) dict_responses = [ - {"headers": {'location':'http://127.0.0.1:5001'}, + {"headers": {'location': 'http://127.0.0.1:5001'}, "status_code": 305, "text": "Use proxy"}, # Configured on admin port, cinder redirects to v2.0 port. diff --git a/tools/test-requires b/tools/test-requires index 4dd52496c..74be7692a 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -1,10 +1,15 @@ distribute>=0.6.24 +# Install bounded pep8/pyflakes first, then let flake8 install +pep8==1.4.5 +pyflakes==0.7.2 +flake8==2.0 +hacking>=0.5.3,<0.6 + coverage discover fixtures mock -pep8==1.3.3 sphinx>=1.1.2 testrepository>=0.0.13 testtools>=0.9.22 diff --git a/tox.ini b/tox.ini index 34ca825c1..4f37062e9 100644 --- a/tox.ini +++ b/tox.ini @@ -12,8 +12,7 @@ deps = -r{toxinidir}/tools/pip-requires commands = python setup.py testr --testr-args='{posargs}' [testenv:pep8] -deps = pep8 -commands = pep8 --repeat --show-source cinderclient setup.py +commands = flake8 [testenv:venv] commands = {posargs} @@ -23,3 +22,8 @@ commands = python setup.py testr --coverage --testr-args='{posargs}' [tox:jenkins] downloadcache = ~/cache/pip + +[flake8] +show-source = True +ignore = F,H +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools