From 1b7040a4327258db336310e17cf3ebfdfa7e739f Mon Sep 17 00:00:00 2001 From: Kent Wills Date: Wed, 20 Apr 2016 10:01:02 -0700 Subject: [PATCH] remove py26, better pre-commit support, cleaner tox --- .travis.yml | 12 +++++------- debian/rules | 2 +- docker_custodian/args.py | 3 ++- docker_custodian/docker_autostop.py | 14 +++++++++----- tests/docker_autostop_test.py | 7 ++++++- tests/docker_gc_test.py | 4 +++- tox.ini | 27 +++++---------------------- 7 files changed, 31 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a69033..c089917 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ language: python env: -- TOX_ENV=py26 -- TOX_ENV=py27 -- TOX_ENV=py33 -- TOX_ENV=py34 +- TOXENV=py27 +- TOXENV=py33 +- TOXENV=py34 install: -- "pip install --use-mirrors tox" +- pip install tox script: -- tox -e $TOX_ENV -sudo: false +- tox diff --git a/debian/rules b/debian/rules index f99ac62..33a8722 100755 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ export DH_OPTIONS dh $@ --with python-virtualenv override_dh_virtualenv: - dh_virtualenv + dh_virtualenv --python python2.7 # do not call `make clean` as part of packaging override_dh_auto_clean: diff --git a/docker_custodian/args.py b/docker_custodian/args.py index a664388..201fb27 100644 --- a/docker_custodian/args.py +++ b/docker_custodian/args.py @@ -7,7 +7,8 @@ from pytimeparse import timeparse def timedelta_type(value): """Return the :class:`datetime.datetime.DateTime` for a time in the past. - :param value: a string containing a time format supported by :mod:`pytimeparse` + :param value: a string containing a time format supported by + mod:`pytimeparse` """ if value is None: return None diff --git a/docker_custodian/docker_autostop.py b/docker_custodian/docker_autostop.py index 2672825..021f60e 100644 --- a/docker_custodian/docker_autostop.py +++ b/docker_custodian/docker_autostop.py @@ -77,18 +77,22 @@ def get_opts(args=None): parser.add_argument( '--max-run-time', type=timedelta_type, - help="Maximum time a container is allows to run. Time may be specified " - "in any pytimeparse supported format.") + help="Maximum time a container is allows to run. Time may " + "be specified in any pytimeparse supported format." + ) parser.add_argument( '--prefix', action="append", default=[], help="Only stop containers which match one of the " - "prefix.") + "prefix." + ) parser.add_argument( '--dry-run', action="store_true", - help="Only log actions, don't stop anything.") + help="Only log actions, don't stop anything." + ) parser.add_argument( '-t', '--timeout', type=int, default=60, - help="HTTP timeout in seconds for making docker API calls.") + help="HTTP timeout in seconds for making docker API calls." + ) opts = parser.parse_args(args=args) if not opts.prefix: diff --git a/tests/docker_autostop_test.py b/tests/docker_autostop_test.py index 4087266..8f0a2a4 100644 --- a/tests/docker_autostop_test.py +++ b/tests/docker_autostop_test.py @@ -54,7 +54,12 @@ def test_has_been_running_since_false(container, earlier_time): @mock.patch('docker_custodian.docker_autostop.get_opts', autospec=True) @mock.patch('docker_custodian.docker_autostop.docker', autospec=True) -def test_main(mock_docker, mock_get_opts, mock_stop_containers, mock_build_matcher): +def test_main( + mock_docker, + mock_get_opts, + mock_stop_containers, + mock_build_matcher +): mock_get_opts.return_value.timeout = 30 main() mock_get_opts.assert_called_once_with() diff --git a/tests/docker_gc_test.py b/tests/docker_gc_test.py index b6a79bd..01486bc 100644 --- a/tests/docker_gc_test.py +++ b/tests/docker_gc_test.py @@ -182,7 +182,9 @@ def test_api_call_with_timeout(): docker_gc.api_call(func, id) func.assert_called_once_with(id) - mock_log.warn.assert_called_once_with('Failed to call remove_image abcd msg') + mock_log.warn.assert_called_once_with( + 'Failed to call remove_image abcd msg' + ) def test_api_call_with_api_error(): diff --git a/tox.ini b/tox.ini index 84ba441..355c2b5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,30 +1,13 @@ [tox] -envlist = py26,py27,py33,py34 +envlist = py27,py33,py34 [testenv] deps = -rrequirements.txt - flake8 - pytest mock -commands = - py.test {posargs:tests} - flake8 . - -[testenv:py26] -deps = - -rrequirements.txt - flake8 - pytest - mock < 1.1.0 - -[testenv:install-hooks] -deps = pre-commit + pytest commands = - pre-commit install - -[flake8] -ignore = -exclude = .git/*,.tox/*,debian/* -max_line_length = 85 + py.test {posargs:tests} + pre-commit install -f --install-hooks + pre-commit run --all-files