Add tox.ini and fix pep8 problems

Change-Id: I42f6ed2fbf211e7ac6adcd8e40ce29ec8c7c5c5c
This commit is contained in:
Lucas Alvares Gomes 2013-06-12 12:01:54 +01:00
parent 676c8170f2
commit 91f75348fb
4 changed files with 60 additions and 10 deletions

5
.testr.conf Normal file
View File

@ -0,0 +1,5 @@
[DEFAULT]
test_command=python -m subunit.run discover . $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -1,13 +1,13 @@
#!/usr/bin/python
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@ -30,10 +30,11 @@ PHASES = ['pre-configure',
def main(argv=sys.argv):
parser = argparse.ArgumentParser(
description="""Runs through all of the phases to ensure configuration is
applied and enabled on a machine. Will exit with an error if any phase has
a problem. Scripts should not depend on eachother having worked properly.
Set OS_REFRESH_CONFIG_BASE_DIR environment variable to override the default
description="""Runs through all of the phases to ensure
configuration is applied and enabled on a machine. Will exit with
an error if any phase has a problem. Scripts should not depend on
eachother having worked properly. Set OS_REFRESH_CONFIG_BASE_DIR
environment variable to override the default
""")
parser.add_argument('--print-base', default=False, action='store_true',
help='Print base dir and exit')
@ -56,7 +57,8 @@ def main(argv=sys.argv):
log = logging.getLogger('os-refresh-config')
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(
logging.Formatter('[%(asctime)s] (%(name)s) [%(levelname)s] %(message)s'))
logging.Formatter(
'[%(asctime)s] (%(name)s) [%(levelname)s] %(message)s'))
log.addHandler(handler)
log.setLevel(options.log_level)

View File

@ -16,8 +16,8 @@ config = {
'long_description': open('README.md', 'rb').read(),
'packages': ['os_refresh_config'],
'entry_points': {
'console_scripts': [
'os-refresh-config = os_refresh_config.os_refresh_config:main']
'console_scripts': [
'os-refresh-config = os_refresh_config.os_refresh_config:main']
}
}

43
tox.ini Normal file
View File

@ -0,0 +1,43 @@
[tox]
envlist = py26,py27,pep8
[testenv]
setenv = LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=C
deps=
testtools
testrepository
coverage
babel
commands=
bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
bash -c 'testr run --parallel {posargs} ; RET=$? echo "Slowest Tests" ; testr slowest && exit $RET'
[testenv:py26]
deps=
testtools
testrepository
coverage
babel
discover
argparse
[pep8]
ignore = E125
[testenv:pep8]
deps = pep8
commands =
pep8 --repeat --show-source --exclude=.venv,.tox,doc .
[testenv:venv]
commands = {posargs}
[testenv:cover]
setenv = PYTHON=coverage run --source os_refresh_config
commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
bash -c 'testr run --parallel ; RET=$? ; coverage combine ; coverage html -d ./cover $OMIT && exit $RET'
[tox:jenkins]
downloadcache = ~/cache/pip