diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-12-06 01:24:19 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-12-06 01:24:19 -0500 |
commit | c689e74fed45bf1a7b2908defc343d35f31dff71 (patch) | |
tree | 3c1904debb429274d2fac316300a8b75b200a66c /tests | |
parent | 709af49a7f161c98260cc5ddda736987fb0f1f23 (diff) | |
download | cmd2-git-c689e74fed45bf1a7b2908defc343d35f31dff71.tar.gz |
Fix flake8 issues
This commit contains a very large number of trivial changes in order to fix flake8 errors and warnings. Predominantly these are whitespace changes.
Additionally, the build for Python 3.7 on TravisCI has been tweaked to fail if there are any flake8 errors using the following commandline:
* flake8 . --count --ignore=E252 --max-complexity=31 --max-line-length=127 --show-source --statistics
NOTE: In the future the max cyclomatic complexity should be lowered, but some improvements need to be made first.
One flake8 error is being ignored entirely:
* E252 missing whitespace around parameter equals
* ignored because it doesn't correctly deal with default argument values after a type hint
A few flake8 errors are being selectively ignored in certain files:
* C901 fuction is too complex
* ignored in argparse_completer.py because the complex code is an override of argparse complexity
* E302 expected 2 blank lines after ...
* ignored in all unit test files for convenience
* F401 module imported but unused
* ignored in cmd2/__init__.py because imports are for convenience of cmd2 developers and backwards compatibility
* F821 undefined name
* ignored in cmd2 script files which are intended to run only within cmd2 applications via pyscript where "app" and "cmd" are defined
Diffstat (limited to 'tests')
33 files changed, 33 insertions, 3 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index 2aeb9ddf..037f3866 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,3 @@ # # -*- coding: utf-8 -*- # - diff --git a/tests/conftest.py b/tests/conftest.py index ac6a1896..223389b9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,7 +5,6 @@ Cmd2 unit/functional testing Copyright 2016 Federico Ceratto <federico.ceratto@gmail.com> Released under MIT license, see LICENSE file """ -import sys from typing import Optional from unittest import mock @@ -31,7 +30,7 @@ BASE_HELP = """Documented commands (type help <topic>): ======================================== alias help load py quit shell edit history macro pyscript set shortcuts -""" +""" # noqa: W291 BASE_HELP_VERBOSE = """ Documented commands (type help <topic>): @@ -108,6 +107,7 @@ quiet: False # Don't print nonessential feedback timing: False # Report execution times """ + def normalize(block): """ Normalize a block of text to perform comparison. diff --git a/tests/pyscript/bar1.py b/tests/pyscript/bar1.py index 521e2c29..0f2b1e5e 100644 --- a/tests/pyscript/bar1.py +++ b/tests/pyscript/bar1.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.bar('11', '22') diff --git a/tests/pyscript/custom_echo.py b/tests/pyscript/custom_echo.py index 14040e4c..3a79133a 100644 --- a/tests/pyscript/custom_echo.py +++ b/tests/pyscript/custom_echo.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 custom.cmd_echo = True custom.echo('blah!') diff --git a/tests/pyscript/foo1.py b/tests/pyscript/foo1.py index d9345354..443282a5 100644 --- a/tests/pyscript/foo1.py +++ b/tests/pyscript/foo1.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.foo('aaa', 'bbb', counter=3, trueval=True, constval=True) diff --git a/tests/pyscript/foo2.py b/tests/pyscript/foo2.py index d3600a60..9aa37105 100644 --- a/tests/pyscript/foo2.py +++ b/tests/pyscript/foo2.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.foo('11', '22', '33', '44', counter=3, trueval=True, constval=True) diff --git a/tests/pyscript/foo3.py b/tests/pyscript/foo3.py index fc0e084a..e4384076 100644 --- a/tests/pyscript/foo3.py +++ b/tests/pyscript/foo3.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.foo('11', '22', '33', '44', '55', '66', counter=3, trueval=False, constval=False) diff --git a/tests/pyscript/foo4.py b/tests/pyscript/foo4.py index e4b7d01c..a601ccd8 100644 --- a/tests/pyscript/foo4.py +++ b/tests/pyscript/foo4.py @@ -1,3 +1,4 @@ +# flake8: noqa F821 app.cmd_echo = True result = app.foo('aaa', 'bbb', counter=3) out_text = 'Fail' diff --git a/tests/pyscript/help.py b/tests/pyscript/help.py index 664c0488..3f24246d 100644 --- a/tests/pyscript/help.py +++ b/tests/pyscript/help.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.help() diff --git a/tests/pyscript/help_media.py b/tests/pyscript/help_media.py index d8d97c42..38c4a2f8 100644 --- a/tests/pyscript/help_media.py +++ b/tests/pyscript/help_media.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.help('media') diff --git a/tests/pyscript/media_movies_add1.py b/tests/pyscript/media_movies_add1.py index 7249c0ef..b5045a39 100644 --- a/tests/pyscript/media_movies_add1.py +++ b/tests/pyscript/media_movies_add1.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media.movies.add('My Movie', 'PG-13', director=('George Lucas', 'J. J. Abrams')) diff --git a/tests/pyscript/media_movies_add2.py b/tests/pyscript/media_movies_add2.py index 681095d7..91dbbc6b 100644 --- a/tests/pyscript/media_movies_add2.py +++ b/tests/pyscript/media_movies_add2.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media.movies.add('My Movie', 'PG-13', actor=('Mark Hamill'), director=('George Lucas', 'J. J. Abrams')) diff --git a/tests/pyscript/media_movies_list1.py b/tests/pyscript/media_movies_list1.py index edbc2021..505d1f91 100644 --- a/tests/pyscript/media_movies_list1.py +++ b/tests/pyscript/media_movies_list1.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media.movies.list() diff --git a/tests/pyscript/media_movies_list2.py b/tests/pyscript/media_movies_list2.py index 5ad01b7b..69e0d3c5 100644 --- a/tests/pyscript/media_movies_list2.py +++ b/tests/pyscript/media_movies_list2.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media().movies().list() diff --git a/tests/pyscript/media_movies_list3.py b/tests/pyscript/media_movies_list3.py index bdbdfceb..c4f0cc1e 100644 --- a/tests/pyscript/media_movies_list3.py +++ b/tests/pyscript/media_movies_list3.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app('media movies list') diff --git a/tests/pyscript/media_movies_list4.py b/tests/pyscript/media_movies_list4.py index 5f7bdaa9..29e98fe7 100644 --- a/tests/pyscript/media_movies_list4.py +++ b/tests/pyscript/media_movies_list4.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media.movies.list(actor='Mark Hamill') diff --git a/tests/pyscript/media_movies_list5.py b/tests/pyscript/media_movies_list5.py index fa4efa5b..1c249ebf 100644 --- a/tests/pyscript/media_movies_list5.py +++ b/tests/pyscript/media_movies_list5.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media.movies.list(actor=('Mark Hamill', 'Carrie Fisher')) diff --git a/tests/pyscript/media_movies_list6.py b/tests/pyscript/media_movies_list6.py index ef1851cd..c16ae6c5 100644 --- a/tests/pyscript/media_movies_list6.py +++ b/tests/pyscript/media_movies_list6.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media.movies.list(rating='PG') diff --git a/tests/pyscript/media_movies_list7.py b/tests/pyscript/media_movies_list7.py index 7c827b7f..d4ca7dca 100644 --- a/tests/pyscript/media_movies_list7.py +++ b/tests/pyscript/media_movies_list7.py @@ -1,2 +1,3 @@ +# flake8: noqa F821 app.cmd_echo = True app.media.movies.list(rating=('PG', 'PG-13')) diff --git a/tests/pyscript/pyscript_dir1.py b/tests/pyscript/pyscript_dir1.py index 14a70a31..81814d70 100644 --- a/tests/pyscript/pyscript_dir1.py +++ b/tests/pyscript/pyscript_dir1.py @@ -1,3 +1,4 @@ +# flake8: noqa F821 out = dir(app) out.sort() print(out) diff --git a/tests/pyscript/pyscript_dir2.py b/tests/pyscript/pyscript_dir2.py index 28c61c8e..ebbbf712 100644 --- a/tests/pyscript/pyscript_dir2.py +++ b/tests/pyscript/pyscript_dir2.py @@ -1,3 +1,4 @@ +# flake8: noqa F821 out = dir(app.media) out.sort() print(out) diff --git a/tests/scripts/recursive.py b/tests/scripts/recursive.py index 4c29d317..3359d31e 100644 --- a/tests/scripts/recursive.py +++ b/tests/scripts/recursive.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # coding=utf-8 +# flake8: noqa F821 """ Example demonstrating that running a Python script recursively inside another Python script isn't allowed """ diff --git a/tests/test_acargparse.py b/tests/test_acargparse.py index b6abc444..64612737 100644 --- a/tests/test_acargparse.py +++ b/tests/test_acargparse.py @@ -1,3 +1,4 @@ +# flake8: noqa E302 """ Unit/functional testing for argparse customizations in cmd2 diff --git a/tests/test_argparse.py b/tests/test_argparse.py index f1078e73..29f0d232 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Cmd2 testing for argument parsing """ diff --git a/tests/test_autocompletion.py b/tests/test_autocompletion.py index 7285af5c..2b9e0458 100644 --- a/tests/test_autocompletion.py +++ b/tests/test_autocompletion.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Unit/functional testing for argparse completer in cmd2 diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index 47fcdb34..c7201e4b 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Unit/functional testing for argparse completer in cmd2 diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 59c6bb60..b10322f1 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Cmd2 unit/functional testing diff --git a/tests/test_completion.py b/tests/test_completion.py index dffb03ec..2a418cd6 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Unit/functional testing for readline tab-completion functions in the cmd2.py module. diff --git a/tests/test_parsing.py b/tests/test_parsing.py index ba72edd6..78adf880 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Test the parsing logic in parsing.py diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 81dd7683..1f95017c 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Test plugin infrastructure and hooks. diff --git a/tests/test_pyscript.py b/tests/test_pyscript.py index ce5e267d..692a498b 100644 --- a/tests/test_pyscript.py +++ b/tests/test_pyscript.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Unit/functional testing for argparse completer in cmd2 diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 58ae16b4..6f1c4be0 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Cmd2 functional testing based on transcript diff --git a/tests/test_utils.py b/tests/test_utils.py index 35524bdf..2f727aaf 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,5 @@ # coding=utf-8 +# flake8: noqa E302 """ Unit testing for cmd2/utils.py module. |