Merge pull request #97 from dims/enforce-update-pep8

tox target to enforce pep8
This commit is contained in:
Mehdy Bohlool 2017-01-13 02:40:30 -08:00 committed by GitHub
commit 37d20f2fe7
7 changed files with 44 additions and 18 deletions

View File

@ -9,6 +9,7 @@ env:
- TOXENV=py27,codecov
- TOXENV=py27-functional,codecov
- TOXENV=py35-functional,codecov
- TOXENV=update-pep8,codecov
- TOXENV=coverage,codecov
install:

View File

@ -19,9 +19,10 @@ import tempfile
import urllib3
import yaml
from kubernetes.client import ApiClient, ConfigurationObject, configuration
from oauth2client.client import GoogleCredentials
from kubernetes.client import ApiClient, ConfigurationObject, configuration
from .config_exception import ConfigException
KUBE_CONFIG_DEFAULT_LOCATION = '~/.kube/config'

View File

@ -17,13 +17,14 @@ import os
import shutil
import tempfile
import unittest
import yaml
from six import PY3
from .config_exception import ConfigException
from .kube_config import (ConfigNode, FileOrData, KubeConfigLoader,
_cleanup_temp_files, _create_temp_file_with_content,
load_kube_config, list_kube_config_contexts,
list_kube_config_contexts, load_kube_config,
new_client_from_config)
BEARER_TOKEN_FORMAT = "Bearer %s"
@ -542,7 +543,7 @@ class TestKubeConfigLoader(BaseTestCase):
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
actual = FakeConfig()
load_kube_config(config_file=config_file,context="simple_token",
load_kube_config(config_file=config_file, context="simple_token",
client_configuration=actual)
self.assertEqual(expected, actual)

View File

@ -19,6 +19,7 @@ import sys
from collections import OrderedDict
import urllib3
from constants import KUBERNETES_BRANCH, SPEC_VERSION
# these four constants are shown as part of this example in []:

View File

@ -21,9 +21,13 @@ set -o errexit
set -o nounset
set -o pipefail
if ! which virtualenv > /dev/null 2>&1; then
echo "virtualenv is not installed. run: [sudo] pip install virtualenv"
exit
ENV=${VIRTUAL_ENV:-}
if [[ -z ${ENV} ]]; then
if ! which virtualenv > /dev/null 2>&1; then
echo "virtualenv is not installed. run: [sudo] pip install virtualenv"
exit
fi
fi
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
@ -37,10 +41,18 @@ pushd "${CLIENT_ROOT}" > /dev/null
CLIENT_ROOT=`pwd`
popd > /dev/null
virtualenv "${SCRIPT_ROOT}/.py"
if [[ -z ${ENV} ]]; then
echo "--- Creating virtualenv"
virtualenv "${SCRIPT_ROOT}/.py"
VIRTUAL_ENV_DISABLE_PROMPT=1; source "${SCRIPT_ROOT}/.py/bin/activate"
trap "deactivate" EXIT SIGINT
VIRTUAL_ENV_DISABLE_PROMPT=1; source "${SCRIPT_ROOT}/.py/bin/activate"
trap "deactivate" EXIT SIGINT
echo "--- Updating tools"
pip install --upgrade pep8
pip install --upgrade autopep8
pip install --upgrade isort
fi
SAVEIFS=$IFS
trap "IFS=$SAVEIFS" EXIT SIGINT
@ -48,11 +60,6 @@ IFS=,
SOURCES="${SCRIPT_ROOT}/../setup.py,${CLIENT_ROOT}/config/*.py,${CLIENT_ROOT}/watch/*.py,${SCRIPT_ROOT}/*.py,${CLIENT_ROOT}/../examples/*.py"
echo "--- Updating tools"
pip install --upgrade pep8
pip install --upgrade autopep8
pip install --upgrade isort
echo "--- applying autopep8"
for SOURCE in $SOURCES; do
autopep8 -i -a -a $SOURCE
@ -69,4 +76,11 @@ for SOURCE in $SOURCES; do
pep8 $SOURCE
done
if [[ ! -z ${ENV} ]]; then
if [[ $(git status --porcelain) != "" ]]; then
git --no-pager diff
exit 1
fi
fi
echo "---Done."

View File

@ -6,4 +6,7 @@ randomize>=0.13
mock>=2.0.0
sphinx>=1.2.1,!=1.3b1,<1.4 # BSD
recommonmark
codecov>=1.4.0
codecov>=1.4.0
pep8
autopep8
isort

11
tox.ini
View File

@ -1,9 +1,6 @@
[tox]
envlist = py27, py34, py35
[testenv:docs]
commands = python setup.py build_sphinx
[testenv]
passenv = TOXENV CI TRAVIS TRAVIS_*
usedevelop = True
@ -13,6 +10,14 @@ commands =
python -V
nosetests []
[testenv:docs]
commands =
python setup.py build_sphinx
[testenv:update-pep8]
commands =
{toxinidir}/scripts/update-pep8.sh
[testenv:py27-functional]
commands =
python -V