Skip to content

Commit

Permalink
upgrade testing, multiple python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
stavxyz committed Apr 25, 2016
1 parent adf6605 commit 5efa4b8
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 48 deletions.
2 changes: 2 additions & 0 deletions chef/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Package attributes and metadata."""

__all__ = (
'__title__',
'__summary__',
Expand Down
8 changes: 6 additions & 2 deletions chef/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=wildcard-import
"""Okchef Package level goodies."""

from __future__ import absolute_import

Expand All @@ -17,15 +20,16 @@
from chef.client import ChefClient
from chef.__about__ import * # noqa

__all__ = ['HOSTED_CHEF_API', 'ChefClient']
__all__ = ('HOSTED_CHEF_API', 'ChefClient')

HOSTED_CHEF_APIS = ['https://api.chef.io', 'https://api.opscode.com']
HOSTED_CHEF_APIS = ('https://api.chef.io', 'https://api.opscode.com')
HOSTED_CHEF_API = HOSTED_CHEF_APIS[0]
_HERE = os.path.dirname(os.path.realpath(__file__))
_HEAD_FILE = os.path.abspath(os.path.join(_HERE, os.pardir, '.git', 'HEAD'))


def _read_commit_dot_txt():
"""Read the commit.txt file and return the contents."""
commit_dot_txt = os.path.join(_HERE, 'commit.txt')
if os.path.isfile(commit_dot_txt):
with open(commit_dot_txt) as sha:
Expand Down
2 changes: 2 additions & 0 deletions chef/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def session(self):
return self._session

def authenticate(self, user_id, private_key):
"""Authenticate this session with the chef server."""
auth = requests_chef.ChefAuth(user_id, private_key)
self.session.auth = auth
self.user_id = user_id
Expand All @@ -83,6 +84,7 @@ def get_version(self):
return self.get('/version').json()

def request(self, path, **kwargs):
"""Perform the request with python-requests."""
url = '%s/%s' % (self.endpoint, path.strip().lstrip(' /'))
method = kwargs.pop('method', 'GET') or 'GET'
# why? avoid KeyError and falsy values
Expand Down
7 changes: 4 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ machine:

dependencies:
override:
- pip install tox
- pip install python-coveralls
- pip install -U pip
- pip install -U tox tox-pyenv python-coveralls
- pyenv local 2.7.9 3.4.3 3.5.0

test:
override:
- env PATH="$HOME/bin:$PATH" tox
- tox -v
post:
- mkdir -p $CIRCLE_ARTIFACTS/coverage
- mkdir -p $CIRCLE_TEST_REPORTS/xunit
Expand Down
16 changes: 12 additions & 4 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
[Messages Control]
# W0511: TODOs in code comments are fine.
# W0142: *args and **kwargs are fine.
disable=W0511,W0142
disable=
bad-builtin,
locally-disabled,
fixme

[BASIC]
# Don't require docstrings on tests or Python Special Methods
no-docstring-rgx=(__.*__|[tT]est.*|setUp|tearDown)
no-docstring-rgx=(__.*__|[tT]est.*|setUp|tearDown)
# Some names we are okay with
good-names=f,e,i,j,k,v,ex,_,x,y,z

[REPORTS]
msg-template={msg_id}({symbol}): {path},{line}: {msg} | {obj}
reports=yes
output-format=colorized
20 changes: 12 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=invalid-name,wrong-import-order

"""Okchef package installation."""

import os
import setuptools
import subprocess
import sys

from setuptools import find_packages
from setuptools import setup

src_dir = os.path.dirname(os.path.realpath(__file__))

about = {}
with open(os.path.join(src_dir, 'chef', '__about__.py')) as abt:
exec(abt.read(), about)
exec(abt.read(), {'__builtins__': {}}, about) # pylint: disable=exec-used

# pandoc --from=markdown_github --to=rst README.md --output=README.rst
readme = os.path.join(src_dir, 'README.rst')
Expand Down Expand Up @@ -59,10 +62,11 @@

# Add the commit hash to the keywords for sanity.
if any(k in ' '.join(sys.argv).lower() for k in ['upload', 'dist']):
import subprocess
try:
current_commit = subprocess.check_output(
['git', 'rev-parse', 'HEAD']).strip()
['git', 'rev-parse', 'HEAD'],
cwd=src_dir,
universal_newlines=True).strip()
except (OSError, subprocess.CalledProcessError):
pass
else:
Expand All @@ -79,7 +83,7 @@
'tests_require': TESTS_REQUIRE,
'test_suite': 'tests',
'install_requires': INSTALL_REQUIRES,
'packages': find_packages(exclude=['tests']),
'packages': setuptools.find_packages(exclude=['tests']),
'author': about['__author__'],
'author_email': about['__email__'],
'classifiers': CLASSIFIERS,
Expand All @@ -88,4 +92,4 @@
}


setup(**package_attributes)
setuptools.setup(**package_attributes)
43 changes: 12 additions & 31 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
[tox]
# Only the following setting are valid in this section and in the Jenkins section
# https://tox.readthedocs.org/en/latest/config.html#tox-global-settings
envlist = py27,py34,py35,style

# minversion=ver # minimally required tox version
# toxworkdir=path # tox working directory, defaults to {toxinidir}/.tox
# setupdir=path # defaults to {toxinidir}
# distdir=path # defaults to {toxworkdir}/dist
# distshare=path # defaults to {homedir}/.tox/distshare
# envlist=ENVLIST # defaults to the list of all environments
# skipsdist=BOOL # defaults to false
envlist = py27
skipsdist = True


##############
# DEFAULT #
##############
[testenv]
# This is the default setup. All other environments will inherit these settings
usedevelop = True
install_command = pip install --verbose --pre --exists-action=w {opts} {packages}
basepython = python
pyflake_codes = F401,F402,F403,F404,F811,F812,F821,F822,F823,F831,F841

# pull in dependencies from our pip-* files
install_command = pip install --verbose -U --pre {opts} {packages}
deps= -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt

commands=
nosetests {posargs} --with-doctest --with-coverage --cover-html --cover-package=chef --cover-html-dir=coverage/ --with-xunit
flake8 --select="{[testenv]pyflake_codes}" chef
flake8 --exit-zero -j 1 chef
/bin/bash -c 'pylint --ignore=tests chef --rcfile=pylintrc || exit 0'
python -c "import sys;print('\nPYTHON VERSION\n%s\n' % sys.version)"
nosetests {posargs} --verbose --with-doctest --with-coverage --cover-html --cover-package=chef --cover-html-dir=coverage/ --with-xunit

[testenv:style]
basepython = python2.7
commands =
flake8 chef setup.py --statistics
flake8 tests --statistics --ignore D100,D101,D102
pylint chef setup.py


[flake8]
#flake8 default settings
exclude = tests
max-complexity = 12
max-complexity = 12

0 comments on commit 5efa4b8

Please sign in to comment.