Setup a tox pep8 check and update test-requirements.txt

Add a tox pep8 check.
Fix PEP8 error in tools/list_ptls.py

Update test-requirements.txt for libraries used.

Change-Id: I179036ebbce555586a711677f45337b364d4847f
This commit is contained in:
John L. Villalovos 2016-05-20 11:04:59 -07:00
parent b3a10927bf
commit ffa7d55448
4 changed files with 40 additions and 3 deletions

View File

@ -1 +1,4 @@
hacking<0.11,>=0.10.0
PyYAML>=3.1.0 # MIT
requests>=2.10.0 # Apache-2.0
yaml2ical>=0.6.1 yaml2ical>=0.6.1

20
test_tools/flake8wrap.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
#
# A simple wrapper around flake8 which makes it possible
# to ask it to only verify files changed in the current
# git HEAD patch.
#
# Intended to be invoked via tox:
#
# tox -epep8 -- -HEAD
#
if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
diff -u --from-file /dev/null ${files} | flake8 --diff "$@"
else
echo "Running flake8 on all files"
exec flake8 "$@"
fi

View File

@ -22,6 +22,7 @@ import yaml
PROJECTS_LIST = "http://git.openstack.org/cgit/openstack/governance/plain/reference/projects.yaml" # noqa PROJECTS_LIST = "http://git.openstack.org/cgit/openstack/governance/plain/reference/projects.yaml" # noqa
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
@ -57,7 +58,7 @@ def main():
initial_indent=args.msg + ' ', initial_indent=args.msg + ' ',
subsequent_indent=args.msg + ' ', subsequent_indent=args.msg + ' ',
width=80, width=80,
)) ))
if __name__ == '__main__': if __name__ == '__main__':

17
tox.ini
View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = ical envlist = ical,pep8
minversion = 1.6 minversion = 1.6
skipsdist = True skipsdist = True
@ -7,12 +7,12 @@ skipsdist = True
install_command = pip install -U {opts} {packages} install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt
whitelist_externals = mkdir
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}
[testenv:ical] [testenv:ical]
whitelist_externals = mkdir
commands = commands =
mkdir -p output/calendars mkdir -p output/calendars
yaml2ical -n "OpenStack Meetings" \ yaml2ical -n "OpenStack Meetings" \
@ -24,3 +24,16 @@ commands =
[testenv:check] [testenv:check]
commands = commands =
python tools/check_channels.py -y meetings python tools/check_channels.py -y meetings
[testenv:pep8]
whitelist_externals = bash
commands =
bash test_tools/flake8wrap.sh {posargs}
[flake8]
ignore =
exclude = .git,.tox
max-complexity = 14
[hacking]
import_exceptions =