diff --git a/run_tests.sh b/run_tests.sh index 073601f4f4..cc805db65b 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -9,8 +9,8 @@ function usage { echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." echo " -u, --update Update the virtual environment with any newer package versions" echo " --unittests-only Run unit tests only, exclude functional tests." - echo " -p, --pep8 Just run pep8" - echo " -P, --no-pep8 Don't run static code checks" + echo " -p, --flake8 Just run flake8" + echo " -P, --no-flake8 Don't run static code checks" echo " -h, --help Print this usage message" echo "" echo "Note: with no options specified, the script will try to run the tests in a virtual environment," @@ -24,8 +24,8 @@ function process_option { -h|--help) usage;; -V|--virtual-env) let always_venv=1; let never_venv=0;; -N|--no-virtual-env) let always_venv=0; let never_venv=1;; - -p|--pep8) let just_pep8=1;; - -P|--no-pep8) let no_pep8=1;; + -p|--flake8) let just_flake8=1;; + -P|--no-flake8) let no_flake8=1;; -f|--force) let force=1;; -u|--update) update=1;; --unittests-only) noseopts="$noseopts --exclude-dir=glance/tests/functional";; @@ -43,8 +43,8 @@ force=0 noseopts= noseargs= wrapper="" -just_pep8=0 -no_pep8=0 +just_flake8=0 +no_flake8=0 update=0 export NOSE_WITH_OPENSTACK=1 @@ -66,14 +66,14 @@ function run_tests { ${wrapper} $NOSETESTS } -function run_pep8 { - echo "Running pep8 ..." - PEP8_EXCLUDE=".venv,.tox,dist,doc,openstack" - PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat" - PEP8_IGNORE="--ignore=E125,E126,E711,E712" - PEP8_INCLUDE="." +function run_flake8 { + echo "Running flake8 ..." + FLAKE8_EXCLUDE=".venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build" + FLAKE8_OPTIONS="--exclude=$FLAKE8_EXCLUDE" + FLAKE8_IGNORE="--ignore=E125,E126,E711,E712,F,H" + FLAKE8_INCLUDE="." - ${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE $PEP8_IGNORE + ${wrapper} flake8 $FLAKE8_OPTIONS $FLAKE8_INCLUDE $FLAKE8_IGNORE } @@ -109,15 +109,15 @@ then fi fi -if [ $just_pep8 -eq 1 ]; then - run_pep8 +if [ $just_flake8 -eq 1 ]; then + run_flake8 exit fi run_tests || exit if [ -z "$noseargs" ]; then - if [ $no_pep8 -eq 0 ]; then - run_pep8 + if [ $no_flake8 -eq 0 ]; then + run_flake8 fi fi diff --git a/tools/test-requires b/tools/test-requires index 73ae00c13f..336f601f3f 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -1,6 +1,12 @@ # Packages needed for dev testing 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 + # For translations processing Babel @@ -12,7 +18,6 @@ nose nose-exclude openstack.nose_plugin>=0.7 nosehtmloutput>=0.0.3 -pep8==1.3.3 sphinx>=1.1.2 requests testtools>=0.9.22 diff --git a/tox.ini b/tox.ini index 4e514811e3..36d1133aa4 100644 --- a/tox.ini +++ b/tox.ini @@ -18,10 +18,15 @@ downloadcache = ~/cache/pip [testenv:pep8] commands = - pep8 --ignore=E125,E126,E711,E712 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack . + flake8 [testenv:cover] setenv = NOSE_WITH_COVERAGE=1 [testenv:venv] commands = {posargs} + +[flake8] +ignore = E125,E126,E711,E712,F,H +builtins = _ +exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build